Skip to content

Fix on streamable‑http auth drop on Azure #1110

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

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/mcp/server/fastmcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ async def sse_endpoint(request: Request) -> Response:
def streamable_http_app(self) -> Starlette:
"""Return an instance of the StreamableHTTP server app."""
from starlette.middleware import Middleware
from starlette.routing import Mount
from starlette.routing import Route

# Create session manager on first call (lazy initialization)
if self._session_manager is None:
Expand All @@ -845,7 +845,7 @@ async def handle_streamable_http(scope: Scope, receive: Receive, send: Send) ->
await self.session_manager.handle_request(scope, receive, send)

# Create routes
routes: list[Route | Mount] = []
routes: list[Route] = []
middleware: list[Middleware] = []
required_scopes = []

Expand Down Expand Up @@ -889,17 +889,19 @@ async def handle_streamable_http(scope: Scope, receive: Receive, send: Send) ->
)

routes.append(
Mount(
Route(
self.settings.streamable_http_path,
app=RequireAuthMiddleware(handle_streamable_http, required_scopes, resource_metadata_url),
endpoint=RequireAuthMiddleware(handle_streamable_http, required_scopes, resource_metadata_url),
methods=["POST", "GET", "DELETE"],
)
)
else:
# Auth is disabled, no wrapper needed
routes.append(
Mount(
Route(
self.settings.streamable_http_path,
app=handle_streamable_http,
endpoint=handle_streamable_http,
methods=["POST", "GET", "DELETE"],
)
)

Expand Down
Loading