Prerequisites
- A working MCP server (see MCP Quickstart)
- An OAuth 2.0 / OpenID Connect provider (Keycloak, Auth0, Okta, or similar) with a JWKS endpoint
Step 1: Configure OAuth
Add theoauth section to your existing MCP configuration in config.yaml:
server.base_url is required when OAuth is enabled. It is used for the RFC 9728 metadata endpoint and
resource_metadata in WWW-Authenticate headers. Set this to your externally-reachable URL.Step 2: Add Scope Requirements
Define which scopes are required at each level:Step 3: Restart and Verify
Restart your router. You should see the MCP server start with OAuth enabled in the logs.Verify the metadata endpoint
The RFC 9728 metadata endpoint should be publicly accessible:Verify token enforcement
A request without a token should return401 Unauthorized:
Step 4: Connect an MCP Client
Your MCP client needs to obtain a token from your authorization server and include it in requests. How this works depends on the client.Well-behaved MCP clients will read
scopes_supported from the metadata endpoint and request all supported scopes
during the initial authorization. This avoids step-up challenges entirely when the authorization server grants all
requested scopes.Development Setup with Symmetric Secrets
For local development, you can use a symmetric secret instead of a remote JWKS endpoint:What’s Next
Scope Enforcement
Understand how scopes are enforced at multiple levels and how to use
@requiresScopes for per-tool authorization.Configuration Reference
Full reference for all OAuth options, JWKS settings, environment variables, and error responses.