Skip to content

CLI Reference

Complete reference for the mockd command-line interface.

These flags apply to all commands:

FlagDescription
-h, --helpShow help message
-v, --versionShow version information

Start the mock server (default command).

Terminal window
mockd serve [flags]

Flags:

FlagShortDescriptionDefault
--port-pHTTP server port4280
--admin-port-aAdmin API port4290
--config-cPath to mock configuration file
--https-portHTTPS server port (0 = disabled)0
--read-timeoutRead timeout in seconds30
--write-timeoutWrite timeout in seconds30
--max-log-entriesMaximum request log entries1000
--auto-certAuto-generate TLS certificatetrue

TLS Flags:

FlagDescription
--tls-certPath to TLS certificate file
--tls-keyPath to TLS private key file
--tls-autoAuto-generate self-signed certificate

mTLS Flags:

FlagDescription
--mtls-enabledEnable mTLS client certificate validation
--mtls-client-authClient auth mode (none, request, require, verify-if-given, require-and-verify)
--mtls-caPath to CA certificate for client validation
--mtls-allowed-cnsComma-separated list of allowed Common Names

Audit Flags:

FlagDescription
--audit-enabledEnable audit logging
--audit-filePath to audit log file
--audit-levelLog level (debug, info, warn, error)

Runtime Mode Flags (register with control plane):

FlagDescriptionDefault
--registerRegister with control plane as a runtime
--control-planeControl plane URLhttps://api.mockd.io
--tokenRuntime token (or MOCKD_RUNTIME_TOKEN env var)
--nameRuntime name (required with —register)
--labelsRuntime labels (key=value,key2=value2)

Pull Mode Flags:

FlagDescription
--pullmockd:// URI to pull and serve
--cacheLocal cache directory for pulled mocks

GraphQL Flags:

FlagDescriptionDefault
--graphql-schemaPath to GraphQL schema file
--graphql-pathGraphQL endpoint path/graphql

OAuth Flags:

FlagDescription
--oauth-enabledEnable OAuth provider
--oauth-issuerOAuth issuer URL
--oauth-portOAuth server port

Chaos Flags:

FlagDescription
--chaos-enabledEnable chaos injection
--chaos-latencyAdd random latency (e.g., “10ms-100ms”)
--chaos-error-rateError rate (0.0-1.0)

Validation Flags:

FlagDescriptionDefault
--validate-specPath to OpenAPI spec for request validation
--validate-failFail on validation errorfalse

Daemon Flags:

FlagShortDescriptionDefault
--detach-dRun server in background (daemon mode)
--pid-filePath to PID file~/.mockd/mockd.pid

Logging Flags:

FlagDescriptionDefault
--log-levelLog level (debug, info, warn, error)info
--log-formatLog format (text, json)text
--loki-endpointLoki endpoint for log aggregation

Tracing Flags:

