Stateless Streamable HTTP and Internal ASGI Dispatch Pipeline JSON-RPC requests arrive at MCPController (/mcp), negotiate 2026-07-28 or 2025-06-18 via MCPHandlerService, and execute tools and prompts through Litestar internal ASGI dispatch with middleware, guards, DI, and OpenTelemetry spans. MCP Client POST / DELETE /mcp 2026-07-28: server/discover 2025-06-18: initialize & ping SEP-2575 Capability Headers JSON or text/event-stream MCPController MCPHandlerService Router Guards & route_opt Origin & Protocol Validation 202 Accepted (notifications) 204 No Content (DELETE /mcp) Internal ASGI Dispatch execute_tool / prompt Forwards Auth & Trace Headers Preserves request.user & auth Binds ToolContext in scope Zero TCP Loopback Hop Litestar Handler @get / @post / @tool Middleware & Route Guards Provide & FromDishka[T] DTOs & msgspec Validation before/after_request Hooks Cross-Cutting Observability & Registry Layer Registry (Tools • Resources • Prompts • Skills) | TelemetryConfig OpenTelemetry Spans (mcp.request • mcp.tool.call)
In-Process Stdio and HTTP Bridge Pipeline Desktop MCP clients communicate over newline-delimited JSON on stdin/stdout using either in-process Litestar.lifespan() execution with MCPStdioContext or the stateless HTTP relay bridge. Desktop Host stdin / stdout NDJSON Claude Desktop / Cursor / IDE litestar mcp stdio litestar mcp bridge mcp.run(transport="stdio") Stdio Lifecycle Adapter run_stdio_async() Enters Litestar.lifespan() Injects MCPStdioContext user • auth • session • state Bounded shutdown_timeout=5.0s Synthetic ASGI Scope MCPHandlerService In-Memory ASGI Dispatch Or Remote HTTP Relay (--url) Owner ID: user:<subject> SSE Progress Notification Loop Application DI Full Litestar Pipeline DB Pools & Stores Active Dishka Scope.REQUEST Route Guards Enforced Identical Tool Semantics Two CLI Modes: Local In-Process vs Remote HTTP Relay litestar --app app:app mcp stdio (in-process ASGI) | litestar mcp bridge --url https://api.example.com/mcp (remote HTTP)