Class HttpMcpClient

java.lang.Object
com.cockroachlabs.data.continuum.mcp.HttpMcpClient
All Implemented Interfaces:
McpClient

public class HttpMcpClient extends Object implements McpClient
HTTP-backed McpClient speaking the MCP Streamable HTTP transport (spec 2025-06-18). Lazily performs the initialize handshake before the first tools call, echoes the server-assigned Mcp-Session-Id and the MCP-Protocol-Version header, and handles both application/json and text/event-stream responses.

To stay independent of the host application's HTTP message converters and Jackson version, responses are retrieved as text and parsed with Spring Boot's JsonParser, and request bodies are written as compact JSON strings. Construct with create(String, String) in production, or pass a pre-built RestClient (e.g. bound to a MockRestServiceServer) in tests.

  • Field Details

    • PROTOCOL_VERSION

      public static final String PROTOCOL_VERSION
      The MCP revision this client negotiates.
      See Also:
  • Constructor Details

    • HttpMcpClient

      public HttpMcpClient(org.springframework.web.client.RestClient rest)
    • HttpMcpClient

      public HttpMcpClient(org.springframework.web.client.RestClient rest, String clientName, String clientVersion)
  • Method Details