Types#

This module contains type definitions for the Litestar MCP Plugin.

MCPConfig#

MCPConfig is documented in Config API.

MCPTaskConfig#

class litestar_mcp.mcp.config.MCPTaskConfig[source]#

Bases: object

Configuration for the opt-in MCP Tasks extension.

__init__(store=None, default_ttl_ms=300000, max_ttl_ms=3600000, poll_interval_ms=1000)#

MCPSkillsConfig#

class litestar_mcp.mcp.config.MCPSkillsConfig[source]#

Bases: object

Configuration for the opt-in Skills over MCP extension.

paths#

Directories whose immediate child folders containing a SKILL.md file are served as MCP skills. Entries are normalized with Path, so a plain string works at runtime; the annotation is Sequence[Path], so type-checked callers should pass Path objects. A bare str in 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.

__post_init__()[source]#

Validate and normalize skill directory paths and size bounds.

Return type:

None

__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.

class litestar_mcp.mcp.app.MCPStdioContext[source]#

Bases: object

Runtime identity context for standalone MCP stdio transports.

__init__(client_id='stdio', owner_id=None, user=None, auth=None, session=None, state=None)#

MCPBlobResource#

class litestar_mcp.mcp.content.MCPBlobResource[source]#

Bases: object

A tool-result embedded resource backed by bytes.

to_content_block(*, max_blob_bytes=None)[source]#

Return the MCP embedded resource content block.

Parameters:

max_blob_bytes (Optional[int]) -- Optional byte limit enforced before base64 encoding.

Return type:

dict[str, typing.Any]

__init__(uri, data, mime_type='application/octet-stream', annotations=None, meta=None)#

MCPToolResult#

class litestar_mcp.mcp.content.MCPToolResult[source]#

Bases: object

A complete MCP tool result with explicit content blocks.

to_result(*, max_blob_bytes=None)[source]#

Return the MCP tools/call result object.

Return type:

dict[str, typing.Any]

__init__(content, structured_content=<object object>, is_error=False, meta=None)#

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: object

A registered MCP prompt — either a standalone callable or a route handler.

Standalone prompts are plain (async) functions decorated with @mcp_prompt and passed to LitestarMCP(prompts=[...]).

Handler-based prompts are Litestar route handlers discovered via the mcp_prompt opt 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 arguments was set explicitly, returns that list unchanged.

For standalone prompts, walks inspect.signature(fn).parameters (which transparently consults fn.__signature__ when present and otherwise builds from fn.__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.

Return type:

list[dict[str, typing.Any]]

__init__(name, fn=None, handler=None, title=None, description=None, arguments=None, icons=None, instructions=None)#