Skip to main content
Authentication middleware for mcp-use server.

AuthMiddleware

from mcp_use.server.auth.middleware import AuthMiddleware

method init

Initialize auth middleware.Parameters
app
ASGIApp
required
The ASGI application
auth_provider
BearerAuthProvider
required
Provider to validate tokens
exclude_paths
list[str] | None
default:"None"
Paths to exclude from authentication
protected_paths
list[str] | None
default:"None"
Paths that require authentication (default: /mcp)
Signature
def __init__(app: ASGIApp, auth_provider: BearerAuthProvider, exclude_paths: list[str] | None = None, protected_paths: list[str] | None = None):