Skip to content

mcp: add SSE session IDs #99

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jba
Copy link
Contributor

@jba jba commented Jul 7, 2025

ClientSessions and ServerSessions created by SSE have non-empty session IDs.

Fixes #98.

ClientSessions and ServerSessions created by SSE have non-empty
session IDs.

Fixes modelcontextprotocol#98.
@jba jba requested a review from findleyr July 7, 2025 13:54
@jba jba enabled auto-merge (squash) July 7, 2025 13:55
@@ -393,6 +394,7 @@ func (c *SSEClientTransport) Connect(ctx context.Context) (Connection, error) {
s := &sseClientConn{
sseEndpoint: c.sseEndpoint,
msgEndpoint: msgEndpoint,
sessionID: msgEndpoint.Query().Get("sessionid"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is, unfortunately, not part of the spec.
Why do we want to have session IDs for the SSE connection? In theory, there is no way for the client to actually know its session id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was requested in #98, and I obliged.
We could also say that SSE is unsupported, and drop this.

Copy link

@tylerwilliams tylerwilliams Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 I filed this bug.

The part of the spec that led me down this session ID path was this: https://modelcontextprotocol.io/docs/concepts/transports#session-management.

Maybe there's another way to approach this (setting or grabbing the header manually) that I should look into?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see SSE is deprecated https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse-deprecated so I think this is my bad and I should just be using mcp.NewStreamableHTTPHandler instead of mcp.NewSSEHandler. Sorry for the noise :(

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.

SessionID is blank / empty when read from mcp.ServerSession
3 participants