mcp-auth is a provider-neutral OAuth platform for HTTP-based Model Context Protocol
247
mcp-auth is a provider-neutral OAuth platform for HTTP-based Model Context Protocol (MCP) resource servers.
It separates three concerns that are often coupled:
An OIDC provider (a connector requesting openid, with a verified ID token) and a
plain OAuth 2.0 provider (no openid, identity from userinfo_endpoint) are both
supported. Endpoints may be configured directly or discovered from the issuer, and
ID tokens may use RS256, PS256, or ES256. See
OIDC or plain OAuth 2.0.
flowchart LR
client["MCP client<br/>Cursor, Claude, or another client"]
resource["MCP resource server<br/>Python or Go SDK"]
auth["mcp-auth<br/>authorization server"]
idp["Upstream identity provider<br/>OIDC or OAuth 2.0"]
api["Downstream API"]
client -->|"1. MCP request"| resource
resource -.->|"2. 401 + protected-resource metadata"| client
client -->|"3. Authorization Code + PKCE"| auth
auth <-->|"4. User login and consent"| idp
auth -->|"5. MCP access token"| client
client -->|"6. Bearer token"| resource
resource -.->|"7. Verify with JWKS"| auth
resource -->|"8. Separate downstream token"| api
The token sent by the MCP client is valid only for the MCP resource server. It is never forwarded to the downstream API. The resource server obtains a separate downstream credential through token exchange or the connector's upstream session.
The repository contains:
auth-server/: a standalone Go OAuth authorization server.auth-client/python/: a reusable Python resource-server SDK, including a FastMCP adapter.auth-client/go/: a reusable Go resource-server SDK.examples/demo-mcp/: a dummy FastMCP resource server used by Compose E2E.MCP authorization is optional at the protocol level. A resource server may still require it when it exposes private data or actions.
The authorization server owns login, consent, client registration, token issuance, refresh rotation, and connector selection. Resource servers remain independent: they use the SDK to publish discovery metadata, return the correct bearer challenge, validate JWTs locally from JWKS, and obtain downstream credentials when needed.
For sequence diagrams, credential boundaries, extension points, and deployment topologies, see Architecture.
Python resource servers can use:
from mcp_auth_client import JWTVerifier, RemoteAuthProvider, TokenExchangeClient
verifier = JWTVerifier(
jwks_uri="https://auth.example.com/.well-known/jwks.json",
issuer="https://auth.example.com",
audience="https://mcp.example.com",
required_scopes={"tools:read"},
)
Go resource servers can import the module under auth-client/go and use mcpauth.JWTVerifier, discovery helpers, and TokenExchangeClient.
The Python SDK is currently installed directly from Git while its API settles:
python -m pip install "mcp-auth-client @ git+https://github.com/Agent-Hellboy/mcp-auth.git#subdirectory=auth-client/python"
The authorization server selects a provider-neutral connector at runtime with
MCP_AUTH_CONNECTORS_FILE and MCP_AUTH_CONNECTOR; the connector contains
endpoints and environment-variable names for secrets, never secret values.
Publishing a GitHub Release (vX.Y.Z) builds auth-server and pushes
princekrroshan01/mcp-auth-server to Docker Hub with that version tag, and
latest for non-prerelease versions.
S256) is required for public clients.private_key_jwt) and presents only a subject_token
this server itself issued; it is not an open relay to the upstream connector.examples/demo-mcp is a dummy MCP server. Compose E2E runs it with Keycloak as
the identity provider. See docs/demo-example.md.
MIT. See LICENSE.
Content type
Image
Digest
sha256:506237865…
Size
5.9 MB
Last updated
about 9 hours ago
docker pull princekrroshan01/mcp-auth-server