mock_endpoint
Mock a single HTTP endpoint without writing an OpenAPI spec. Provide the method, exact path, and response body to start a local mock server and return the requested response.
Instructions
Quickly mock a single HTTP endpoint without writing an OpenAPI spec. Pass method (default GET), path (the EXACT HTTP path the user described, including all segments), and the response body (object → JSON, string → text). The bridge writes the response into a managed static dir at ~/.cache/mockzilla-mcp/mocks/ and (re)starts a single shared mockzilla server pointing at it.
Pass path AS IS. Do NOT prepend or duplicate any segment. The bridge derives the service name from the first segment for internal grouping, but it does not change the URL the user hits. Examples:
• User says GET /pets/{id} → call mock_endpoint with path=/pets/{id} → URL is http://HOST:PORT/pets/{id}
• User says POST /orders → path=/orders → URL is http://HOST:PORT/orders
• User says GET /v1/users/me → path=/v1/users/me → URL is http://HOST:PORT/v1/users/me
Pass status and/or headers to mock a failure or a redirect with a real body: status: 404 with an error payload, 201 with a Location, 429 with Retry-After. Omit response to send no body at all, which 204 and 304 require. These need mockzilla 2.8.20 or newer; the tool says so if the installed CLI is older. To fail a share of requests instead of every one, use serve_locally with errors.
Path placeholders like {id} are stored as literal directory names — by default ALL placeholder values share the same response. To return different responses for specific values, call mock_endpoint again with a literal value (e.g. /pets/123).
Calling this multiple times accumulates endpoints in the same server — adding POST /pets after GET /pets/{id} keeps both. Mutually exclusive with serve_locally: stop any ad-hoc server first. See mockzilla_docs_search('static directory') for the underlying convention.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path beginning with /. First segment is the service name. | |
| method | No | GET | |
| status | No | Response status. Omit `response` alongside it for a body-less response, which is what 204 and 304 need. | |
| headers | No | Extra response headers, e.g. {"Location": "/orders/42"}. A Content-Type here wins over `content_type`. | |
| response | No | Response body. Object → JSON. String → text. Default {}. | |
| content_type | No | Override content type. Inferred from response type if omitted (object → application/json, string → text/plain). |