Skip to content

M5: dual era (2025-11-25 and 2025-06-18 next to 2026-07-28) - #6

Merged
t11z merged 4 commits into
mainfrom
claude/amazing-cerf-g66iz8
Sep 29, 2026
Merged

t11z merged 4 commits into
mainfrom
claude/amazing-cerf-g66iz8

Conversation

@t11z

@t11z t11z commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Milestone M5 Dual era (ROADMAP.md). One server process or endpoint now serves the stateless 2026-07-28 core and the initialize handshake of 2025-11-25 and 2025-06-18 side by side. 2025-03-26 is accepted as a version string. The client detects which era a server speaks and falls back to the handshake when needed.

Server

  • New-McpServer -SupportedVersions now defaults to 2026-07-28, 2025-11-25, 2025-06-18. The era follows from this list; there is no separate -Era parameter.
    • Only 2026-07-28 makes the server modern-only. It then answers initialize with -32022 and its supported versions.
    • Only legacy revisions make it legacy-only. It then answers requests before initialize with -32600.
  • The era of each request is decided in one place, Get-McpMessageEra in Era.ps1:
    • A request whose _meta carries the 2026-07-28 protocol version is modern. This includes initialize, which then gets 404 and -32601 as a removed method; the 2026-07-28 suite checks exactly that.
    • initialize without that _meta opens a legacy session.
    • Any other request belongs to the session named by its Mcp-Session-Id (HTTP) or to the process-wide session (stdio).
  • LegacySession.ps1 handles the legacy session:
    • version and capability negotiation, ping, logging/setLevel, resources/subscribe and resources/unsubscribe;
    • unsolicited list-changed and resource-updated notifications.
  • Server-initiated requests keep handlers era-agnostic:
    • Request-McpElicitation, Request-McpSampling and Request-McpRoot block in a legacy session until the answer arrives, instead of throwing to start an input round.
    • The dispatcher correlates the client's response with the waiting request.
  • Legacy results and errors are converted in one place. They carry no resultType, ttlMs, cacheScope or io.modelcontextprotocol/ keys in _meta. An unknown resource becomes -32002 via the new McpResourceNotFoundException.
  • Streamable HTTP sessions:
    • initialize returns an Mcp-Session-Id.
    • GET with that id opens the session's stream (a second GET gets 409, the stream uses Connection: close); DELETE ends the session; an unknown or expired session gets 404.
    • JSON-RPC errors inside a session are sent with status 200, because a 404 would tell the client its session is gone.
    • Start-McpServer -SessionIdleTimeoutSeconds (default 1800) and -MaxSessions (default 100, then 503) bound the sessions.
  • Request ids only need to be unique within a session. In-flight entries of legacy sessions are keyed with a session prefix, so two sessions and the stateless core can use the same id at the same time.

Client

  • Connect-McpServer -Era Auto|Modern|Legacy (default Auto) probes with server/discover:
    • a DiscoverResult or -32020/-32021/-32022 means modern;
    • anything else means legacy and triggers initialize: another error, no answer within 5 s, an HTTP error without a JSON-RPC body, or a result that is not a DiscoverResult.
    • The era of an HTTP endpoint is remembered for later connections of the same process.
  • What a legacy session does:
    • sends Mcp-Session-Id and the negotiated MCP-Protocol-Version instead of the per-request headers and _meta;
    • answers the server's elicitation, sampling, roots and ping requests with the existing callbacks, whether they arrive on stdio, on a response stream or on the GET stream;
    • opens the GET stream after initialize and reads it on the caller's thread without blocking, also while one of its own requests waits for a response;
    • starts a new session after a 404;
    • resumes a response stream that ends before its response with GET and Last-Event-ID after the announced retry time;
    • sends DELETE on disconnect.
  • New command Set-McpLogLevel, for both eras.

Conformance

  • The fixture server is a single dual-era instance for both requirement sets (-Era Dual|Modern|Legacy) and has the 2025-11-25 tools.
  • The fixture client detects the era and fills forms from schema defaults.
  • The Conformance task and the workflow now run both requirement sets.
  • Local results:
