Class McpContractTest

java.lang.Object
org.mockserver.netty.mcp.McpContractTest

public class McpContractTest extends Object
Deterministic conformance / contract tester for a target MCP (Model Context Protocol) server reachable over Streamable HTTP.

It exercises the required JSON-RPC handshake and core methods — initialize, notifications/initialized, ping, tools/list, unknown-method rejection, and optionally a single tools/call — and reports per-check conformance.

This validates only the shape of responses (the JSON-RPC 2.0 envelope and the required result fields of each method), never the semantics of any tool. No LLM and no MockServer state are involved, so the outcome is fully deterministic.

The HTTP transport is injected as a McpContractTest.JsonRpcExchange so the orchestration is unit testable without a network, mirroring org.mockserver.openapi.OpenApiContractTest.

  • Field Details

    • DEFAULT_PROTOCOL_VERSION

      public static final String DEFAULT_PROTOCOL_VERSION
      Default MCP protocol version advertised by the client when the caller supplies none. Corresponds to the 2025-03-26 MCP specification; callers can override it via the protocolVersion argument to test a server against a newer or older revision.
      See Also:
  • Constructor Details

    • McpContractTest

      public McpContractTest(com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details