Skip to content

test(e2e): MCP is sessionless; don't expect Mcp-Session-Id - #900

Merged
lakhansamani merged 2 commits into
mainfrom
fix/e2e-mcp-sessionless
Nov 17, 2026
Merged

lakhansamani merged 2 commits into
mainfrom
fix/e2e-mcp-sessionless

Conversation

@lakhansamani

Copy link
Copy Markdown
Contributor

What failed

e2e-playground/tests/dcr.spec.ts › "a self-registered client is consented to, then reaches the MCP surface" has failed since 2.4.5: mcp-session-id is undefined after initialize. It fails identically on unmodified main (c6b0ca31, the 2.4.5 release). e2e-playground doesn't run in CI, so nothing caught it.

Cause: an intended SDK change, not a server bug

2.4.5 moved github.com/modelcontextprotocol/go-sdk from v1.6.1 to v1.8.0. Authorizer serves /mcp with StreamableHTTPOptions{Stateless: true, JSONResponse: true} on purpose (internal/mcp/server.go): no sticky sessions, so replicas scale horizontally. v1.8.0 changed what stateless mode does:

A stateless server does not read or set the Mcp-Session-Id header … This mode aligns with the sessionless direction of the MCP spec; see SEP-2567. The previous behavior … can be restored temporarily via the MCPGODEBUG compatibility parameter "allowsessionsinstateless=1" … The option will be removed in the 1.9.0 version of the SDK.

Session IDs are optional for MCP servers, so spec-conformant clients send none when none is issued. mcp.spec.ts already calls tools/list without one and passes. So no client is affected; only this test, which asserted the old SDK behaviour, broke.

Not done: restoring the old behaviour with MCPGODEBUG=allowsessionsinstateless=1. The SDK removes that option in 1.9.0, and a session ID from a stateless server means nothing anyway.

Change

dcr.spec.ts now asserts the sessionless contract instead of the SDK detail:

  • initialize returns no Mcp-Session-Id. This pins the stateless design: if one ever appears, sessions were enabled and replicas would need affinity.
  • tools/list works without a session ID.
  • After a token refresh, a request carrying a stale session ID (as a client from the 2.4.4 era might still hold) succeeds. The ID is ignored, not rejected.

The Go side already covers the stale-ID case (internal/mcp/transport_test.go sends an ID "issued-by-some-other-replica").

Release note for 2.4.6

MCP (/mcp) no longer returns Mcp-Session-Id, and DELETE /mcp returns 405 (since 2.4.5, via go-sdk v1.8.0). The MCP server has always been stateless; it now also stops issuing session IDs, per the spec's sessionless direction (SEP-2567). Spec-conformant clients need no change: session IDs are optional for servers, and a 405 on DELETE is the spec's "server does not allow clients to terminate sessions". A session ID still held from an earlier server is ignored.

Verification

e2e-playground, built from this branch: npx playwright test tests/dcr.spec.ts tests/mcp.spec.ts → 10 passed. Previously the DCR test above failed on main.

go-sdk v1.8.0 (shipped in 2.4.5) stopped issuing Mcp-Session-Id from a
stateless server, per SEP-2567. Authorizer runs /mcp stateless on purpose
(internal/mcp/server.go), and session IDs are optional for servers, so this
is not a client-facing regression: mcp.spec.ts already calls tools/list with
no session ID. dcr.spec.ts asserted the old SDK detail and has failed since
2.4.5; e2e-playground does not run in CI, so nothing caught it.

The test now asserts the sessionless contract instead: initialize returns
no session ID, tools/list works without one, and a stale ID from an older
server is ignored rather than rejected.
Adds two subtests to TestHandlerIsStateless: initialize issues no
Mcp-Session-Id, and DELETE is refused with 405 + Allow. Both fail on go-sdk
v1.6.1 and pass on v1.8.0, so the behaviour change behind the stale e2e
assertion is now caught by the Go suite, which runs in CI.
@lakhansamani
lakhansamani merged commit b6bcf6c into main Nov 17, 2026
4 checks passed
@lakhansamani
lakhansamani deleted the fix/e2e-mcp-sessionless branch November 17, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant