Mockarty CLI
mockarty-cli is the command-line client for Mockarty. One binary covers the
work you do from a terminal: serving mock APIs on your machine, running API and
load tests, fuzzing, checking contracts, running Test Plans, and querying a
connected Mockarty server.
It runs in two ways:
- Standalone — no server and no licence needed.
serve,run,perf,
fuzz,test runandcontract verifyexecute on your machine. - Connected — signed in to a Mockarty server. Mock, Test Plan, run history,
TCM and team data live on the server and are shared with the web UI.
About URLs in examples: examples use
localhost:5770for a local Mockarty
server. Replace it with your own address. The standalone mock server examples
use port8080.
The complete command list is in CLI command reference.
Install
- Download the binary for your OS and architecture and
checksums.txtfrom the same CLI release. - Compare the binary SHA-256 with its entry in
checksums.txt. Usesha256sumon Linux,shasum -a 256on macOS orGet-FileHash -Algorithm SHA256in PowerShell. - Add the verified file to your
PATHasmockarty-cliormockarty-cli.exeon Windows. This example uses Linux amd64:
mkdir -p "$HOME/.local/bin"
install -m 755 mockarty-cli-linux-amd64 "$HOME/.local/bin/mockarty-cli"
export PATH="$HOME/.local/bin:$PATH"
Check the installed version:
mockarty-cli version
Sign in to a server
Use an API token — the same token the web UI issues for automation:
mockarty-cli login --server https://mockarty.example.com --token mk_xxx
Give the connection a name when you work with more than one server:
mockarty-cli login --server https://staging.example.com --token mk_staging --name staging
mockarty-cli login --server https://mockarty.example.com --token mk_prod --name production
mockarty-cli config get-contexts
mockarty-cli config use-context staging
Check the current connection, switch it, or remove it:
mockarty-cli login --status
mockarty-cli config view
mockarty-cli config delete-context old-server
For an interactive sign-in with a browser (OAuth device flow), use
mockarty-cli auth login — see OAuth login.
Verify that the server is reachable, the token works, and the namespace is
accessible:
mockarty-cli verify
verify exits 0 only when every check passes, so it is a good first step in
a pipeline.
Choose how you work
What do you want to do?
| Task | Command |
|---|---|
| Serve mocks from files on this machine | mockarty-cli serve -f mocks/ --port 8080 |
| Replace WireMock or Mockoon | mockarty-cli mock serve --data-dir ./stubs |
| Run an API collection from a file | mockarty-cli run -f collection.json |
| Run a collection stored on the server | mockarty-cli run collection "Smoke" |
| Run a Postman collection | mockarty-cli postman run collection.json |
| Run a Mockarty-native test manifest | mockarty-cli test run flow.mockarty.json |
| Load-test a k6-style script | mockarty-cli perf run load.js --vus 10 --duration 30s |
| Fuzz an API | mockarty-cli fuzz --target https://api.example.com --spec openapi.yaml |
| Check mocks against an OpenAPI spec | mockarty-cli contract validate --spec openapi.yaml |
| Check a live service against a spec | mockarty-cli contract verify --spec openapi.yaml --target https://api.example.com |
| Turn a spec, HAR or Postman file into mocks | mockarty-cli generate openapi spec.yaml --upload |
| Create, list, inspect or delete mocks | mockarty-cli mock create -f mock.json, mock list, mock get <id>, mock delete <id> |
| Back up all mocks | mockarty-cli mock export -d backup/ |
| Restore a backup | mockarty-cli mock import -f backup/ |
| Run a Test Plan | mockarty-cli testplan run <plan-id> --wait |
| Download a run report | mockarty-cli testplan report <run-id> --plan <plan-id> --zip report.zip |
| Switch namespace | mockarty-cli namespace use <namespace> |
| Diagnose a broken install | mockarty-cli health --verbose |
| Collect a support archive | mockarty-cli support-bundle --url https://mockarty.example.com --out support.zip |
Output formats
Data commands accept -o:
| Value | Output |
|---|---|
table |
Human-readable table (default) |
wide |
Table with extra columns |
json |
Machine-readable JSON |
quiet |
IDs only, one per line |
mockarty-cli mock list -o json | jq '.mocks[] | .id'
mockarty-cli mock list -o quiet | xargs -I{} mockarty-cli mock delete {}
Connection settings
Higher rows win:
| Source | Example |
|---|---|
--server, --token, --namespace flags |
mockarty-cli --server https://mk.example.com mock list |
| Environment variables | export MOCKARTY_SERVER=https://mk.example.com |
Saved context (login, config set-context) |
mockarty-cli config use-context staging |
| Built-in default | http://localhost:5770 |
Environment variables read by the CLI:
| Variable | Meaning |
|---|---|
MOCKARTY_SERVER |
Server URL |
MOCKARTY_TOKEN |
API token |
MOCKARTY_NAMESPACE |
Namespace |
MOCKARTY_OUTPUT |
Output format |
MOCKARTY_TLS_INSECURE |
Skip TLS verification (lab use only) |
NO_COLOR |
Disable coloured output |
Standalone: no server needed
Serve mocks
serve runs the full mock engine locally and loads native Mockarty mocks:
echo '{"id":"hello","http":{"route":"/hello/:name","httpMethod":"GET"},
"response":{"statusCode":200,"payload":{"message":"Hello, $.pathParam.name!"}}}' > mock.json
mockarty-cli serve -f mock.json --port 8080
curl http://localhost:8080/hello/World
# {"message":"Hello, World!"}
Other serve options:
mockarty-cli serve -f mocks/ --port 9090 # directory of mock files
mockarty-cli serve -f mocks/ --watch # reload on file changes
mockarty-cli serve --har traffic.har # serve from a HAR recording
mockarty-cli serve -f mocks/ --proto protos/ --grpc-port 50051
The server exposes an SDK-compatible mock API at /api/v1/mocks and a health
endpoint at /health.
Serve WireMock / Mockoon stubs
mock serve accepts WireMock, Mockoon and Mockarty files, detected per file.
It also exposes the WireMock admin API (/__admin/mappings) and the native
admin API (/__admin/api/v1/mocks):
mockarty-cli mock serve --port 8080 --data-dir ./stubs
curl http://localhost:8080/__admin/health
Add a stub at run time:
curl -X POST http://localhost:8080/__admin/mappings \
-H 'Content-Type: application/json' \
-d '{"request":{"method":"GET","url":"/api/users"},"response":{"status":200,"body":"{\"ok\":true}"}}'
curl http://localhost:8080/api/users
# {"ok":true}
Run API tests
mockarty-cli run -f collection.json --reporter cli
mockarty-cli run -f tests/ --reporter cli --reporter junit:report.xml
Reporters can be repeated: cli, json:FILE, junit:FILE, allure:DIR,
html:FILE.
Useful flags:
| Flag | Meaning |
|---|---|
-f, --file |
Collection file or directory (- reads stdin) |
--har |
Run a HAR recording as the collection |
--env-file, --env-var |
Environment variables (--env-var KEY=VALUE, repeatable) |
--iterations |
Number of iterations |
--delay, --timeout |
Pacing and per-request timeout |
--bail |
Stop at the first failure |
--folder |
Only requests whose name starts with this prefix |
A run that executes nothing — an empty collection or a --folder that matches
no request — exits 1, not 0.
Run a Mockarty-native test manifest
test run executes a declarative manifest with HTTP steps and assertions:
{
"apiVersion": "mockarty/v1",
"kind": "FunctionalTest",
"metadata": {"name": "Smoke"},
"spec": {
"steps": [
{
"name": "hello",
"kind": "http",
"request": {"method": "GET", "url": "http://localhost:8080/hello/World"},
"assertions": [
{"name": "status", "expr": "status == 200"},
{"name": "body", "expr": "body contains Hello, World!"}
]
}
]
}
}
mockarty-cli test run smoke.mockarty.json
Assertion expressions are status == N, status != N, body contains TEXT and
body == TEXT.
Run a Postman collection
mockarty-cli postman run collection.json --env-var base_url=https://api.example.com
The command keeps Newman’s flags: --env, --globals, --iterations,
--data, --folder, --bail, --reporter, --out.
Load testing
mockarty-cli perf run load.js --vus 10 --duration 30s
mockarty-cli perf run load.js --rps 200 --out json:result.json --out html:report.html
mockarty-cli perf run --har traffic.har --vus 5 --duration 30s
Scripts use k6-style imports (mockarty/http or k6/http), __ENV variables
and thresholds. A breached threshold, an abnormal stop, or a run that measured
nothing exits 99.
To run a load profile that lives on the server, use
mockarty-cli perf run-config "<name-or-id>" --wait.
Fuzzing
mockarty-cli fuzz --target https://api.example.com --spec openapi.yaml
mockarty-cli fuzz --target https://api.example.com --spec openapi.yaml \
--strategy all --duration 5m --threads 4 \
--out json:findings.json --out junit:fuzz-report.xml
Strategies: security (injection, XSS, path traversal), mutation (type and
boundary mutation), all. Exit codes: 0 no findings, 1 findings or nothing
executed, 2 the scan did not run.
Contract testing
# Validate the mocks on the server against a spec
mockarty-cli contract validate --spec openapi.yaml
# Verify a live service against a spec
mockarty-cli contract verify --spec openapi.yaml --target https://api.example.com
# Compare the mocks with a live API
mockarty-cli contract drift --target https://api.example.com
# Deploy gate and deployment ledger
mockarty-cli contract can-i-deploy --participant user-service --version "$GIT_SHA" --to production
mockarty-cli contract record-deployment --service user-service --version "$GIT_SHA" --environment production
contract verify refuses loopback and private targets; point it at the real
service you want to check.
Connected: work on a server
Mocks
mockarty-cli mock create -f mock.json # create or update
mockarty-cli mock create -f mocks/ # every file in a directory
cat mock.json | mockarty-cli mock create -f - # from stdin
mockarty-cli mock list
mockarty-cli mock list --protocol grpc
mockarty-cli mock get <mock-id>
mockarty-cli mock logs <mock-id>
mockarty-cli mock delete <mock-id> # recoverable from the recycle bin
Back up and restore:
mockarty-cli mock export -d backup/ # one JSON file per mock
mockarty-cli mock import -f backup/ # create or update
A single-file export (mock export -d backup.json) writes the same mocks in one
JSON document and can be imported the same way.
Declarative apply, with optional pruning of mocks that are not in the files:
mockarty-cli mock apply -f mocks/
mockarty-cli mock apply -f mocks/ --prune
Convert WireMock, Mockoon or GripMock stubs into Mockarty mock files:
mockarty-cli mock convert ./wiremock-stubs --from wiremock --out ./mocks
mockarty-cli mock convert ./wiremock-stubs --out ./mocks --report preflight.json
Files are stamped with the active namespace; import them with mock import -f.
Generate mocks from a specification
The API-first generators preview against the server by default and only save
with --upload:
mockarty-cli generate openapi spec.yaml --upload
mockarty-cli generate openapi spec.yaml # preview, prints JSON
mockarty-cli generate grpc service.proto --upload
HAR and Postman conversion is local and writes mock files:
mockarty-cli generate har recording.har --out mocks/
mockarty-cli generate postman collection.json --out mocks/
The reverse direction builds a specification from the mocks already on the
server:
mockarty-cli generate spec --format openapi > openapi.json
Collections and runs on the server
If the collection is authored in the web UI, run it by name or id:
mockarty-cli run collection "Smoke"
mockarty-cli run collection 0d1b7b0f-...
Names are resolved in the active namespace; an unknown or ambiguous name stops
with the candidates instead of guessing.
Test Plans and reports
# plan.yaml
name: Nightly regression
items:
- order: 1
type: functional
resourceId: <collection-id>
mockarty-cli testplan create -f plan.yaml
mockarty-cli testplan list
mockarty-cli testplan run <plan-id> --wait
mockarty-cli testplan runs <plan-id>
Download the run in the shape your pipeline needs:
mockarty-cli testplan report <run-id> --plan <plan-id> --zip allure.zip
mockarty-cli testplan report <run-id> --plan <plan-id> --format junit --out junit.xml
mockarty-cli testplan report <run-id> --plan <plan-id> --format markdown
Formats: zip/allure (default), json, junit, markdown, unified,
html.
Test case management
mockarty-cli tcm folders create --name "Checkout"
mockarty-cli tcm folders tree
mockarty-cli tcm folders move <folder-id> <new-parent-id>
mockarty-cli tcm folders rm <folder-id>
tcm discover --manifest cases.json syncs a test framework’s case list into the
catalogue.
Recycle bin
mock delete and similar commands are soft deletes:
mockarty-cli trash list
mockarty-cli trash summary
mockarty-cli trash restore <cascade-group-id>
mockarty-cli trash purge <cascade-group-id>
Purge is irreversible.
Stores, audit, tokens
mockarty-cli store global set featureFlag on
mockarty-cli store global get
mockarty-cli store global delete featureFlag
mockarty-cli audit export --format csv --output audit.csv
mockarty-cli audit export --format json --output audit.json
Token management, backups, the AI agent, and cluster management need the
matching licence on the server; the command tells you when it is not included.
Namespaces
mockarty-cli namespace list
mockarty-cli namespace current
mockarty-cli namespace use my-team
mockarty-cli ns current # short alias
An administrator can create a namespace:
mockarty-cli namespace create my-team
Support archive
support-bundle collects health snapshots, redacted configuration and log
tails into one zip. Secrets are masked before they are written:
mockarty-cli support-bundle --url https://mockarty.example.com --token "$MOCKARTY_TOKEN" --out support.zip
CI/CD
Gate the pipeline
mockarty-cli verify
mockarty-cli wait --mocks user-api,order-api --timeout 120s
mockarty-cli wait --mock-count 5
wait blocks until the server is healthy and, when you ask, until those mocks
exist.
Exit codes
| Code | Meaning |
|---|---|
0 |
The work ran and the result is good |
1 |
The work ran and the result is bad — a test failed, a contract was violated, nothing was executed |
2 |
The work did not run — unknown subcommand or flag, no server configured, a feature your licence does not include |
Branch on 2 to tell a misconfigured step from a red test suite.
Example pipeline
Set CLI_RELEASE_TAG in CI to an exact tag from CLI releases. Both examples use Linux amd64.
GitHub Actions
name: API tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Mockarty CLI
env:
CLI_RELEASE_TAG: ${{ vars.CLI_RELEASE_TAG }}
run: |
set -euo pipefail
: "${CLI_RELEASE_TAG:?Set the published CLI release tag}"
asset=mockarty-cli-linux-amd64
base="https://github.com/mockarty/mockarty-cli/releases/download/$CLI_RELEASE_TAG"
curl -fsSLo "$asset" "$base/$asset"
curl -fsSLo checksums.txt "$base/checksums.txt"
awk -v asset="$asset" '$2 == asset { print }' checksums.txt | sha256sum --check -
install -m 755 "$asset" /usr/local/bin/mockarty-cli
- name: Start mock server
run: mockarty-cli serve -f mocks/ --port 8080 &
- name: Wait for the server
run: mockarty-cli wait --server http://localhost:8080 --timeout 30s
- name: Run API tests
run: mockarty-cli run -f tests/ --reporter cli --reporter junit:report.xml
- name: Upload the report
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports
path: report.xml
GitLab CI
api-tests:
image: debian:bookworm-slim
before_script:
- apt-get update && apt-get install -y --no-install-recommends ca-certificates curl
- |
set -eu
: "${CLI_RELEASE_TAG:?Set the published CLI release tag}"
asset=mockarty-cli-linux-amd64
base="https://github.com/mockarty/mockarty-cli/releases/download/$CLI_RELEASE_TAG"
curl -fsSLo "$asset" "$base/$asset"
curl -fsSLo checksums.txt "$base/checksums.txt"
awk -v asset="$asset" '$2 == asset { print }' checksums.txt | sha256sum --check -
install -m 755 "$asset" /usr/local/bin/mockarty-cli
script:
- mockarty-cli serve -f mocks/ --port 8080 &
- mockarty-cli wait --server http://localhost:8080 --timeout 30s
- mockarty-cli run -f tests/ --reporter cli --reporter junit:report.xml
artifacts:
when: always
reports:
junit: report.xml
Running server-side suites from a manifest:
mockarty-cli ci run-suite suite.yaml
A suite executes test jobs (Mockarty-native manifests). postman, load,
fuzz and chaos jobs are reported as not executed, with the standalone
command to run instead.
apiVersion: mockarty.ci/v1
kind: CISuite
metadata:
name: nightly
spec:
jobs:
- name: functional
kind: test
manifest: tests/smoke.mockarty.json
Terminal UI
mockarty-cli tui opens an interactive terminal UI for the same server: auth
status, Test Plans, results, mocks, perf configs, fuzz targets and chaos
experiments. See TUI user guide.
Shell completion
mockarty-cli completion bash > /etc/bash_completion.d/mockarty-cli
mockarty-cli completion zsh > "${fpath[1]}/_mockarty-cli"
mockarty-cli completion fish > ~/.config/fish/completions/mockarty-cli.fish
Troubleshooting
| Symptom | Cause / fix |
|---|---|
command not found |
The binary is not on PATH. Move it to /usr/local/bin or add its directory to PATH. |
connection refused |
Server is not running, or the URL is wrong. Check MOCKARTY_SERVER and run mockarty-cli health. |
401 unauthorized |
Missing or revoked token. Run mockarty-cli login again, or set MOCKARTY_TOKEN. |
403 forbidden on a namespace |
The token is pinned to another namespace. Use a token for the target namespace. |
x509: certificate signed by unknown authority |
Self-signed certificate. Add the CA to your trust store; --insecure is for lab use only. |
| A command says the licence does not include it | The server’s licence does not grant that module. Ask the administrator. |
| HAR import produces no mocks | The HAR has no HTTP entries. Re-export it without filters. |
| Chaos experiment refused | Fault injection changes a live cluster and needs an explicit acknowledgement: --i-know-this-is-preview (or MOCKARTY_CHAOS_PREVIEW=1). |
For connection problems, mockarty-cli health --verbose prints the server’s
version, uptime and licence tier.
Related documentation
- CLI command reference — every command and flag.
- TUI user guide — the interactive terminal surface.
- OAuth login — browser sign-in.
- Feature access — what a licence unlocks.
- Contract testing — contracts and the deployment ledger.
- Store systems — global and chain stores.
- SDK guide — the same operations from code.