Spec0docs
Mock serverHow-to

MCP Integration

The mock server exposes a built-in **MCP (Model Context Protocol) server**, letting AI assistants like Claude and Cursor manage your mock server directly — creating variants, inspecting logs, changing

The mock server exposes a built-in MCP (Model Context Protocol) server, letting AI assistants like Claude and Cursor manage your mock server directly — creating variants, inspecting logs, changing strategies, and more — without leaving the conversation.

Contents


Enabling MCP

MCP is disabled by default and enabled per mock server.

From the UI: Go to the Settings tab → toggle Enable MCP.

From the API:

curl -X PATCH http://localhost:8080/mock-server/servers/{mockServerId}/mcp-config \
  -H 'Content-Type: application/json' \
  -d '{"mcpEnabled": true}'

Once enabled, the SSE endpoint is available at:

http://localhost:8080/mcp/sse

[!NOTE] The SSE endpoint does not require authentication. If you run the mock server on a non-default port, update the URL accordingly.


Connecting an AI assistant

Add the server to your AI assistant's MCP config, then restart the client.

Claude Desktop

Config file location:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "spec0-mock-server": {
      "url": "http://localhost:8080/mcp/sse"
    }
  }
}

Restart Claude Desktop. The mock server tools will appear in the tool picker.

Cursor

Create or edit .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "spec0-mock-server": {
      "url": "http://localhost:8080/mcp/sse"
    }
  }
}

Restart Cursor. The tools are available in AI chat and Composer.

Claude Code CLI

Add to your project's CLAUDE.md or to ~/.claude/CLAUDE.md:

{
  "mcpServers": {
    "spec0-mock-server": {
      "url": "http://localhost:8080/mcp/sse"
    }
  }
}

Or pass it at startup:

claude --mcp-server spec0-mock-server=http://localhost:8080/mcp/sse

Available tools

ToolDescription
list_mock_serversList all mock servers with their IDs, names, and base URLs
list_operationsList operations from the OpenAPI spec for a given server
list_variantsList response variants, optionally filtered by operationId
create_variantCreate a static response variant (name, status code, body, default flag)
create_cel_variantCreate a CEL-evaluated dynamic variant (supports natural language description)
delete_variantDelete a variant by ID
set_strategySet the response selection strategy (RANDOM, DEFAULT_ONLY, SEQUENTIAL, ROUND_ROBIN)
get_logsRetrieve recent request logs (default 20, max 200)
reset_to_defaultsDelete all user-created variants and reset the strategy to RANDOM

Example prompts

Once the MCP server is connected, you can ask your AI assistant in plain language:

Exploring your servers

"List all mock servers and show me the operations for the Users service."

Creating variants

"Create a variant for getUser that returns a 404 with {"error": "user not found"} when the user ID is 99."

"Create a CEL variant for createOrder that generates a random UUID for the order ID and includes the current timestamp."

Controlling strategy

"Set the strategy for this mock server to SEQUENTIAL so my tests get predictable responses."

Debugging

"Show me the last 10 request logs for this mock server."

Resetting state

"Reset all variants on the Payments mock server back to defaults."


See also

On this page