FlagDescriptionDefault
--otlp-endpointOTLP HTTP endpoint for distributed tracing (e.g., http://localhost:4318/v1/traces)
--trace-samplerTrace sampling ratio (0.0-1.0)1.0

Examples:

Terminal window
# Start with defaults
mockd serve
# Start with config file on custom port
mockd serve --config mocks.json --port 3000
# Register as a runtime
mockd serve --register --name ci-runner-1 --token $MOCKD_RUNTIME_TOKEN
# Pull and serve from cloud
mockd serve --pull mockd://acme/payment-api
# Start with TLS using certificate files
mockd serve --tls-cert server.crt --tls-key server.key --https-port 8443
# Start with mTLS enabled
mockd serve --mtls-enabled --mtls-ca ca.crt --tls-cert server.crt --tls-key server.key
# Start with audit logging
mockd serve --audit-enabled --audit-file audit.log --audit-level debug
# Start in daemon/background mode
mockd serve -d
# Start with distributed tracing (send traces to Jaeger)
mockd serve --otlp-endpoint http://localhost:4318/v1/traces
# Start with JSON structured logging
mockd serve --log-level debug --log-format json
# Send logs to Loki for aggregation
mockd serve --loki-endpoint http://localhost:3100/loki/api/v1/push

Start the mock server (alias for serve with additional directory loading features).

Terminal window
mockd start [flags]

Flags:

FlagShortDescriptionDefault
--port-pHTTP server port4280
--admin-port-aAdmin API port4290
--config-cPath to mock configuration file
--loadLoad mocks from directory
--watchWatch for file changes (with —load)
--validateValidate files before serving (with —load)
--https-portHTTPS server port (0 = disabled)0
--read-timeoutRead timeout in seconds30
--write-timeoutWrite timeout in seconds30
--max-log-entriesMaximum request log entries1000
--auto-certAuto-generate TLS certificatetrue

Also supports all TLS, mTLS, Audit, GraphQL, gRPC, OAuth, MQTT, Chaos, and Validation flags from serve.

Examples:

Terminal window
# Start with defaults
mockd start
# Start with config file on custom port
mockd start --config mocks.json --port 3000
# Start with HTTPS enabled
mockd start --https-port 8443
# Load mocks from directory
mockd start --load ./mocks/
# Load with hot reload
mockd start --load ./mocks/ --watch
# Validate mocks before serving
mockd start --load ./mocks/ --validate

Stop a running mockd server.

Terminal window
mockd stop [component] [flags]

Arguments:

ArgumentDescription
componentOptional component to stop: “admin” or “engine” (if not specified, stops all)

Flags:

FlagShortDescriptionDefault
--pid-filePath to PID file~/.mockd/mockd.pid
--force-fSend SIGKILL instead of SIGTERM
--timeoutTimeout in seconds to wait for shutdown10

Examples:

Terminal window
# Stop all components
mockd stop
# Force stop
mockd stop --force
# Stop with custom PID file
mockd stop --pid-file /tmp/mockd.pid
# Stop with longer timeout
mockd stop --timeout 30

Show status of running mockd server.

Terminal window
mockd status [flags]

Flags:

FlagDescriptionDefault
--pid-filePath to PID file~/.mockd/mockd.pid
--jsonOutput in JSON format

Examples:

Terminal window
# Check server status
mockd status
# Output as JSON
mockd status --json
# Use custom PID file
mockd status --pid-file /tmp/mockd.pid

Show all ports in use by the running mockd server.

Terminal window
mockd ports [flags]

Flags:

FlagShortDescriptionDefault
--pid-filePath to PID file~/.mockd/mockd.pid
--admin-port-aAdmin API port to query4290
--jsonOutput in JSON format

Output:

The command displays a table of all ports with their protocol, component, and status:

PORT PROTOCOL COMPONENT STATUS
------- ---------- --------------- --------
1883 MQTT MQTT Broker running
4280 HTTP Mock Engine running
4290 HTTP Admin API running
50051 gRPC gRPC Server running

Examples:

Terminal window
# Show all ports
mockd ports
# Output as JSON
mockd ports --json
# Query a different admin port
mockd ports --admin-port 8090

Create a starter mockd configuration file.

Terminal window
mockd init [flags]

Flags:

FlagShortDescriptionDefault
--forceOverwrite existing config file
--output-oOutput filenamemockd.yaml
--formatOutput format: yaml or jsoninferred from filename
--interactive-iInteractive mode - prompts for configuration
--template-tTemplate to usedefault

Templates:

TemplateDescription
defaultBasic HTTP mocks (hello, echo, health)
crudFull REST CRUD API for resources
websocket-chatChat room WebSocket endpoint with echo
graphql-apiGraphQL API with User CRUD resolvers
grpc-servicegRPC Greeter service with reflection
mqtt-iotMQTT broker with IoT sensor topics

Examples:

Terminal window
# Create default mockd.yaml
mockd init
# List available templates
mockd init --template list
# Use CRUD API template
mockd init --template crud
# Use WebSocket template with custom output
mockd init -t websocket-chat -o websocket.yaml
# Interactive setup
mockd init -i
# Create with custom filename
mockd init -o my-mocks.yaml
# Create JSON config
mockd init --format json -o mocks.json
# Overwrite existing config
mockd init --force

Add a new mock endpoint.

Terminal window
mockd add [flags]

Global Flags:

FlagShortDescriptionDefault
--type-tMock type: http, websocket, graphql, grpc, mqtt, soaphttp
--name-nMock display name
--admin-urlAdmin API base URLhttp://localhost:4290
--jsonOutput in JSON format

HTTP Flags (--type http):

FlagShortDescriptionDefault
--method-mHTTP method to matchGET
--pathURL path to matchRequired
--status-sResponse status code200
--body-bResponse body
--body-fileRead response body from file
--header-HResponse header (key:value), repeatable
--match-headerRequired request header (key:value), repeatable
--match-queryRequired query param (key:value), repeatable
--priorityMock priority (higher = matched first)
--delayResponse delay in milliseconds

SSE Flags (HTTP with streaming):

FlagDescriptionDefault
--sseEnable SSE streaming response
--sse-eventSSE event (type:data), repeatable
--sse-delayDelay between events in milliseconds100
--sse-templateBuilt-in template: openai-chat, notification-stream
--sse-repeatRepeat events N times (0 = infinite)1
--sse-keepaliveKeepalive interval in milliseconds (0 = disabled)0

WebSocket Flags (--type websocket):

FlagDescriptionDefault
--pathWebSocket pathRequired
--messageDefault response message (JSON)
--echoEnable echo mode

GraphQL Flags (--type graphql):

FlagDescriptionDefault
--pathGraphQL endpoint path/graphql
--operationOperation nameRequired
--op-typeOperation type: query or mutationquery
--responseJSON response data

gRPC Flags (--type grpc):

FlagDescriptionDefault
--protoPath to .proto file (required, repeatable)
--proto-pathImport path for proto dependencies (repeatable)
--serviceService name, e.g., myapp.UserService (required)
--rpc-methodRPC method name (required)
--responseJSON response data
--grpc-portgRPC server port50051

MQTT Flags (--type mqtt):

FlagDescriptionDefault
--topicTopic patternRequired
--payloadResponse payload
--qosQoS level: 0, 1, or 20
--mqtt-portMQTT broker port (required)

SOAP Flags (--type soap):

FlagDescriptionDefault
--pathSOAP endpoint path/soap
--operationSOAP operation nameRequired
--soap-actionSOAPAction header value
--responseXML response body

Examples:

Terminal window
# Simple HTTP GET mock
mockd add --path /api/users --status 200 --body '[]'
# HTTP POST with JSON response
mockd add -m POST --path /api/users -s 201 \
-b '{"id": "new-id", "created": true}' \
-H "Content-Type:application/json"
# WebSocket mock with echo mode
mockd add --type websocket --path /ws/chat --echo
# WebSocket mock with default response
mockd add --type websocket --path /ws/events \
--message '{"type": "connected", "status": "ok"}'
# GraphQL query mock
mockd add --type graphql --operation getUser \
--response '{"data": {"user": {"id": "1", "name": "Alice"}}}'
# GraphQL mutation mock
mockd add --type graphql --operation createUser --op-type mutation \
--response '{"data": {"createUser": {"id": "new-id"}}}'
# gRPC mock
mockd add --type grpc --service greeter.Greeter --rpc-method SayHello \
--response '{"message": "Hello, World!"}'
# MQTT mock
mockd add --type mqtt --topic sensors/temperature --payload '{"temp": 72.5}' --qos 1
# SOAP mock
mockd add --type soap --operation GetWeather --soap-action "http://example.com/GetWeather" \
--response '<GetWeatherResponse><Temperature>72</Temperature></GetWeatherResponse>'
# SSE streaming mock with custom events
mockd add --path /events --sse \
--sse-event 'connected:{"status":"ok"}' \
--sse-event 'update:{"count":1}' \
--sse-event 'update:{"count":2}' \
--sse-delay 500
# SSE with OpenAI-compatible streaming template
mockd add -m POST --path /v1/chat/completions --sse --sse-template openai-chat
# SSE with infinite keepalive ping
mockd add --path /stream --sse \
--sse-event 'ping:{}' --sse-delay 1000 --sse-repeat 0

Create mocks from templates.

Terminal window
mockd new [flags]

Flags:

FlagShortDescriptionDefault
--template-tTemplate: blank, crud, auth, pagination, errorsblank
--name-nCollection name
--output-oOutput filestdout
--resourceResource name (for crud/pagination templates)

Templates:

TemplateDescription
blankEmpty mock collection
crudREST CRUD endpoints (GET list, GET one, POST, PUT, DELETE)
authAuthentication flow (login, logout, refresh, me)
paginationList endpoints with cursor/offset pagination
errorsCommon HTTP error responses (400, 401, 403, 404, 500)

Examples:

Terminal window
# Create a blank collection
mockd new -t blank -o mocks.yaml
# Create CRUD endpoints for users
mockd new -t crud --resource users -o users.yaml
# Create auth endpoints
mockd new -t auth -n "Auth API" -o auth.yaml

List all configured mocks.

Terminal window
mockd list [flags]

Flags:

FlagShortDescriptionDefault
--config-cList mocks from config file (no server needed)
--type-tFilter by type: http, websocket, graphql, grpc, mqtt, soap
--admin-urlAdmin API base URLhttp://localhost:4290
--jsonOutput in JSON format

Examples:

Terminal window
# List all mocks from running server
mockd list
# List mocks from config file (no server needed)
mockd list --config mockd.yaml
# List only WebSocket mocks
mockd list --type websocket
# List as JSON
mockd list --json
# List from remote server
mockd list --admin-url http://remote:4290

Get details of a specific mock.

Terminal window
mockd get <mock-id> [flags]

Arguments:

ArgumentDescription
mock-idID of the mock to retrieve (required)

Flags:

FlagDescriptionDefault
--admin-urlAdmin API base URLhttp://localhost:4290
--jsonOutput in JSON format

Examples:

Terminal window
# Get mock details
mockd get abc123
# Get as JSON
mockd get abc123 --json

Delete a mock by ID.

Terminal window
mockd delete <mock-id> [flags]

Arguments:

ArgumentDescription
mock-idID of the mock to delete (required)

Flags:

FlagDescriptionDefault
--admin-urlAdmin API base URLhttp://localhost:4290

Examples:

Terminal window
mockd delete abc123

Import mocks from various sources and formats.

Terminal window
mockd import <source> [flags]

Arguments:

ArgumentDescription
sourcePath to file, or cURL command (in quotes)

Flags:

FlagShortDescriptionDefault
--format-fForce format (auto-detected if omitted)
--replaceReplace all existing mocksmerge
--dry-runPreview import without saving
--include-staticInclude static assets (for HAR imports)
--admin-urlAdmin API base URLhttp://localhost:4290

Supported Formats:

FormatDescription
mockdMockd native format (YAML/JSON)
openapiOpenAPI 3.x or Swagger 2.0
postmanPostman Collection v2.x
harHTTP Archive (browser recordings)
wiremockWireMock JSON mappings
curlcURL command

Examples:

Terminal window
# Import from OpenAPI spec (auto-detected)
mockd import openapi.yaml
# Import from Postman collection
mockd import collection.json -f postman
# Import from HAR file including static assets
mockd import recording.har --include-static
# Import from cURL command
mockd import "curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{\"name\": \"test\"}'"
# Preview import without saving
mockd import openapi.yaml --dry-run
# Replace all mocks with imported ones
mockd import mocks.yaml --replace

Export current mocks to file.

Terminal window
mockd export [flags]

Flags:

FlagShortDescriptionDefault
--output-oOutput filestdout
--name-nCollection nameexported-config
--format-fOutput format: mockd, openapimockd
--versionVersion tag for the export
--admin-urlAdmin API base URLhttp://localhost:4290

Formats:

FormatDescription
mockdMockd native format (YAML/JSON) - recommended for portability
openapiOpenAPI 3.x specification - for API documentation

Examples:

Terminal window
# Export to stdout as YAML
mockd export
# Export to JSON file
mockd export -o mocks.json
# Export to YAML file
mockd export -o mocks.yaml
# Export as OpenAPI specification
mockd export -f openapi -o api.yaml
# Export with custom name
mockd export -n "My API Mocks" -o mocks.yaml

View request logs.

Terminal window
mockd logs [flags]

Flags:

FlagShortDescriptionDefault
--protocolFilter by protocol (http, grpc, mqtt, soap, graphql, websocket, sse)
--method-mFilter by HTTP method
--path-pFilter by path (substring match)
--matchedShow only matched requests
--unmatchedShow only unmatched requests
--limit-nNumber of entries to show20
--verboseShow headers and body
--clearClear all logs
--follow-fStream logs in real-time (like tail -f)
--admin-urlAdmin API base URLhttp://localhost:4290
--jsonOutput in JSON format

Examples:

Terminal window
# Show recent logs
mockd logs
# Show last 50 entries
mockd logs -n 50
# Filter by method
mockd logs -m POST
# Filter by protocol
mockd logs --protocol grpc
# Show verbose output
mockd logs --verbose
# Stream logs in real-time
mockd logs --follow
# Clear logs
mockd logs --clear

Show effective configuration.

Terminal window
mockd config [flags]

Flags:

FlagDescription
--jsonOutput in JSON format

Examples:

Terminal window
mockd config
mockd config --json

Diagnose common setup issues and validate configuration.

Terminal window
mockd doctor [flags]

Flags:

FlagShortDescriptionDefault
--config-cPath to config file to validate
--port-pMock server port to check4280
--admin-port-aAdmin API port to check4290

Examples:

Terminal window
# Run all checks with defaults
mockd doctor
# Validate a specific config file
mockd doctor --config mocks.yaml
# Check custom ports
mockd doctor -p 3000 -a 3001

Manage contexts (admin server + workspace pairs). Similar to kubectl contexts, allows quick switching between different mockd deployments (local, staging, CI, cloud, etc.).

Terminal window
mockd context [command]

Subcommands:

CommandDescription
(no command)Show current context
showShow current context (same as no command)
use <name>Switch to a different context
add <name>Add a new context
listList all contexts
remove <name>Remove a context

Configuration:

Contexts are stored in ~/.config/mockd/contexts.yaml. A default “local” context pointing to http://localhost:4290 is created automatically.


Show the current context.

Terminal window
mockd context
mockd context show

Output includes:

  • Current context name
  • Admin URL
  • Workspace (if set)
  • Description (if set)
  • Environment variable overrides (if active)

Switch to a different context.

Terminal window
mockd context use <name>

Examples:

Terminal window
# Switch to staging context
mockd context use staging
# Switch back to local
mockd context use local

Add a new context.

Terminal window
mockd context add <name> [flags]

Flags:

FlagShortDescription
--admin-url-uAdmin API URL (e.g., http://localhost:4290)
--workspace-wDefault workspace for this context
--description-dDescription for this context
--token-tAuth token for cloud/enterprise deployments
--tls-insecureSkip TLS certificate verification (for self-signed certs)
--useSwitch to this context after adding
--jsonOutput in JSON format

Examples:

Terminal window
# Add with flags
mockd context add -u https://staging.example.com:4290 staging
# Add interactively (will prompt for URL)
mockd context add production
# Add and switch to it
mockd context add -u http://dev-server:4290 --use dev
# Add with auth token for cloud deployment
mockd context add -u https://api.mockd.io -t YOUR_TOKEN --use cloud
# Add with workspace preset
mockd context add -u https://staging:4290 -w my-workspace staging

Security Notes:

  • URLs with embedded credentials (http://user:pass@host) are rejected for security
  • Auth tokens are stored in the config file but masked in JSON output
  • Config file is created with 0600 permissions (owner read/write only)

List all contexts.

Terminal window
mockd context list [flags]

Flags:

FlagDescription
--jsonOutput in JSON format

Examples:

Terminal window
# List all contexts
mockd context list
# Output:
# CURRENT NAME ADMIN URL WORKSPACE DESCRIPTION
# * local http://localhost:4290 - Local mockd server
# staging https://staging.example.com ws-123 Staging server
# cloud https://api.mockd.io - Cloud deployment
# JSON output (tokens are masked)
mockd context list --json

Remove a context.

Terminal window
mockd context remove <name> [flags]

Flags:

FlagShortDescription
--force-fForce removal without confirmation

Examples:

Terminal window
# Remove with confirmation prompt
mockd context remove old-server
# Remove without confirmation
mockd context remove old-server --force

Note: The current context cannot be removed. Switch to another context first.


Manage workspaces for organizing mocks. Workspaces allow logical grouping and isolation of mocks within a mockd server.

Terminal window
mockd workspace [command]

Subcommands:

CommandDescription
(no command)Show current workspace
listList all workspaces
use <id>Switch to a workspace
createCreate a new workspace
delete <id>Delete a workspace
clearClear workspace selection (use all mocks)

Show the current workspace.

Terminal window
mockd workspace
mockd workspace show

List all workspaces from the server.

Terminal window
mockd workspace list [flags]

Flags:

FlagDescription
--jsonOutput in JSON format

Switch to a workspace.

Terminal window
mockd workspace use <id>

Examples:

Terminal window
mockd workspace use ws-123
mockd workspace use "my-project"

Create a new workspace.

Terminal window
mockd workspace create [flags]

Flags:

FlagShortDescription
--name-nWorkspace name
--description-dWorkspace description
--useSwitch to this workspace after creating

Examples:

Terminal window
# Create and switch to new workspace
mockd workspace create -n "my-project" --use
# Create with description
mockd workspace create -n "api-tests" -d "Mocks for API integration tests"

Delete a workspace.

Terminal window
mockd workspace delete <id> [flags]

Flags:

FlagShortDescription
--force-fForce deletion without confirmation

Clear the workspace selection to use all mocks.

Terminal window
mockd workspace clear

Manage the MITM proxy for recording API traffic.

Terminal window
mockd proxy <subcommand> [flags]

Subcommands:

  • start - Start the proxy server
  • stop - Stop the proxy server
  • status - Show proxy server status
  • mode - Get or set proxy mode
  • ca - Manage CA certificate

Start the MITM proxy server.

Terminal window
mockd proxy start [flags]

Flags:

FlagShortDescriptionDefault
--port-pProxy server port8888
--mode-mProxy mode: record or passthroughrecord
--session-sRecording session name
--ca-pathPath to CA certificate directory
--includeComma-separated path patterns to include
--excludeComma-separated path patterns to exclude
--include-hostsComma-separated host patterns to include
--exclude-hostsComma-separated host patterns to exclude

Examples:

Terminal window
# Start proxy in record mode
mockd proxy start
# Start with custom port and session
mockd proxy start --port 9000 --session my-session
# Start with filters
mockd proxy start --include "/api/*" --exclude "/api/health"

Stop the running proxy server.

Terminal window
mockd proxy stop

Show the current proxy server status.

Terminal window
mockd proxy status

Get or set the proxy operating mode.

Terminal window
mockd proxy mode [mode]

Arguments:

ArgumentDescription
modeNew mode: record or passthrough (optional)

Examples:

Terminal window
# Get current mode
mockd proxy mode
# Set mode to passthrough
mockd proxy mode passthrough

Manage CA certificate for HTTPS interception.

Terminal window
mockd proxy ca <subcommand> [flags]

Subcommands:

  • export - Export CA certificate for trust installation
  • generate - Generate a new CA certificate

Terminal window
mockd proxy ca export [flags]

Flags:

FlagShortDescriptionDefault
--output-oOutput file pathstdout
--ca-pathPath to CA certificate directory

Examples:

Terminal window
# Export to stdout
mockd proxy ca export
# Export to file
mockd proxy ca export -o ca.crt

Terminal window
mockd proxy ca generate [flags]

Flags:

FlagDescription
--ca-pathPath to CA certificate directory (required)

Examples:

Terminal window
mockd proxy ca generate --ca-path ~/.mockd/ca

Manage recorded API traffic.

Terminal window
mockd recordings <subcommand> [flags]

Subcommands:

  • list - List all recordings
  • convert - Convert recordings to mock definitions
  • export - Export recordings to JSON
  • import - Import recordings from JSON
  • clear - Clear all recordings

List all recorded API requests.

Terminal window
mockd recordings list [flags]

Flags:

FlagDescription
--sessionFilter by session ID
--methodFilter by HTTP method
--pathFilter by request path
--jsonOutput as JSON
--limitMaximum number of recordings to show

Examples:

Terminal window
# List all recordings
mockd recordings list
# List only GET requests
mockd recordings list --method GET
# List as JSON
mockd recordings list --json

Convert recordings to mock definitions.

Terminal window
mockd recordings convert [flags]

Flags:

FlagShortDescriptionDefault
--sessionFilter by session ID
--deduplicateRemove duplicate request patternstrue
--include-headersInclude request headers in matchers
--output-oOutput file pathstdout

Examples:

Terminal window
# Convert all recordings to mocks
mockd recordings convert
# Convert specific session with deduplication
mockd recordings convert --session my-session --deduplicate
# Save to file
mockd recordings convert -o mocks.json

Export recordings to JSON format.

Terminal window
mockd recordings export [flags]

Flags:

FlagShortDescriptionDefault
--sessionExport specific session
--output-oOutput file pathstdout

Examples:

Terminal window
# Export all recordings to stdout
mockd recordings export
# Export specific session to file
mockd recordings export --session my-session -o recordings.json

Import recordings from JSON format.

Terminal window
mockd recordings import [flags]

Flags:

FlagShortDescription
--input-iInput file path (required)

Examples:

Terminal window
mockd recordings import -i recordings.json

Clear all recordings.

Terminal window
mockd recordings clear [flags]

Flags:

FlagShortDescription
--force-fSkip confirmation

Examples:

Terminal window
mockd recordings clear
mockd recordings clear --force

Convert recorded API traffic to mock definitions (standalone command).

Terminal window
mockd convert [flags]

Flags:

FlagShortDescriptionDefault
--recordingConvert a single recording by ID
--sessionConvert all recordings from a session (use “latest” for most recent)
--path-filterGlob pattern to filter paths (e.g., /api/*)
--methodComma-separated HTTP methods (e.g., GET,POST)
--statusStatus code filter (e.g., 2xx, 200,201)
--smart-matchConvert dynamic path segments like /users/123 to /users/{id}
--duplicatesDuplicate handling strategy: first, last, allfirst
--include-headersInclude request headers in mock matchers
--check-sensitiveCheck for sensitive data and show warningstrue
--output-oOutput file pathstdout

Examples:

Terminal window
# Convert a single recording
mockd convert --recording abc123
# Convert latest session with smart matching
mockd convert --session latest --smart-match
# Convert session filtering only GET requests to /api/*
mockd convert --session my-session --path-filter '/api/*' --method GET
# Convert and save to file
mockd convert --session latest -o mocks.json
# Convert only successful responses
mockd convert --session latest --status 2xx

Manage WebSocket and SSE stream recordings.

Terminal window
mockd stream-recordings <subcommand> [flags]

Subcommands:

  • list, ls - List all stream recordings
  • show, get - Show details of a specific recording
  • delete, rm - Delete a recording
  • export - Export a recording to JSON
  • convert - Convert a recording to mock config
  • stats - Show storage statistics
  • vacuum - Remove soft-deleted recordings
  • sessions - List active recording sessions

List all WebSocket and SSE stream recordings.

Terminal window
mockd stream-recordings list [flags]

Flags:

FlagDescriptionDefault
--protocolFilter by protocol (websocket, sse)
--pathFilter by path prefix
--statusFilter by status (complete, incomplete, recording)
--jsonOutput as JSON
--limitMaximum number of recordings to show20
--offsetOffset for pagination
--sortSort by field: startTime, name, sizestartTime
--orderSort order: asc, descdesc
--include-deletedInclude soft-deleted recordings

Examples:

Terminal window
# List all recordings
mockd stream-recordings list
# List only WebSocket recordings
mockd stream-recordings list --protocol websocket
# List as JSON
mockd stream-recordings list --json
# Paginate results
mockd stream-recordings list --limit 10 --offset 20

Show details of a specific stream recording.

Terminal window
mockd stream-recordings show <id> [flags]

Flags:

FlagDescription
--jsonOutput as JSON

Examples:

Terminal window
mockd stream-recordings show 01ABCDEF123456
mockd stream-recordings show 01ABCDEF123456 --json

Delete a stream recording.

Terminal window
mockd stream-recordings delete <id> [flags]

Flags:

FlagShortDescription
--force-fSkip confirmation
--permanentPermanently delete (not soft-delete)

Examples:

Terminal window
mockd stream-recordings delete 01ABCDEF123456
mockd stream-recordings delete 01ABCDEF123456 --force
mockd stream-recordings delete 01ABCDEF123456 --permanent

Export a stream recording to JSON format.

Terminal window
mockd stream-recordings export <id> [flags]

Flags:

FlagShortDescriptionDefault
--output-oOutput file pathstdout

Examples:

Terminal window
mockd stream-recordings export 01ABCDEF123456
mockd stream-recordings export 01ABCDEF123456 -o recording.json

Convert a stream recording to a mock configuration.

Terminal window
mockd stream-recordings convert <id> [flags]

Flags:

FlagShortDescriptionDefault
--output-oOutput file pathstdout
--simplify-timingNormalize timing to reduce noise
--min-delayMinimum delay to preserve in ms10
--max-delayMaximum delay in ms5000
--include-clientInclude client messages as expect stepstrue
--deduplicateRemove consecutive duplicate messages

Examples:

Terminal window
mockd stream-recordings convert 01ABCDEF123456
mockd stream-recordings convert 01ABCDEF123456 --simplify-timing
mockd stream-recordings convert 01ABCDEF123456 -o scenario.json

Show storage statistics for stream recordings.

Terminal window
mockd stream-recordings stats [flags]

Flags:

FlagDescription
--jsonOutput as JSON

Permanently remove soft-deleted recordings.

Terminal window
mockd stream-recordings vacuum [flags]

Flags:

FlagShortDescription
--force-fSkip confirmation

Examples:

Terminal window
mockd stream-recordings vacuum
mockd stream-recordings vacuum --force

List active recording sessions.

Terminal window
mockd stream-recordings sessions [flags]

Flags:

FlagDescription
--jsonOutput as JSON

Generate mock configurations using AI.

Terminal window
mockd generate [flags]

Flags:

FlagShortDescriptionDefault
--input-iInput OpenAPI spec file
--prompt-pNatural language description for generation
--output-oOutput filestdout
--aiEnable AI-powered data generation
--providerAI provider (openai, anthropic, ollama)
--modelAI model to use
--dry-runPreview generation without saving
--admin-urlAdmin API base URLhttp://localhost:4290

Environment Variables:

VariableDescription
MOCKD_AI_PROVIDERDefault AI provider
MOCKD_AI_API_KEYAPI key for the provider
MOCKD_AI_MODELDefault model
MOCKD_AI_ENDPOINTCustom endpoint (for Ollama)

Examples:

Terminal window
# Generate mocks from OpenAPI spec with AI enhancement
mockd generate --ai --input openapi.yaml -o mocks.yaml
# Generate mocks from natural language description
mockd generate --ai --prompt "user management API with CRUD operations"
# Generate mocks using specific provider
mockd generate --ai --provider openai --prompt "payment processing API"
# Preview what would be generated
mockd generate --ai --prompt "blog API" --dry-run

Enhance existing mocks with AI-generated response data.

Terminal window
mockd enhance [flags]

Flags:

FlagDescription
--aiEnable AI-powered enhancement (required)
--providerAI provider (openai, anthropic, ollama)
--modelAI model to use
--admin-urlAdmin API base URL (default: http://localhost:4290)

Environment Variables:

VariableDescription
MOCKD_AI_PROVIDERDefault AI provider
MOCKD_AI_API_KEYAPI key for the provider
MOCKD_AI_MODELDefault model
MOCKD_AI_ENDPOINTCustom endpoint (for Ollama)

Examples:

Terminal window
# Enhance all mocks with AI-generated data
mockd enhance --ai
# Use specific provider
mockd enhance --ai --provider anthropic

Manage and test GraphQL endpoints.

Terminal window
mockd graphql <subcommand> [flags]

Subcommands:

  • validate - Validate a GraphQL schema file
  • query - Execute a query against a GraphQL endpoint

Validate a GraphQL schema file.

Terminal window
mockd graphql validate <schema-file>

Arguments:

ArgumentDescription
schema-filePath to the GraphQL schema file (.graphql or .gql)

Examples:

Terminal window
# Validate a schema file
mockd graphql validate schema.graphql
# Validate with full path
mockd graphql validate ./schemas/api.graphql

Execute a GraphQL query against an endpoint.

Terminal window
mockd graphql query <endpoint> <query> [flags]

Arguments:

ArgumentDescription
endpointGraphQL endpoint URL (e.g., http://localhost:4280/graphql)
queryGraphQL query string or @filename

Flags:

FlagShortDescriptionDefault
--variables-vJSON string of variables
--operation-oOperation name for multi-operation documents
--header-HAdditional headers (key:value,key2:value2)
--prettyPretty print outputtrue

Examples:

Terminal window
# Simple query
mockd graphql query http://localhost:4280/graphql "{ users { id name } }"
# Query with variables
mockd graphql query http://localhost:4280/graphql \
"query GetUser($id: ID!) { user(id: $id) { name } }" \
-v '{"id": "123"}'
# Query from file
mockd graphql query http://localhost:4280/graphql @query.graphql
# With custom headers
mockd graphql query http://localhost:4280/graphql "{ me { name } }" \
-H "Authorization:Bearer token123"

Manage chaos injection for fault testing.

Terminal window
mockd chaos <subcommand> [flags]

Subcommands:

  • enable - Enable chaos injection
  • disable - Disable chaos injection
  • status - Show current chaos configuration

Enable chaos injection on the running mock server.

Terminal window
mockd chaos enable [flags]

Flags:

FlagShortDescriptionDefault
--admin-urlAdmin API base URLhttp://localhost:4290
--latency-lAdd random latency (e.g., “10ms-100ms”)
--error-rate-eError rate (0.0-1.0)
--error-codeHTTP error code to return500
--path-pPath pattern to apply chaos to (regex)
--probabilityProbability of applying chaos1.0

Examples:

Terminal window
# Enable random latency
mockd chaos enable --latency "50ms-200ms"
# Enable error injection with 10% rate
mockd chaos enable --error-rate 0.1 --error-code 503
# Apply chaos only to specific paths
mockd chaos enable --latency "100ms-500ms" --path "/api/.*"
# Combine latency and errors
mockd chaos enable --latency "10ms-50ms" --error-rate 0.05

Disable chaos injection on the running mock server.

Terminal window
mockd chaos disable [flags]

Flags:

FlagDescriptionDefault
--admin-urlAdmin API base URLhttp://localhost:4290

Examples:

Terminal window
mockd chaos disable

Show current chaos configuration.

Terminal window
mockd chaos status [flags]

Flags:

FlagDescriptionDefault
--admin-urlAdmin API base URLhttp://localhost:4290
--jsonOutput in JSON format

Examples:

Terminal window
mockd chaos status
mockd chaos status --json