Types

This module contains type definitions for the Litestar MCP Plugin.

MCPConfig

class litestar_mcp.config.MCPConfig[source]

Bases: object

Configuration for the Litestar MCP Plugin.

The plugin uses Litestar's opt attribute to discover routes marked for MCP exposure. Server name and version are derived from the Litestar app's OpenAPI configuration.

base_path

Base path for MCP API endpoints.

include_in_schema

Whether to include MCP routes in OpenAPI schema generation.

name

Optional override for server name. If not set, uses OpenAPI title.

guards

Optional list of guards to protect MCP endpoints.

allowed_origins

List of allowed Origin header values. If empty/None, all origins are accepted. When set, requests with a non-matching Origin are rejected with 403.

auth

Optional OAuth 2.1 auth configuration. When set, bearer token validation is enforced on MCP endpoints.

tasks

Optional task configuration or True to enable the default experimental in-memory task implementation.

property task_config: MCPTaskConfig | None

Return the normalized task configuration, if task support is enabled.

__init__(base_path='/mcp', include_in_schema=False, name=None, guards=None, allowed_origins=None, include_operations=None, exclude_operations=None, include_tags=None, exclude_tags=None, auth=None, tasks=False, opt_keys=<factory>, session_store=None, session_max_idle_seconds=3600.0, sse_max_streams=10000, sse_max_idle_seconds=3600.0, _session_manager=None)

MCPTaskConfig

class litestar_mcp.config.MCPTaskConfig[source]

Bases: object

Configuration for experimental MCP task support.

__init__(enabled=True, list_enabled=True, cancel_enabled=True, default_ttl=300000, max_ttl=3600000, poll_interval=1000)

MCPAuthConfig

class litestar_mcp.auth.MCPAuthConfig[source]

Bases: object

Metadata for the /.well-known/oauth-protected-resource manifest.

Authentication enforcement is handled by a Litestar authentication middleware (either your own AbstractAuthenticationMiddleware subclass or the built-in MCPAuthBackend). This struct only describes the auth surface to discovery clients.

issuer

OAuth 2.1 authorization server issuer URL (advertised to clients).

audience

Resource identifier used in the protected-resource manifest.

scopes

Mapping of scope name to human-readable description.

__init__(issuer=None, audience=None, scopes=None)

OIDCProviderConfig

class litestar_mcp.auth.OIDCProviderConfig[source]

Bases: object

Configuration for validating bearer tokens against an OIDC/JWKS provider.

issuer

Expected iss claim and discovery base URL.

audience

Expected aud claim (string, list, or None to skip).

jwks_uri

Optional explicit JWKS endpoint (overrides discovery).

discovery_url

Optional override for the OpenID discovery document URL.

algorithms

Allowed JWS algorithms (default: ["RS256"]).

cache_ttl

JWKS / discovery document cache TTL in seconds.

clock_skew

Tolerance in seconds for exp / iat / nbf checks.

jwks_cache

Optional shared JWKSCache instance. When None the process-wide default cache is used.

__init__(issuer, audience=None, jwks_uri=None, discovery_url=None, algorithms=<factory>, cache_ttl=3600, clock_skew=30, jwks_cache=None)