Repository navigation
fix(mcp): follow the spec's transport session rules #1308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lucasheriques
wants to merge
4
commits into
lucas/mcp-client-meta-session
from
lucas/mcp-session-spec-align
+404
−228
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4748852
fix(mcp): follow the spec's transport session rules
lucasheriques fae08e3
chore(mcp): drop comments that restate the code
lucasheriques f34e47e
fix(mcp): only tool calls move the connection clock; keep the manual …
lucasheriques 5c6cb5a
refactor(mcp): name the sessionless revision once and drop a redundan…
lucasheriques File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| pypi/posthog: patch | ||
| --- | ||
|
|
||
| MCP analytics sessions now follow the transport rules of the sdk-specs "Session identity" requirement: | ||
|
|
||
| - Every sessionless HTTP request gets a `$session_id` of its own. That covers a stateless server without the session middleware, and a request that sends no `Mcp-Session-Id` after another client's request did. Before, these requests shared the process session with every other caller, and an unwired stateless route reported each pod's first request as an `$mcp_initialize`. That fallback is gone, so such a server reports one session per request until the middleware is added. The runtime warning names the fix, and no longer fires for 2026-07-28 requests, which no middleware can group. | ||
| - A call's events all use the session resolved when the call arrived, so a stdio call longer than 30 minutes no longer changes session midway. | ||
| - A one-client connection's session rotates once 30 or more minutes pass between the end of one tool call and the arrival of the next. A `tools/list` or resource request no longer keeps the session alive. | ||
| - The deprecated SSE transport groups a connection's requests by its `session_id` query parameter, read only on a connection that completed a handshake. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2 · Validate the SSE transport before accepting its query session
On MCP 2.x, a stateless Streamable HTTP
initializecarrying?session_id=chosenreaches_initialize_session, wherehandshake=Trueaccepts the unvalidated query and overrides the middleware-minted token. The handshake uses a caller-chosen analytics session while later calls use the returned token, violating the session identity contract; restrict query reads to verified SSE transport sessions.