Types#
This module contains type definitions for the Litestar MCP Plugin.
MCPConfig#
MCPConfig is documented in Config API.
MCPTaskConfig#
MCPSkillsConfig#
- class litestar_mcp.mcp.config.MCPSkillsConfig[source]#
Bases:
objectConfiguration for the opt-in Skills over MCP extension.
- paths#
Directories whose immediate child folders containing a
SKILL.mdfile are served as MCP skills. Entries are normalized withPath, so a plain string works at runtime; the annotation isSequence[Path], so type-checked callers should passPathobjects. A barestrin place of the sequence is rejected.
- directory_read#
Advertise and serve
resources/directory/read.
- max_files_per_skill#
Maximum files, including
SKILL.md, one skill may contain before it is rejected at startup.
- max_bytes_per_skill#
Maximum total byte size of one skill's files before it is rejected at startup.
- __init__(paths, directory_read=True, max_files_per_skill=512, max_bytes_per_skill=16777216)#
MCPStdioContext#
Runtime identity for standalone stdio transports. Its fields seed the
synthesized dispatch scope so handlers, guards, and task execution read the
usual request.user / request.scope["auth"] / session / state. See
Standalone Application for the stdio walkthrough.
MCPResourceLink#
- class litestar_mcp.mcp.content.MCPResourceLink[source]#
Bases:
objectA tool-result content block linking to a fetchable MCP resource.
- __init__(name, uri, mime_type=None, description=None, title=None, size=None, annotations=None, meta=None)#
MCPBlobResource#
- class litestar_mcp.mcp.content.MCPBlobResource[source]#
Bases:
objectA tool-result embedded resource backed by bytes.
- __init__(uri, data, mime_type='application/octet-stream', annotations=None, meta=None)#
MCPToolResult#
PromptRegistration#
See also MCPOptKeys (documented under
Config API) for the opt-key field names that drive handler-based
prompt discovery.
- class litestar_mcp.mcp.registry.PromptRegistration[source]#
Bases:
objectA registered MCP prompt — either a standalone callable or a route handler.
Standalone prompts are plain (async) functions decorated with
@mcp_promptand passed toLitestarMCP(prompts=[...]).Handler-based prompts are Litestar route handlers discovered via the
mcp_promptopt key, executed through the normal Litestar pipeline.- name#
Unique prompt identifier used in
prompts/get.
- fn#
The callable to invoke (standalone prompt functions).
- handler#
The Litestar route handler (handler-based prompts).
- title#
Optional human-readable display name.
- description#
Optional LLM-facing description.
- arguments#
Explicit argument definitions. When
None, derived from the function signature (standalone prompts) or the handler's parsed signature (handler-based prompts), with DI- and framework-injected parameters filtered out.
- icons#
Optional list of icon objects for UI display.
- get_arguments()[source]#
Return prompt arguments, introspecting from signature if needed.
When
argumentswas set explicitly, returns that list unchanged.For standalone prompts, walks
inspect.signature(fn).parameters(which transparently consultsfn.__signature__when present and otherwise builds fromfn.__code__/fn.__annotations__).For handler-based prompts, walks the handler's parsed Litestar signature, filtering out DI dependencies and framework parameters (
request,headers, …) so the advertised shape matches what an MCP caller is expected to supply.Both paths enrich each entry with a Google-style docstring description when present.
- __init__(name, fn=None, handler=None, title=None, description=None, arguments=None, icons=None, instructions=None)#