Skip to content

fix: Drive Starlette lifespan ourselves for SSE transport too#94

Merged
GoodbyePlanet merged 1 commit into
mainfrom
fix/sse-transport-lifespan
Jul 15, 2026
Merged

fix: Drive Starlette lifespan ourselves for SSE transport too#94
GoodbyePlanet merged 1 commit into
mainfrom
fix/sse-transport-lifespan

Conversation

@GoodbyePlanet

Copy link
Copy Markdown
Owner

Summary

  • SSE transport relied on FastMCP's own per-session lifespan, re-initializing the Qdrant store/embedding provider on every client connect/disconnect and racing the global store singletons
  • Applies the same fix already used for streamable-http: build the app via mcp.sse_app() and wrap its lifespan ourselves so init/teardown happens once per process, not per session
  • Documents SSE in the README as the deprecated legacy MCP transport, pointing users at streamable-http for new setups

Fixes #93

Test plan

  • uv run pytest — 265 passed
  • Verified via a real mcp SDK sse_client/ClientSession: connected twice (connect → list_tools → disconnect, reconnect → list_tools → disconnect) against the fixed server — Starting semcode MCP server... logged exactly once across both connections
  • Reproduced the pre-fix code path for contrast — same two-connection script logged the startup/shutdown lines once per connect (4 total), confirming the bug and the fix

🤖 Generated with Claude Code

FastMCP's per-session lifespan re-initialized the Qdrant store and
embedding provider on every SSE client connect/disconnect, racing the
global store singletons. Apply the same fix already used for
streamable-http: build the app via mcp.sse_app() and wrap its lifespan
manually. Also documents SSE as the deprecated legacy transport in the
README.

Fixes #93

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@GoodbyePlanet GoodbyePlanet merged commit 0c6f129 into main Jul 15, 2026
2 checks passed
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.

SSE transport re-initializes Qdrant store/embedding provider on every client connect

1 participant