litestar-mcp
litestar-mcp
litestar-mcp exposes explicitly marked Litestar route handlers and class-based SkillController / PromptController definitions as Model Context Protocol (MCP) tools, resources, prompts, and skills over JSON-RPC 2.0, provides a multi-agent runtime (litestar_mcp.agent) with distributed queue execution (litestar_mcp.queues), and includes an optional A2A 1.0 adapter (LitestarA2A) backed by a2a-sdk.
Version 0.16.0 follows the stateless MCP specification (protocol 2026-07-28). The MCP transport is POST-only and request-scoped: the legacy initialize handshake, sessions and Mcp-Session-Id, ping, GET and DELETE transport handlers, replay, and /.well-known/mcp-server.json are removed. Each request supplies protocol version, method, and client capabilities; named calls also supply matching name or URI metadata. Call server/discover for capabilities. Version 0.16.0 also ships:
- Static and dynamic
io.modelcontextprotocol/skillscatalogs (MCPSkillsConfig(paths=..., sources=...),FilesystemSkillSource, async request-awareSkillSourceprotocol, and in-memorySkill.build/Skill.from_content/SkillFile.from_content). - Class-based
SkillControllerandPromptController(@tool,@prompt,PromptMessage) with recursive discovery across nestedRouter/DishkaRouter/litestar-autowiretrees and automaticRESERVED_KWARGSparameter aliasing. - Universal dependency injection across HTTP routes, MCP
tools/call/prompts/get, and standaloneAgentRuntime(Tool.execute): LitestarProvide/Dependency, DishkaFromDishka[T], genericAnnotated[T, Inject()]/Depends(fn)markers, andToolContext(container=..., dependency_resolver=...). - Streamable HTTP client and stdio bridge (
MCPStreamableHTTPClient,prepare_mcp_request,mcp_request_headers, andrun_stdio_streamable_http_bridge) powered byhttpx2in core. - Agent runtime, workflows, and protocol bridges (
litestar_mcp.agent:Agent,AgentGroup,AgentRuntime,GoogleGenAIClientdefaulting togemini-3.8-flash,AgentChatController,DynamicWorkflow,WorkflowEngine,agent_to_mcp,agent_to_a2a,mcp_to_tools,discover_mcp_tools), plus optional distributed queue execution (litestar_mcp.queues:QueuedAgentChatController,QueuedTurnManager,AgentRegistry) and OpenTelemetry GenAI spans (TelemetryConfig,SpanManager). - Standards-backed A2A 1.0 and OAuth 2.1 discovery:
LitestarA2A/A2AConfig(litestar-mcp[a2a],a2a-sdk>=1.1.4) andlitestar-securityroute authentication policies plus RFC 9728/.well-known/oauth-protected-resourcediscovery. See Stateless Protocol.
Mark routes by passing mcp_tool="name", mcp_resource="name", or mcp_prompt="name" directly to the Litestar route decorator — Litestar funnels unknown kwargs into handler.opt, so no opt={...} wrapper is needed. Use the decorator forms for structured metadata: @mcp_tool adds schemas, annotations, scopes, and task policy; @mcp_prompt adds title, arguments, and icons. Route description keys are mcp_description, mcp_resource_description, and mcp_prompt_description; MCPOptKeys can rename every key the plugin reads. There is no opt={"mcp_tool_name": ...} form or mcp_exclude key. To hide a route, leave it unmarked.