Use this configuration when your authorization server fully implements the MCP Authorization spec. Agentgateway acts as the resource server and validates tokens directly.
When using Keycloak, set provider.keycloak: {} to enable the Keycloak adapter. The gateway exposes modified well-known endpoints and proxies client registration to Keycloak.
If jwks.url is omitted, the gateway derives it automatically as <issuer>/.well-known/jwks.json for Auth0.
You can also require authentication when proxying a remote MCP server over HTTPS. Add backendTLS: {} to enable TLS verification for the upstream connection.
By default, the exp (expiration) claim is required in every token. You can customize which RFC 7519 registered claims must be present using jwtValidationOptions.requiredClaims.Only the following claim names are recognized: exp, nbf, aud, iss, sub. Any other value is silently ignored.
This setting only enforces presence. Standard claims like exp are always validated when present — an expired token is rejected regardless of requiredClaims.
Tokens without exp remain valid until the signing key is rotated. Only use requiredClaims: [] when your identity provider intentionally omits expiration and you have a key rotation strategy in place.
The authentication example uses Keycloak and a mock authorization server. Start them with:
make run-validation-deps
This starts the mock authorization server on http://localhost:9000 and Keycloak on http://localhost:7080.
2
Start the gateway
cargo run -- -f examples/mcp-authentication/config.yaml
3
Test unauthenticated access
A request without a token should return 401 Unauthorized:
curl -i http://localhost:3000/stdio/mcp
The response includes a WWW-Authenticate header with a link to the resource metadata endpoint.
4
Test with MCP Inspector
npx @modelcontextprotocol/inspector
Set transport to Streamable and URL to http://localhost:3000/stdio/mcp. The MCP Authorization flow starts automatically after the initial 401 response. For Keycloak, use credentials testuser / testpass.