mcp-toolbox-sdk-python icon indicating copy to clipboard operation
mcp-toolbox-sdk-python copied to clipboard

feat(core): implement reference support for Stateless MCP (SEP-2575)

Open anubhav756 opened this issue 6 months ago • 1 comments

Description

This PR introduces reference client support for Stateless MCP (SEP-2575) according to conformance tests in https://github.com/modelcontextprotocol/conformance/pull/270, transitioning the SDK to a stateless-first architecture for the upcoming MCP version.

Changes

  1. Added new stateless transport (v20260618)
    • Created McpHttpTransportV20260618 which skips the monolithic initialize session handshake, keeping connections completely stateless.
    • Automatically populates the required _meta parameters (protocolVersion, clientInfo, clientCapabilities) on every request.
    • Appends the mandatory MCP-Protocol-Version HTTP header to every outgoing POST request.
  2. Added support for inline version negotiation
    • Implemented automatic version negotiation and retry loop prevention
      • intercepts server UnsupportedProtocolVersionError (-32004) responses, intersects available versions, and retries the request inline with the negotiated version.
  3. Added Pydantic models strictly mapped to the stateless draft schema.
  4. Added unit tests for the new transport.
    • Updated the client conformance harness client.py to support execution of the request-metadata scenario.

Checklist

  • [x] Unit tests pass.
  • [x] Conformance suite stateless checks pass.

anubhav756 avatar May 13 '26 14:05 anubhav756

/gcbrun

anubhav756 avatar May 23 '26 08:05 anubhav756