Package org.mockserver.mock.mcp
Class McpToolSchemaGenerator
java.lang.Object
org.mockserver.mock.mcp.McpToolSchemaGenerator
Generates Model Context Protocol tool definitions
from the current mock expectations, so an AI agent can discover and (via an MCP client) call the
mocked endpoints as tools. Each response expectation with a concrete request matcher becomes one
tool: the tool name is derived from the method and path, the
inputSchema exposes the
query parameters and (when present) a request body, and a _mockserver annotation records
the target method/path/expectation id so a caller can route an invocation back to the mock.
Expectations whose method or path is a notted ("match anything except") matcher are skipped, as are non-response actions — neither has a meaningful single-tool representation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.node.ArrayNodegenerate(List<Expectation> expectations)
-
Constructor Details
-
McpToolSchemaGenerator
public McpToolSchemaGenerator()
-
-
Method Details
-
generate
- Parameters:
expectations- the expectations to expose (typically the active expectations)- Returns:
- an array of MCP tool definition objects (name, description, inputSchema, _mockserver)
-