Requirement set Server leg Client leg
2026-07-28 (dual-era fixture) unchanged: every scenario passes, empty baseline unchanged
2025-11-25 30/30 scored scenarios, plus the unscored server-session-lifecycle initialize, tools_call, elicitation-sep1034-client-defaults, sse-retry
  • conformance-baseline.yml keeps only the authorization scenarios (M6). They count toward both requirement sets.

Corrections to the plan, documented in docs/implementation-plan.md §7 and ROADMAP.md:

  • The exit criterion "client 18/18" was wrong: 14 of the 18 scored client scenarios of 2025-11-25 are auth/* and belong to M6.
  • sse-retry is scored, so the client resumes interrupted streams. Server-side resumability stays out of scope; server-sse-polling is still marked pending in the suite.
  • A closed POST stream cancels the handler in both eras. Without server-side resumability the response could not be delivered anyway.
  • -32042 is not used; the blocking server-initiated request replaces it.

Known risk: the suite starts all client scenarios at once, and sse-retry allows the reconnect only +200 ms. Under heavy load it can be flaky. Locally, under the suite's concurrency, I measured 510 to 631 ms against a target of 500 ms. That is why the legacy GET stream no longer runs in a background runspace.

Checklist

  • ./build.ps1 -Task CI passes locally (Analyze, Test, Package, PublishLocal). Pester: 556 passed, 5 skipped, on PowerShell 7.4.20 / Linux. ModuleBuilder was stood in for locally because the PowerShell Gallery was not reachable from the environment; CI uses the real one.
  • New behaviour is covered by tests:
    • unit: Era.Tests.ps1, legacy status mapping, SSE id/retry;
    • integration: LegacyServer.Tests.ps1, LegacyHttp.Tests.ps1, and LegacyClient.Tests.ps1, which includes the compatibility matrix client Auto/Modern/Legacy × server modern-only/legacy-only/dual and resumption against a mock.
  • CHANGELOG.md has an entry under [Unreleased]
  • conformance-baseline.yml is unchanged in content; only its comment was updated.
  • Documentation updated: docs/concepts/dual-era.md, transports.md, conformance.md, development.md, README, about help, ROADMAP, implementation plan.

Also checked against the Inspector CLI in its default legacy mode: tools/list and tools/call work over stdio and over Streamable HTTP.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rvihdz4S9tqxJNrZGrX3qD


Generated by Claude Code

A dual-era server serves the initialize handshake of 2025-11-25 and 2025-06-18
(2025-03-26 accepted as a version string) next to the 2026-07-28 core on the
same process. New-McpServer defaults to all three revisions; the era of every
request is chosen in one place (Get-McpMessageEra) and legacy results and errors
are converted in one place (Era.ps1): no resultType, ttlMs, cacheScope or
io.modelcontextprotocol/ _meta keys, -32002 for unknown resources.

LegacySession.ps1 implements the session (version and capability negotiation,
ping, logging/setLevel, resources/subscribe and unsubscribe), unsolicited
list-changed and resource-updated notifications, and server-initiated
elicitation, sampling and roots requests: the MRTR cmdlets stay era-agnostic,
in a legacy session the worker sends the request and blocks until the
dispatcher correlates the client's response, the request is cancelled or it
times out. Requests of a session are keyed with the session's prefix.

A modern-only server answers initialize with -32022 and its versions; a
legacy-only server answers requests before initialize with -32600.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rvihdz4S9tqxJNrZGrX3qD
A server with legacy revisions speaks the Streamable HTTP of 2025-11-25 and
2025-06-18 on the same endpoint: initialize mints an Mcp-Session-Id (a UUID),
requests carrying it belong to that session and skip the header validation of
2026-07-28 (MCP-Protocol-Version is optional and must be a legacy version),
notifications are dispatched, responses to server-initiated requests are
accepted with 202, GET opens the session's stream (one per session, 409 for a
second one) for list-changed and resource-updated notifications, DELETE ends
the session, unknown or expired sessions answer 404. Errors of a session are
JSON-RPC responses with status 200 (404 would end the client's session).
Server-initiated requests go out on the SSE stream of the request that asked.

Start-McpServer -SessionIdleTimeoutSeconds (default 1800) ends idle sessions
without an open GET stream; -MaxSessions (default 100) answers further
initialize requests with 503. A modern-only server keeps answering GET and
DELETE with 405 and ignores Mcp-Session-Id. initialize with the per-request
_meta of 2026-07-28 is a modern request for a removed method (404, -32601),
as the 2026-07-28 conformance suite checks on the dual-era fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rvihdz4S9tqxJNrZGrX3qD
Connect-McpServer -Era Auto (default) probes with server/discover and falls back
to the initialize handshake when the answer is neither a DiscoverResult nor an
error only revision 2026-07-28 has (-32020, -32021, -32022), or when no answer
arrives within five seconds; -Era Modern and -Era Legacy skip the detection.
The era of an HTTP endpoint is remembered for later connections of the process.
A legacy version given with -ProtocolVersion is requested in initialize.

A legacy session sends no per-request _meta or headers of 2026-07-28 but the
Mcp-Session-Id and the negotiated MCP-Protocol-Version, answers the server's
elicitation, sampling, roots and ping requests with the existing callbacks (on
stdio, on response streams and on the GET stream), sets the log level with
logging/setLevel (new Set-McpLogLevel for both eras), maps subscriptions to
unsolicited notifications and resources/subscribe with a GET stream reader over
HTTP, initializes a new session after HTTP 404, resumes a response stream that
ends before its response with GET and Last-Event-ID after the announced retry
time, and sends DELETE on disconnect. 2025-03-26 is accepted from servers.

Tests cover the compatibility matrix of client and server eras in memory, the
legacy session over stdio, HTTP and in memory, and resumption against a mock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rvihdz4S9tqxJNrZGrX3qD
The fixture server is one dual-era instance for both requirement sets (-Era
Dual|Modern|Legacy) with the tools and the resource of the 2025-11-25
scenarios; the fixture client detects the era and fills forms from schema
defaults. The Conformance task and workflow run 2026-07-28 and 2025-11-25:
all scored server scenarios of both sets pass; on the client side
initialize, tools_call, elicitation-sep1034-client-defaults and sse-retry
pass, and the baseline still holds only the authorization scenarios (M6).

Legacy HTTP clients open the session's GET stream after initialize, as the
TypeScript SDK does, because servers send requests that belong to no client
request there; the stream is read without blocking on the caller's thread,
also while a request waits for its response, instead of in a background
runspace (whose module import competed with the timing of sse-retry).
Resumption prepares the GET before the announced retry time and sends it then.
GET streams use Connection: close on both sides: the managed HttpListener
reset the connection of a stream that ended while the client still read it
when the next request reused it.

Docs: dual-era concept, transports, conformance state after M5, development,
README, about help, ROADMAP (M5 done, exit criterion: server 30/30, client
4/4 outside authorization) and the implementation plan with the corrections
and deviations of M5; CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rvihdz4S9tqxJNrZGrX3qD

t11z commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

CI on 243fd4f: Test (windows-latest, pwsh 7.6.6) failed. All other checks passed, including both conformance requirement sets and the other 8 cells of the test matrix.

The one failing test is HttpServer.Tests.ps1 › stops the handler when the client closes the connection on timeout: its marker file did not appear within 8 s.

This does not look caused by this PR:

  • Seen on main before. The same test already failed on main in CI run 10 (merge of M1 + M2: protocol core, stdio, tools, Streamable HTTP and the conformance suite #3, Windows / pwsh 7.5.11).
  • Only this Windows cell failed. It passed on Windows 7.4 and 7.5 in this run, and on Linux and macOS.
  • Code path unchanged. The PR does not touch the disconnect detection for modern requests: the keep-alive write in Update-McpHttpChannel and the stop in Stop-McpHttpChannelRequest behave as before.

Likely cause: http.sys buffers the keep-alive chunks, so a write to a client that has already gone does not fail reliably within the test window. No fix exists yet.

Next steps:

  • I am re-running the failed jobs once.
  • If the test fails again, I will push a hardening of the disconnect detection on Windows in this PR instead of relaxing the test.

Generated by Claude Code

@t11z t11z self-assigned this Sep 29, 2026
@t11z t11z added the enhancement Type: new feature or request label Sep 29, 2026
@t11z
t11z merged commit 0f77f81 into main Sep 29, 2026
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Type: new feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants