MCP Resource Server example that supports OAuth 2.0 (introspection), API Key (X-API-Key or Bearer <key>), and Mutual TLS (placeholder).
- Uses
MultiProtocolAuthBackendwithOAuthTokenVerifier,APIKeyVerifier, and a Mutual TLS placeholder verifier. - PRM and
RequireAuthMiddlewareuseauth_protocols(oauth2, api_key, mutual_tls),default_protocol, andprotocol_preferences. - Serves
/.well-known/authorization_serversfor unified discovery.
-
Start the Authorization Server (same as simple-auth):
Fromexamples/servers/simple-auth:uv run mcp-simple-auth-as --port=9000 -
Start this Resource Server:
From this directory:uv run mcp-simple-auth-multiprotocol-rs --port=8002 --auth-server=http://localhost:9000 -
Use OAuth (e.g. simple-auth-client) or API Key:
- OAuth: same as simple-auth (401 → discovery → OAuth → token → MCP).
- API Key: set header
X-API-Key: demo-api-key-12345orAuthorization: Bearer demo-api-key-12345(default key).
Custom keys:--api-keys=key1,key2.
You can run the Resource Server without the Authorization Server when using API Key authentication:
-
Start the Resource Server (from this directory):
uv run mcp-simple-auth-multiprotocol-rs --port=8002 --api-keys=demo-api-key-12345
-
Run the client from
examples/clients/simple-auth-multiprotocol-client:MCP_SERVER_URL=http://localhost:8002/mcp MCP_API_KEY=demo-api-key-12345 uv run mcp-simple-auth-multiprotocol-client
-
At the
mcp>prompt, runlist,call get_time {}, thenquit.
One-command verification (from repo root):
./examples/clients/simple-auth-multiprotocol-client/run_multiprotocol_test.sh
This starts the RS, then the client with API Key; complete the session with list, call get_time {}, quit.
DPoP (Demonstrating Proof-of-Possession, RFC 9449) binds the access token to a client-held key. Use it together with OAuth.
-
Start the Authorization Server (from
examples/servers/simple-auth):
uv run mcp-simple-auth-as --port=9000 -
Start this Resource Server with DPoP enabled (from this directory):
uv run mcp-simple-auth-multiprotocol-rs --port=8002 --auth-server=http://localhost:9000 --api-keys=demo-api-key-12345 --dpop-enabled
-
Run the client with OAuth and DPoP from
examples/clients/simple-auth-multiprotocol-client:MCP_SERVER_URL=http://localhost:8002/mcp MCP_USE_OAUTH=1 MCP_DPOP_ENABLED=1 uv run mcp-simple-auth-multiprotocol-client
Complete OAuth in the browser, then at
mcp>runlist,call get_time {},quit. Server logs should show "Authentication successful with DPoP".
One-command verification (from repo root):
./examples/clients/simple-auth-multiprotocol-client/run_dpop_test.sh — starts AS and RS (with --dpop-enabled), runs automated DPoP tests, then optionally the OAuth+DPoP client (use MCP_SKIP_OAUTH=1 to skip the manual OAuth step).
Mutual TLS is a placeholder in this example: the server accepts the mutual_tls protocol in PRM/discovery but does not perform client certificate validation. Selecting mTLS in the client will show a "not implemented" style message.
- Server: No extra flags;
auth_protocolsalready includesmutual_tls. - Client (from repo root):
MCP_AUTH_PROTOCOL=mutual_tls ./examples/clients/simple-auth-multiprotocol-client/run_multiprotocol_test.sh
The client will start but mTLS authentication is not implemented in this example.
--port: RS port (default 8002).--auth-server: AS URL (default http://localhost:9000).--api-keys: Comma-separated valid API keys (default demo-api-key-12345).--oauth-strict: Enable RFC 8707 resource validation.--dpop-enabled: Enable DPoP proof verification (RFC 9449); use with OAuth.
Mutual TLS is a placeholder (no client certificate validation).