litestar-org/litestar-skills/litestar-mcp

Claude Code and agent skill by litestar-org/litestar-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Auto-activate for litestar_mcp, LitestarMCP, MCP, MCPConfig, MCPSkillsConfig, SkillController, LitestarA2A, A2AConfig, @mcp.tool/resource/prompt, mcp_tool=, or stdio MCP. Not for non-Litestar MCP SDK servers.

Install

npx vskill@latest install litestar-org/litestar-skills/litestar-mcp

SKILL.md

litestar-mcp

litestar-mcp exposes explicitly marked Litestar route handlers as Model Context Protocol (MCP) tools, resources, and prompts over JSON-RPC 2.0, and provides an optional A2A 1.0 adapter (LitestarA2A) backed by the official a2a-sdk.

litestar-mcp follows the stateless MCP specification (protocol 2026-07-28 with backward compatibility for 2025-06-18 and 2025-03-26). The MCP transport is POST-only and request-scoped: each request supplies protocol version, method, and capabilities. Call server/discover for capabilities. Features include the io.modelcontextprotocol/skills catalog (MCPSkillsConfig), durable task execution over litestar-queues (QueueTaskExecutor, DurableWorkflowEngine), the stdio-to-HTTP bridge (httpx2), standards-backed LitestarA2A (litestar-mcp[a2a]), and route authentication integration with litestar-security. 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.

Code Style Rules

  • PEP 604 unions: T | None, never Optional[T]
  • Consumer Litestar app modules MAY use from __future__ import annotations
  • Async all I/O. Pure standalone @mcp.tool / @mcp.resource / @mcp.prompt functions may be sync; keep blocking I/O out of the event loop.

Quick Reference

Install
bash
pip install litestar-mcp

The stdio-to-Streamable-HTTP bridge is included in the core package (httpx2). Install the a2a extra when mounting the optional A2A 1.0 SDK adapter (LitestarA2A):

bash
pip install "litestar-mcp[a2a]"
Basic Setup
python
from litestar import Litestar, get, post
from litestar_mcp import LitestarMCP, MCPConfig
@get("/users", mcp_tool="list_users")
async def list_users() -> list[dict[str, str | int]]:
"""List all registered users."""
return [{"id": 1, "name": "Alice"}]
@post("/analyze", mcp_tool="analyze_data")
async def analyze_data(data: dict[str, str]) -> dict[str, int]:
"""Analyze provided key-value dataset."""
return {"count": len(data)}
@get("/config", mcp_resource="app_config")
async def get_app_config() -> dict[str, bool]:
"""Read the active application configuration."""
return {"debug": False}
app = Litestar(
route_handlers=[list_users, analyze_data, get_app_config],
plugins=[LitestarMCP(MCPConfig(name="My API"))],
)

The transport and discovery surface across the ecosystem is:

