Mock Server
recon mock turns responses you already recorded into a local HTTP server on 127.0.0.1. Use it to work offline, to give a frontend a stable backend, or to test how a client handles slow or failing responses.
Quick start
Section titled “Quick start”Record some traffic first (any command that writes to the Flight Recorder works), then export a mock pack and serve it:
recon send "List Students"recon send "Create Enrollment"recon mock --airlock --export-pack mocks/demo.recon-mock.json✓ Exported 2 frozen route(s) (airlock=true) to mocks/demo.recon-mock.jsonrecon mock --pack mocks/demo.recon-mock.json --port 4501http://127.0.0.1:4501Freeze-to-Mock listening on http://127.0.0.1:4501 (2 routes, airlock=false)The first line (the URL) goes to stdout. The second line goes to stderr. The server runs until you press Ctrl-C, then exits with code 0. It prints no statistics on exit.
curl -si 'http://127.0.0.1:4501/_sandbox/local/v1/students?page=2'HTTP/1.1 200 OKcontent-type: application/jsondate: Mon, 30 Nov 2026 15:45:04 GMTx-recon-mock: truex-recon-airlock: zero-piicontent-length: 830...The date header is the one captured with the original response. Frozen headers are replayed as they were recorded.
Where responses come from
Section titled “Where responses come from”The server always serves a mock pack: a list of frozen (method, path) entries. The pack comes from one of two places.
| Source | When | What happens |
|---|---|---|
| Flight Recorder (default) | --pack is not given |
Recon opens the workspace flight_db and builds a pack from the 500 most recent runs. |
| Pack file | --pack <FILE> |
Recon loads the JSON file as is. |
When building from the Flight Recorder:
- Each run is keyed by its uppercase method and its normalized URL path. The scheme, host, port, query string and fragment are dropped. So
http://127.0.0.1:4500/_sandbox/local/v1/students?x=1becomesGET /_sandbox/local/v1/students. Runs against different hosts with the same method and path collapse into one entry. - For each key, a pinned baseline run beats a non-baseline run. Between two runs of the same kind, the newer one wins.
- Only runs among the 500 most recent are considered.
- Response headers are filtered (see Header handling).
- With
--airlock, each entry’s headers and body pass through the PII Airlock before they enter the pack, and the entry is markedairlocked: true.
Request matching
Section titled “Request matching”For every incoming request, the server normalizes the request path (query string removed, empty segments removed) and then:
- Looks for an entry with the same method (case-insensitive) and exactly the same normalized path.
- If none, looks for the first entry with the same method whose path matches segment by segment, where a
{name}segment in the entry matches any single segment in the request. Both paths must have the same number of segments.
The query string, headers and body of the request are never used for matching.
Paths recorded from real traffic contain literal values, so wildcard matching only applies when a pack entry contains {param} segments. You can add such entries by editing a pack file. For example, an entry with "path": "/v1/users/{id}" answers GET /v1/users/1, GET /v1/users/77, and so on.
No match
Section titled “No match”A request that matches no entry gets a 404:
curl -si -X DELETE http://127.0.0.1:4501/nope/123HTTP/1.1 404 Not Foundcontent-type: application/jsonx-recon-mock: truecontent-length: 75date: Mon, 30 Nov 2026 15:45:16 GMT
{"error":"recon_mock_route_not_found","method":"DELETE","path":"/nope/123"}Chaos injection
Section titled “Chaos injection”Chaos settings apply to every request the server receives, including requests that would match nothing.
| Flag | Default | Effect |
|---|---|---|
--latency-ms <MS> |
0 |
Fixed delay added before every response. |
--jitter-ms <MS> |
0 |
Extra delay between 0 and this value (inclusive), added on top of --latency-ms. |
--error-rate <P> |
0 |
Probability in 0.0..=1.0 that a request gets a fault response instead of its frozen response. 1.0 faults every request. |
--error-status <CODE> |
503 |
HTTP status of fault responses. Must be 100..=599 when --error-rate is above 0. |
The order is: delay first, then the fault decision, then route matching. A fault response looks like this:
HTTP/1.1 429 Too Many Requestscontent-type: application/jsonx-recon-mock: truex-recon-chaos: injectedcontent-length: 53
{"error":"recon_chaos_injected","seq":8,"status":429}seq is the request’s 0-based sequence number since the server started. Jitter and fault decisions come from a fixed pseudo-random function of this sequence number, not from a random seed. A server started with the same settings produces the same pattern of delays and faults for the same request order.
This example serves a copy of the pack with one hand-added entry whose path is /v1/users/{id}:
recon mock --pack mocks/edited.recon-mock.json --port 4501 \ --latency-ms 20 --jitter-ms 10 --error-rate 0.5 --error-status 429for i in 1 2 3 4 5 6; do curl -s -o /dev/null -w "%{http_code} %{time_total}\n" http://127.0.0.1:4501/v1/users/$idone429 0.030715200 0.027584200 0.027796429 0.031575429 0.030761429 0.022438Header handling
Section titled “Header handling”These headers are removed from frozen responses, both when a pack is built from the Flight Recorder and when a response is served: connection, keep-alive, proxy-authenticate, proxy-authorization, te, trailers, transfer-encoding, upgrade, content-length, content-encoding. The server computes its own content-length.
Headers that Recon adds:
| Header | When |
|---|---|
X-Recon-Mock: true |
Every response, including 404s and faults. |
X-Recon-Airlock: zero-pii |
Matched responses, when --airlock is set or the entry has airlocked: true. |
X-Recon-Chaos: injected |
Fault responses. |
Exporting a pack
Section titled “Exporting a pack”--export-pack <FILE> writes the pack as pretty-printed JSON. Parent directories are created. Without --serve, Recon then exits with code 0 and does not start a server. With --format json (or agent), the pack JSON is also printed to stdout instead of the summary line. Add --serve to write the file and then start the server.
You can combine --pack and --export-pack to copy a pack file.
Pack format
Section titled “Pack format”{ "schema_version": "recon.mock/v1", "workspace_name": "recon-demo", "created_at": "2026-11-30T15:45:09.240690988+00:00", "airlocked": true, "entries": [ { "method": "POST", "path": "/_sandbox/local/v1/enrollments", "status": 201, "headers": [ { "name": "content-type", "value": "application/json" }, { "name": "date", "value": "Mon, 30 Nov 2026 15:45:04 GMT" } ], "body": "{\n \"course\": \"CS-401\",\n \"id\": \"enr_2026_091\",\n \"status\": \"enrolled\",\n \"student_id\": \"007218\",\n \"timestamp\": \"2026-11-30T15:45:04.422656396+00:00\"\n}", "airlocked": true, "source_run_id": "01a22d21-91ac-7409-aaa9-20fe689a7b08", "is_baseline": false } ]}Top-level fields:
| Field | Type | Meaning |
|---|---|---|
schema_version |
string | Always recon.mock/v1 for packs Recon writes. Not checked when loading. |
workspace_name |
string | name from .recon.toml. |
created_at |
string | RFC 3339 timestamp. |
airlocked |
bool | true if the pack was built with --airlock. |
entries |
array | Frozen routes, ordered by method and then path. |
Entry fields:
| Field | Type | Meaning |
|---|---|---|
method |
string | Uppercase HTTP method. |
path |
string | Normalized path. May contain {name} segments for wildcard matching. |
status |
integer | Response status code. |
headers |
array of {name, value} |
Response headers. |
body |
string | Response body text. |
airlocked |
bool | Headers and body already passed through the Airlock. |
source_run_id |
string | Flight Recorder run ID the entry came from. |
is_baseline |
bool | The source run was a pinned baseline. |
Every field is required when Recon loads a pack. A hand-written entry that leaves one out makes the load fail with serialization error.
| Flag | Default | Description |
|---|---|---|
--port <PORT> |
4010 |
Port on 127.0.0.1. 0 picks a free port. |
--airlock |
off | Scrub entries through the PII Airlock when building from the Flight Recorder. Adds X-Recon-Airlock to matched responses. |
--latency-ms <MS> |
0 |
Fixed delay per response. |
--jitter-ms <MS> |
0 |
Maximum extra random delay. |
--error-rate <P> |
0 |
Fault probability, 0.0..=1.0. |
--error-status <CODE> |
503 |
Fault status code. |
--pack <FILE> |
none | Serve this pack file instead of building one from the Flight Recorder. |
--export-pack <FILE> |
none | Write the pack to this file, then exit unless --serve is set. |
--serve |
off | Start the server even when --export-pack is set. |
The global --workspace, --format and --salt flags apply. --salt sets the masking salt used by --airlock. The global transport flags (--proxy, --ca-cert, -k and so on) are accepted but have no effect, because the mock server makes no outbound requests. See the CLI Reference for global flags.
Errors and exit codes
Section titled “Errors and exit codes”All errors print an E_CLI_RUNTIME envelope and exit with code 2.
| Cause | Message |
|---|---|
--error-rate outside 0.0..=1.0 |
invalid proxy configuration: chaos error_rate 1.5 must be in 0.0..=1.0 |
--error-status outside 100..=599 with a non-zero rate |
invalid proxy configuration: chaos error_status 700 must be a valid HTTP status |
--pack file missing |
io error at `nope.json`: No such file or directory (os error 2) |
| Pack file is not valid pack JSON | serialization error: ... |
| Port already in use | failed to bind proxy listener ... |
Also available via
Section titled “Also available via”- Web Studio: the Studio button in the top bar opens the “Freeze-to-Mock & Shadow Studio” dialog. The Freeze-to-Mock tab has an Airlock checkbox (on by default), Latency, Jitter, Fault Rate and Fault HTTP fields, Start/Stop buttons, an “Export .recon-mock.json” button (downloads
recon-mock-pack.json), and counters for Routes, Served, Faults and 404 Misses. It always builds the pack from the Flight Recorder and binds an ephemeral port. See Web Studio. - HTTP API:
GET /api/v1/mock/status,POST /api/v1/mock/start(body{port?, airlock, chaos};airlockdefaults totrue,portto0),POST /api/v1/mock/stop,POST /api/v1/mock/export(body{airlock}, defaulttrue). Starting a new mock stops the previous one. See HTTP API. - MCP:
recon_mock_exportreturns a pack built from the Flight Recorder with the Airlock always on. It takes no arguments and does not start a server. See MCP Tools.