~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

MCP: legacy clients too, 2025-11-25 and 2025-06-18, beside 2026-07-28

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/monolith:mcp/legacy

/mcp now serves MCP clients that open with initialize, as most clients still do (2025-11-25 and 2025-06-18), beside the stateless 2026-07-28 it already spoke. Until now such a client got "Unsupported protocol version" and could not connect at all.

Claude Opus 5.5 · high

What changes

Spec.

  • spec/mcp/legacy/2025-11-25/ and 2025-06-18/ vendor the pages a legacy endpoint rests on, from modelcontextprotocol/modelcontextprotocol: lifecycle, transports, basic, ping, tools, changelog and schema.json.
  • spec/COMMANDS.md's "The MCP endpoint" makes the endpoint dual-era, as mcp/basic/versioning.md allows:
    • A request with _meta's version is modern, as before.
    • initialize answers the version asked if served, else 2025-11-25, with the tools capability and the same identity and instructions as server/discover. No session.
    • Later requests name their revision in MCP-Protocol-Version and get ping, tools/list and tools/call in that revision's shape. Notifications are 202; other methods are -32601.
    • No 2025-03-26: a request with no version anywhere is refused -32020.
    • GET and DELETE are 405. supportedVersions and UnsupportedProtocolVersionError.supported name all three.

Harness.

  • lib/via.mjs: every --commands tool call goes in a random era, and each message is validated against its revision's schema. 2025-06-18's is draft-07, so it gets an Ajv of its own.

  • checks/commands.mjs, for each legacy revision:

    • initialize with and without the header must give that version, the tools capability, the identity and instructions, and no MCP-Session-Id;
    • notifications/initialized must be 202 with no body, and ping must be {};
    • tools/list must give the modern era's tools exactly;
    • an unknown tool must be -32602, and server/discover must be -32601.

    For both eras: no version must be -32020; 2025-03-26 must be -32022 with the three versions; initialize for 2025-03-26 or 1999-01-01 must give 2025-11-25; GET and DELETE must be 405.

  • conformance.mjs also runs the suite's legacy scenarios at 2025-11-25: server-initialize, server-session-lifecycle, ping, tools-list and dns-rebinding-protection. conformance.yaml lists the one modern check that no longer applies: sep-2575-http-server-method-not-found-404-initialize, whose own text holds only a server that does not implement initialize.

  • runCli clears PDS_ADMIN_PASSWORD as it does PDS_TOKEN. A shell that had one set made --commands fail with 401s.

Server. In mcp.rs, request picks the era:

  • initialize answers the handshake.
  • legacy serves the post-handshake methods statelessly, with no session state.
  • modern is the old path, its supported lists now naming three versions.

call_tool answers (content, is_error), which each era wraps in its own result shape.

Why

The endpoint was usable only from clients already on 2026-07-28, and a smoke test against just dev showed the 2025 handshake refused. A dual-era endpoint is what the MCP spec prescribes for this. Stateless legacy, with no session ids, keeps the server holding nothing per client and keeps any instance able to answer any request.

How it was checked

  • Before the server change, the checks fail: server/discover's supportedVersions, and the suite's server-initialize, server-session-lifecycle and ping.
  • Planted bug: initialize answering 2025-11-25 whatever was asked. --commands fails at MCP initialize (2025-06-18). The suite's scenarios, which ask for 2025-11-25, pass, which is why the harness's own check is there. Put back.
  • With the change:
    • compare.mjs --steps 400 --seed 31 --commands agrees, with tool calls in all three eras;
    • conformance.mjs passes all 10 scenarios;
    • cargo test -p pds-server mcp:: passes, and clippy is clean;
    • just quick passes here.
  • The MCP TypeScript SDK's own client (1.32.2), as a black box, connects to just dev, lists the tools, calls them with a token and pings.
  • just gates is left to the pull's gates workflow.

Shortcomings

  • No 2025-03-26 clients: they send no version header, and that revision requires accepting JSON-RPC batches.
  • No session ids, no standalone SSE stream, no resumability. A client that insists on a session gets none, which the legacy transport allows.
Approved

This makes /mcp serve legacy clients (2025-11-25 and 2025-06-18) statelessly, beside 2026-07-28. initialize answers the handshake with no session. legacy serves ping, tools/list and tools/call. modern is the old path.

  • Spec: spec/COMMANDS.md states the dual-era behaviour and its checks, and the vendored legacy pages are in place. The README describes what is built, not how it came to be built.
  • Server: the code follows the spec: the handshake, the 202 for notifications, -32601 for other methods, and the three versions in supportedVersions and supported. mcp.rs adds no crates.
  • Harness: the new checks are strict. They compare against the spec where the reference can't say. The schemas are per revision, with draft-07 handled for 2025-06-18, and tool calls go in a random era drawn from the seeded random.mjs. Nothing is loosened.
  • conformance.yaml: the one excused check, sep-2575-http-server-method-not-found-404-initialize, gives a reason that matches what that check tests.

I read every changed file except the vendored spec/mcp/legacy/** pages and schemas. I only confirmed they are added as spec material, since they are copies of upstream.

I did not run the code.

Merged as 359c699