EndpointOwnerPurpose
POST /mcpLitestarMCPThe only MCP transport route. JSON-RPC endpoint for server/discover, tools/*, resources/*, resources/templates/list, resources/directory/read, prompts/*, skills/*, completion/complete, subscriptions/listen, and optional tasks/* methods
POST /a2aLitestarA2A (litestar-mcp[a2a])Optional A2A 1.0 JSON-RPC and SSE streaming endpoint
GET /.well-known/agent-card.jsonLitestarA2A (litestar-mcp[a2a])Standard A2A 1.0 agent card discovery route (with ETag and Cache-Control)
GET /.well-known/oauth-protected-resourceSecurityPlugin (litestar-security)RFC 9728 OAuth 2.1 protected-resource metadata via SecurityConfig(protected_resource=ProtectedResourceConfig(...))
MCPConfig
OptionTypeDefaultDescription
base_pathstr"/mcp"URL prefix for the MCP transport endpoint
include_in_schemaboolFalseInclude the /mcp router in OpenAPI
name`str \None`NoneServer name; defaults to OpenAPI title
instructions`str \None`NoneServer instructions advertised to MCP clients
guards`list[Any] \None`NoneLitestar guards applied to the MCP router
route_opt`dict[str, Any] \None`NoneRoute opt mapping merged into the mounted MCP router (e.g., {AUTH_POLICY_OPT_KEY: required("api-key", "oidc")} with litestar-security)
allowed_origins`list[str] \None`NoneRestrict accepted Origin headers
include_operations`list[str] \None`NoneOnly expose matching operation names
exclude_operations`list[str] \None`NoneExclude matching operation names
include_tags`list[str] \None`NoneOnly expose routes with matching OpenAPI tags
exclude_tags`list[str] \None`NoneExclude routes with matching OpenAPI tags
tasks`bool \MCPTaskConfig`FalseEnable MCP task support (io.modelcontextprotocol/tasks). Pass MCPTaskConfig to configure the backing Store and record TTLs
skills`MCPSkillsConfig \None`NoneEnable the io.modelcontextprotocol/skills catalog serving <path>/<name>/SKILL.md directories
opt_keysMCPOptKeysMCPOptKeys()Rename the handler.opt keys the plugin reads
cache_ttl_msint0Response cache lifetime in milliseconds; 0 disables caching
cache_scopeLiteral["private", "public"]"private"Whether cached responses may be shared between callers
subscription_max_streamsint10000Max concurrent SSE streams
subscription_keepalive_secondsfloat15.0Seconds between SSE keepalive pings
stream_queue_capacityint256Maximum queued progress notifications per request stream
stream_cleanup_timeoutfloat5.0Positive finite seconds allowed for cooperative stream producer cleanup
subscription_channels`Any \None`NoneChannels backend backing subscriptions/listen fan-out
list_page_sizeint100Page size for tools/list, resources/list, resources/templates/list, skills/list, prompts/list, and resources/directory/read
before_tool_call`BeforeToolCallHook \None`NoneObserve each tools/call before dispatch
after_tool_call`AfterToolCallHook \None`NoneObserve each tools/call result, exception, and duration
max_blob_bytes`int \None`25 * 1024 * 1024Maximum raw byte length for base64-embedded blobs; None disables the cap
Filters (include_tags / exclude_tags / include_operations / exclude_operations) gate both list responses and direct invocation. A filtered tool/resource/template behaves like an unknown name or URI in tools/call / resources/read; still use guards or route_opt auth policies for real access control.
Route Marking
python
from litestar import get, post
@get("/products", mcp_resource="product_list")
async def list_products() -> list[dict[str, str]]:
"""List all available products in the catalog."""
return [{"id": "sku-1", "name": "Widget"}]
@post("/cart/items", mcp_tool="add_to_cart")
async def add_to_cart(data: dict[str, int]) -> dict[str, str]:
"""Add a product item to the shopping cart."""
return {"status": "added"}
@get(
"/products/{product_id:int}",
mcp_resource="product",
mcp_resource_template="shop://products/{product_id}",
)
async def get_product(product_id: int) -> dict[str, int | str]:
"""Fetch details for a single product by identifier."""
return {"id": product_id, "name": "Widget"}
@get("/products/{product_id:int}/blurb", mcp_prompt="product_blurb")
async def product_blurb(product_id: int) -> str:
"""Write a short marketing blurb for a product."""
return f"Product {product_id} is top tier."

mcp_resource_template takes effect alongside mcp_resource — the resource supplies the name the template binds to. A handler can expose more than one MCP role (a tool and a resource) at once; the description-override keys (mcp_description vs mcp_resource_description) are kind-specific so each surface can carry its own prose.

Register prompts not bound to a route with the @mcp_prompt decorator plus LitestarMCP(prompts=[...]):

python
from litestar import Litestar
from litestar_mcp import LitestarMCP, mcp_prompt
@mcp_prompt("summarize", description="Summarize a document for the user.")
def summarize(text: str) -> str:
"""Produce a summarization prompt for the supplied text."""
return f"Summarize the following:\n\n{text}"
app = Litestar(plugins=[LitestarMCP(prompts=[summarize])])

Use structured metadata when the agent needs sharper tool selection:

python
from litestar import post
from litestar_mcp import mcp_tool
@post("/reports")
@mcp_tool(
name="generate_report",
description="Generate a report for an existing account.",
agent_instructions="Ensure account ID exists before calling.",
when_to_use="Use after the user has confirmed the account and date range.",
returns="A report id and queued status.",
scopes=["reports:write"],
task_support="optional",
)
async def generate_report(data: dict[str, str]) -> dict[str, str]:
"""Create a new reporting job."""
return {"report_id": "rep-123", "status": "queued"}
Accessing Request Context And Progress

Retrieve active MCP scope and metadata inside tool, resource, or prompt handlers with get_mcp_request_context(). When the client supplies a progress token (params._meta.progressToken), call await ctx.report_progress(...) to stream notifications/progress SSE events over the active request stream:

python
from litestar import post
from litestar_mcp import MCPRequestContext, get_mcp_request_context
@post("/agent-session", mcp_tool="record_session")
async def record_session(note: str) -> dict[str, str]:
"""Record a note attached to the calling MCP client."""
ctx: MCPRequestContext = get_mcp_request_context()
if ctx.progress_token is not None:
await ctx.report_progress(0.5, total=1.0, message="Recording session note")
return {
"client_id": ctx.client_id,
"owner_id": ctx.owner_id or "anonymous",
"note": note,
}
Standalone MCP App, Skills Catalog, A2A 1.0, Binary Results, and Auth

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/litestar-org/litestar-skills/litestar-mcp/badge)](https://verified-skill.com/skills/litestar-org/litestar-skills/litestar-mcp)

Something wrong with this skill or its page? Tell us.