API and code · Mock server docs
Editing mock settings with MCP
The mock server is part of every plan except Time only. Request access · See the plans
There is no web screen for the mock settings yet: your AI agent (any AI app connected to Spectrail's MCP server)
edits them in bulk. Connect it at https://api.spectrail.app/mcp (writes) — /mcp/readonly can read but not save.
The agent acts as the person who connected it, with that person's rights, and the company must let agents write.
| Tool | What |
|---|---|
get_endpoint | One endpoint with its mock block and current rev. |
list_endpoints | The project's endpoints. |
save_endpoint | Save one endpoint (owners and admins). Send a patch on /mock or the whole endpoint. |
propose_endpoint_change | The same as a proposal on a ticket (members; or when the team reviews changes). |
bulk_save_endpoints | Up to 20 endpoints in one call (counts as one change). |
get_mock_config | The project mock config {config, rev, updatedAt}. |
save_mock_config | Save the WHOLE config (owners and admins), with the rev you read. |
The mock key is not in MCP: copy the Base address from the Endpoints page (Mock server).
Every save is a revision
A mock change is saved like any endpoint change: it needs a note, bumps rev, a stale rev is refused (read
again, then retry), and a member's change becomes a proposal. A revision that changes only mock is marked mock-only
and stays out of the contract signals. The save checks the block against the endpoint (statuses, documented fields).
Add a block (patch)
{
"org": "acme",
"project": "app",
"id": "cash-confirm",
"rev": 4,
"note": "Mock: token-only confirm",
"patch": [
{ "op": "add", "path": "/mock", "value": { "confirm": { "refField": "token" }, "presets": [{ "status": 200, "body": { "status": true } }] } }
]
}
Change one part (patch)
{
"org": "acme",
"project": "app",
"id": "cash-deactivate",
"rev": 5,
"note": "Mock: refused message",
"patch": [
{ "op": "test", "path": "/mock/presets/0/final", "value": true },
{ "op": "replace", "path": "/mock/presets/0/body/message", "value": "The account is not active." },
{ "op": "add", "path": "/mock/sets/-", "value": { "key": "hasOpenDepot", "value": false } }
]
}
Patch ops: add, replace, remove, test (JSON Patch). /- appends to a list. A failed test or a bad path
refuses the whole save and names the op. Remove the whole block with {"op": "remove", "path": "/mock"}.
Many endpoints at once
{
"org": "acme",
"project": "app",
"items": [
{ "id": "auth-login", "rev": 2, "note": "Mock login", "patch": [{ "op": "add", "path": "/mock", "value": { "login": true } }] },
{ "id": "auth-logout", "rev": 1, "note": "Mock logout", "patch": [{ "op": "add", "path": "/mock", "value": { "sets": [{ "op": "logout" }] } }] }
]
}
Answer {saved, proposed, unchanged, refused}: each item has its own rev; a refused item does not stop the others.
The project config
{
"org": "acme",
"project": "app",
"rev": 0,
"config": {
"login": { "usernameField": "username", "passwordField": "password", "users": [{ "username": "sam.tester@example.com", "password": "Test-pass-1" }] },
"unauthorized": { "status": 401, "body": { "detail": "Invalid token." } },
"confirmCodes": ["123456"]
}
}
save_mock_config replaces the whole config: read it with get_mock_config, change it, send it back with that
rev (0 when none is saved). A refusal {error: "invalid", fields: [{path, message}]} names every wrong field.
Scenario presets name endpoints by id and must use their documented statuses.
Limits
One save_endpoint, propose_endpoint_change or bulk_save_endpoints call may be up to 512 KB; one
save_mock_config call up to the config's 512 KB plus a little. A mock block is ≤ 128 KB.