Types¶
This module contains type definitions for the Litestar MCP Plugin.
MCPConfig¶
- class litestar_mcp.config.MCPConfig[source]¶
Bases:
objectConfiguration 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
Trueto 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¶
MCPAuthConfig¶
- class litestar_mcp.auth.MCPAuthConfig[source]¶
Bases:
objectMetadata for the
/.well-known/oauth-protected-resourcemanifest.Authentication enforcement is handled by a Litestar authentication middleware (either your own
AbstractAuthenticationMiddlewaresubclass or the built-inMCPAuthBackend). 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:
objectConfiguration for validating bearer tokens against an OIDC/JWKS provider.
- issuer¶
Expected
issclaim and discovery base URL.
- audience¶
Expected
audclaim (string, list, orNoneto 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/nbfchecks.
- jwks_cache¶
Optional shared
JWKSCacheinstance. WhenNonethe 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)¶