Streamable HTTP Sessions, SSE, and Internal ASGI Dispatch Pipeline JSON-RPC requests and GET /mcp SSE streams (Accept: text/event-stream) arrive at MCPController (/mcp), negotiate stateless 2026-07-28 (server/discover, POST subscriptions/listen) or stateful 2025-11-25, 2025-06-18, and 2025-03-26 (initialize, Mcp-Session-Id via MCPSessionStore, resources/subscribe, RFC 5424 logging/setLevel, DELETE /mcp), and execute handlers through internal ASGI dispatch with MCPRequestContext.log() and SubscriptionManager. MCP Client POST • GET /mcp • DELETE /mcp 2026-07-28: server/discover POST subscriptions/listen SSE 2025-*: initialize + Mcp-Session-Id GET /mcp (Accept: text/event-stream) resources/subscribe • logging/setLevel logLevel _meta & SEP-2575 headers MCPController MCPHandlerService Router Guards, auth & Origin check MCPSessionStore (Mcp-Session-Id TTL) RFC 5424 logging/setLevel state GET /mcp SSE stream & 405 toggle 202 Accepted • 204 DELETE /mcp 2026-07-28 • 2025-11-25 • 2025-06-18 Internal ASGI Dispatch execute_tool / prompt / res Forwards Auth & Trace Headers Preserves request.user & auth Binds session_id & log_level threshold MCPRequestContext.log() & progress subscription_authorizer enforcement Zero TCP Loopback Hop Litestar Handler @get / @post / @mcp_tool Middleware & Route Guards Provide & FromDishka[T] msgspec DTOs & outputSchema SEP-1865 ui:// HTML resources ctx.log() -> notifications/message before/after_request hooks Session State, Subscription Fan-Out & Observability Layer MCPSessionStore (TTL) | SubscriptionManager (owner_id • session_id • subscription_authorizer) Registry (Tools • Resources • Prompts • Skills) | SpanManager OpenTelemetry (mcp.request • mcp.tool.call)
In-Process Stdio and Stateful/Stateless HTTP Bridge Pipeline Desktop MCP clients exchange newline-delimited JSON on stdin/stdout using in-process Litestar.lifespan() execution with MCPStdioContext or the remote HTTP bridge supporting both stateless 2026-07-28 and stateful 2025-11-25 Mcp-Session-Id sessions, GET /mcp SSE notification forwarding, and DELETE /mcp teardown. Desktop Host stdin / stdout NDJSON IDE & Desktop MCP Clients litestar mcp stdio (in-process) litestar mcp bridge (--endpoint) 2026-07-28 or 2025-11-25 frames Receives notifications/* on stdout mcp.run(transport="stdio") Stdio Lifecycle Adapter run_stdio_async() Enters Litestar.lifespan() Injects MCPStdioContext user • auth • session_id • state Streams progress & RFC 5424 logs Resource & skill list_changed push Bounded shutdown_timeout=5.0s ASGI Scope or HTTP Bridge stdio.py / bridge.py Stateless 2026-07-28 POST relay 2025-11-25 Mcp-Session-Id capture Background GET /mcp SSE listener Forwards SSE notifications to NDJSON Clean DELETE /mcp session teardown Owner ID: user:<subject> Application DI Full Litestar Pipeline DB Pools & Stores Active Dishka Scope.REQUEST Route Guards Enforced SkillCatalog & Registry live Identical Tool & UI Semantics MCPSessionStore + Tasks active Two CLI Modes: Local In-Process ASGI vs Stateful/Stateless Remote HTTP Bridge litestar --app app:app mcp stdio | litestar mcp bridge --endpoint https://api.example.com/mcp Bridge 2025-11-25 lifecycle: initialize -> Mcp-Session-Id -> GET /mcp SSE forwarder -> DELETE /mcp on EOF