Skip to content

StreamableHttp - stateless server support #554

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

Merged
merged 34 commits into from
May 2, 2025
Merged

Conversation

ihrpr
Copy link
Contributor

@ihrpr ihrpr commented Apr 21, 2025

  • Adding support for stateless servers using StreamableHttp transport. Each request is independent and does not require initialization.
  • Adding an example of stateless server with streamable http transport.

Tested with multi-client test script in Typescript introduced in this PR
uv run mcp-simple-streamablehttp-stateless --log-level DEBUG
uv run mcp-simple-streamablehttp-stateless --json-response

Follow ups

  • Support GET SSE
  • Streamable Http Client
  • Resumability

Stacked on top of #553

Copy link
Contributor

@jerome3o-anthropic jerome3o-anthropic left a comment

Choose a reason for hiding this comment

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

One question around initialization, also tests for this would be good.

# When True, the server will wait for the client to send an initialization
# message before processing any other messages.
# False should be used for stateless servers.
require_initialization: bool = True,
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit / question] should we just spoof the initialization on these requests with capabilities that a stateless server would have (i.e. capabilities={})? that way the life cycle of the mcp server is still spec compliant - it's a bit of a pointless dance though, so I'm happy to leave it as you have it.

The code as it stands feels like this could be interpreted as initialization being optional - that's my main concern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'd probaly change the name, require_initialization sounds like we are skipping the protocol requirement on intialization

@dsp-ant
Copy link
Member

dsp-ant commented Apr 25, 2025

Can we change the module name please, to something that is pep 8 compatible, like mcp.server.http.streamable

Copy link
Contributor

@jerome3o-anthropic jerome3o-anthropic left a comment

Choose a reason for hiding this comment

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

awesome!

dsp-ant
dsp-ant previously approved these changes May 1, 2025
Base automatically changed from ihrpr/streamablehttp-server to main May 2, 2025 10:58
@ihrpr ihrpr dismissed stale reviews from dsp-ant and jerome3o-anthropic May 2, 2025 10:58

The base branch was changed.

@ihrpr ihrpr merged commit 72b66a5 into main May 2, 2025
10 checks passed
@ihrpr ihrpr deleted the ihrpr/streamablehttp-stateless branch May 2, 2025 12:40
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.

3 participants