Skip to main content

Module mcp_mock

Module mcp_mock 

Source
Expand description

Mock MCP (Model Context Protocol) server for agent-as-MCP-client testing (#913). Mock MCP (Model Context Protocol) server (#913, #79 round 50 follow-up).

Serves a JSON-RPC 2.0 endpoint at POST /mcp so an agent acting as an MCP client (the role Cursor / Claude Code / custom agents play when they call out to tool servers) can talk to MockForge as a fake MCP server. Answers the core MCP methods with a configurable catalog and canned results: initialize, tools/list, tools/call, resources/list, resources/read, resources/templates/list, prompts/list, prompts/get, ping, plus the notifications/initialized notification.

This is a MOCK: no real tools run. tools/call returns deterministic canned content so agents can be exercised against a predictable (or, with a configured error tool, hostile) MCP server.

Round 52 (#79) — Srikanth on 0.3.198 asked whether the mock can “respond with more tools, resources, prompts so that applications are chatty (sees more client-server traffic)”. The default catalog now ships a fuller set of tools plus non-empty resources and prompts, and resources/read / prompts/get are implemented, so a client that lists then reads/gets/calls generates substantially more request/response traffic to capture.

Mounted by mockforge serve --mcp-mock.

Structs§

McpMockConfig
Runtime configuration for the mock MCP server.
McpPrompt
A single mock prompt in the catalog.
McpPromptArg
A single argument declared by a mock prompt.
McpResource
A single mock resource in the catalog.
McpTool
A single mock tool in the catalog.

Functions§

router
Build the axum router exposing the mock MCP JSON-RPC endpoint.