Litestar MCP
Model Context Protocol (MCP), Multi-Agent Runtime, Durable DAG Workflows, and A2A 1.0 Interoperability for Litestar.
Expose existing Litestar routes as MCP tools, resources, prompts, and Agent Skills without duplicating handlers, middleware, guards, or dependency injection.
Core Capabilities¶
Zero-Duplicate Route Exposure
Mark existing Litestar routes with mcp_tool, mcp_resource, or mcp_prompt, advertise opt-in outputSchema with automatic structuredContent, and attach SEP-1865 MCP Apps metadata (io.modelcontextprotocol/ui, _meta.ui, title, icons). Calls run through in-process ASGI dispatch with full middleware, guards, and DTO validation.
Dual-Mode Streamable HTTP & Stdio
Serve stateless 2026-07-28 (server/discover, SEP-2575 headers, POST subscriptions/listen) and session-aware 2025-11-25 / 2025-06-18 / 2025-03-26 (initialize, Mcp-Session-Id, GET /mcp SSE, resources/subscribe, logging/setLevel, DELETE /mcp) on one /mcp endpoint alongside litestar mcp stdio and bridge.
Agent Skills & Universal DI
Publish io.modelcontextprotocol/skills (SEP-2640) via SkillCatalog (expose_as_prompts, notifications/skills/list_changed, litestar mcp list-skills) from static SKILL.md directories, dynamic request-aware SkillSource providers, or SkillController and PromptController classes wired with Provide and FromDishka[T].
Distributed MCP Tasks & Durable Workflows
Scale long-running io.modelcontextprotocol/tasks and DynamicWorkflow DAGs across worker replicas on litestar-queues with automatic principal, SecurityContext, and Dishka Scope.REQUEST rehydration plus multi-round MCPInputRequiredResult resume.
Multi-Agent Runtime & GoogleGenAIClient
Orchestrate Agent and AgentGroup hierarchies under AgentRuntime with strict TurnBudget ceilings, GoogleGenAIClient (defaulting to gemini-3.8-flash with thought-signature preservation), and owner-scoped SessionStore streaming.
Official A2A 1.0 JSON-RPC + HTTP+JSON REST
Mount LitestarA2A on official a2a-sdk 1.0 primitives with dual JSON-RPC 2.0 and native HTTP+JSON REST bindings (:send, :stream, :cancel, :subscribe), split Agent Card security, and /{tenant:str} + X-A2A-Tenant multi-tenancy.
Request & Dispatch Architecture¶
Every MCP tool and prompt invocation passes through MCPController and MCPHandlerService into Litestar's internal ASGI router, ensuring a single source of truth for validation, security, dependency injection, and OpenTelemetry spans.
Choose Your Entry Point¶
litestar-mcp supports two complementary authoring styles that compile down to the exact same Litestar ASGI pipeline:
Attach LitestarMCP to any existing Litestar application to expose selected routes over /mcp alongside your standard REST and OpenAPI endpoints:
Use the declarative MCP wrapper when building a dedicated MCP server with @mcp.tool(), @mcp.resource(), and @mcp.prompt() decorators:
Installation¶
Install litestar-mcp and any optional integration extras (a2a, queues, google-genai, opentelemetry, or all):
Explore by Domain¶
| Domain | Coverage |
|---|---|
| Architecture & Examples | Interactive HTML/SVG system diagrams, the 10-variant Notes reference application matrix (advanced_alchemy and sqlspec), and single-file PEP 723 uv run / uvx execution |
| Getting Started | Entry-point comparison, optional extra matrix, step-by-step quickstart, standalone MCP server guide, and core architectural concepts |
| MCP Core | MCPConfig, route markers, MCPOptKeys, outputSchema and structuredContent, io.modelcontextprotocol/ui MCP Apps, static uri= resources and RFC 6570 URI templates, PromptController, SkillCatalog (SEP-2640), RFC 5424 MCPRequestContext.log(), 2026-07-28 and 2025-11-25 Streamable HTTP, stdio, and bridge |
| Tasks, Queues & Workflows | io.modelcontextprotocol/tasks, progress_token forwarding, MCPInputRequiredResult, distributed QueueTaskExecutor, DurableWorkflowEngine DAGs, QueuedAgentChatController, and multi-replica deployment |
| Agents & A2A | Agent, AgentRuntime, TurnBudget, GoogleGenAIClient, AgentGroup handoffs, SSE session streaming, visibility-aware bidirectional protocol bridges, LitestarA2A, and multi-tenancy |
| Security & Operations | Litestar authentication middleware, first-party litestar-security & RFC 9728 metadata, MCPSessionStore owner isolation, subscription_authorizer, guards/scopes, RFC 5424 server logging, and OpenTelemetry TelemetryConfig |
| Reference | Curated API reference across all modules, auto-generated litestar mcp CLI documentation (stdio, bridge, export-tool-spec, list-tools, list-resources, list-skills, run), contributor workflow, and release changelog |