Skip to content

Streamable HTTP support #361

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 12 commits into from
May 8, 2025
Merged

Streamable HTTP support #361

merged 12 commits into from
May 8, 2025

Conversation

jlowin
Copy link
Owner

@jlowin jlowin commented May 7, 2025

This implementation is based on changes introduced to the low-level server in modelcontextprotocol/python-sdk#641, and requires the new objects introduced there. However we need to do more work to abstract out auth and routes to avoid polluting the FastMCP object further, as it is at risk of becoming as configuration-heavy as the low-level server. Since Streamable HTTP is so popular, it's ok to merge this and risk some breaking changes in auth (which can be made backwards compatible via deprecation) in order to get to a more sane configuration setup.

Vendors the changes in # 641 until merged.

@jlowin jlowin mentioned this pull request May 7, 2025
@Akshit97
Copy link

Akshit97 commented May 7, 2025

Nice work @jlowin, I was thinking of implementing this today :)

@jlowin jlowin marked this pull request as ready for review May 8, 2025 00:57
@Copilot Copilot AI review requested due to automatic review settings May 8, 2025 00:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds Streamable HTTP support to the FastMCP server while introducing new settings, transports, and session management routines as well as updating associated tests. Key changes include:

  • Introducing and integrating the streamable-http transport in server and client modules.
  • Adding new settings (streamable_http_path, json_response, stateless_http) and a session manager (StreamableHTTPSessionManager).
  • Updating tests to reflect new module imports and transport support.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/server/test_lifespan.py Updates import paths to use the new fastmcp module structure.
tests/client/test_streamable_http.py Adds tests for ping and header validation using streamable-http.
src/fastmcp/settings.py Adds new settings for streamable HTTP support.
src/fastmcp/server/streamable_http_manager.py Introduces session management for Streamable HTTP.
src/fastmcp/server/server.py Updates transport methods to include “streamable-http”.
src/fastmcp/server/http.py Implements creation of the streamable-http app and middleware changes.
src/fastmcp/client/transports.py Adjusts transport inference to support the “streamable-http” transport.
Comments suppressed due to low confidence (1)

tests/server/test_lifespan.py:21

  • The import change reflects the updated module structure. Please verify that all related test code references now align with the new import path to avoid any linkage issues.
from fastmcp import Context, FastMCP

@jlowin jlowin merged commit 61a1f33 into main May 8, 2025
5 checks passed
@jlowin jlowin deleted the streamable-http branch May 8, 2025 02:30
jordicore pushed a commit to jordicore/fastmcp that referenced this pull request Jul 2, 2025
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.

2 participants