Skip to content

mcp: support stateless connections for streamable #159

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ln-12
Copy link
Contributor

@ln-12 ln-12 commented Jul 23, 2025

When the client lost the connection to the mcp server or the mcp server runs on distributed nodes (e.g. behind a loadbalancer), it can be desired to run the server in stateless mode. When doing so, the Mcp-Session-Id should not generated or verified to allow the execution of methods without prior initialization.

Or would it be better to still generate the session id and send the Mcp-Session-Id but just not validate it?

The Rust sdk, mcp-go and the typescript sdk also support it for example. Additionally, this mode is mentioned in the typescript documentation although the official documentation does not seem to contain any information about it.

Fixes #148

When the client lost the connection to the mcp server or the mcp server runs on distributed nodes (e.g. behind a loadbalancer), it can be desired to run the server in stateless mode. When doing so, the Mcp-Session-Id should not generated or verified to allow the execution of methods without prior initialization.

Fixes modelcontextprotocol#148
# Conflicts:
#	mcp/server.go
#	mcp/streamable.go
@ln-12
Copy link
Contributor Author

ln-12 commented Jul 24, 2025

One issue I found so far is that for example sending log messages from the server to the client is not working as the session id is needed for that. So maybe it would be better to still generate and send the session id but simply not validate it like I tested on this branch.

Please let me know what you think about it.

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.

Session recovery / shared session storage for distributed MCP env
1 participant