mcpAuthentication policy validates incoming Bearer tokens from MCP clients against a configured OAuth 2.0 / OIDC authorization server. When enabled, Agentgateway enforces token validity before allowing any MCP traffic and optionally serves OAuth 2.0 Protected Resource Metadata at /.well-known/oauth-protected-resource/<path>.
Configuration location
mcpAuthentication is set under binds[].listeners[].routes[].policies:
Fields
The expected
iss (issuer) claim in the JWT. Must exactly match the issuer URL of your authorization server.A list of accepted
aud (audience) values. The token must contain at least one of these values.Source of the JSON Web Key Set (JWKS) used to verify token signatures. Exactly one of
file or url must be set.Token enforcement mode. When set to
strict, Agentgateway rejects requests that do not carry a valid Bearer token. When omitted or set to a permissive value, tokens are validated when present but not required.Optional provider hint for non-spec-compliant authorization servers. When set, Agentgateway activates a compatibility adapter that adjusts
/.well-known/oauth-authorization-server responses. Exactly one of auth0 or keycloak must be specified.Configures the OAuth 2.0 Protected Resource Metadata document served at
/.well-known/oauth-protected-resource/<path>. MCP clients use this to discover the correct authorization server.Fine-grained control over which RFC 7519 registered claims must be present in the token before validation proceeds.
Examples
Standard OIDC provider
Standard OIDC provider
Keycloak provider
Keycloak provider
Auth0 provider
Auth0 provider
Local JWKS file with strict validation
Local JWKS file with strict validation
When
resourceMetadata is configured, Agentgateway automatically registers /.well-known/oauth-protected-resource/<path> and /.well-known/oauth-authorization-server/<path> endpoints. Include these paths in your route matches so the gateway serves them correctly.jwtAuth
ThejwtAuth policy provides generic JWT validation for any route — not limited to MCP. Unlike mcpAuthentication, it does not expose OAuth resource metadata endpoints. Use it for standard API authentication and as the authentication layer alongside mcpAuthorization.
Configuration location: binds[].listeners[].routes[].policies.jwtAuth
The policy supports two forms:
- Single provider (shorthand)
- Multiple providers
Fields
Enforcement mode. When set to
strict, requests without a valid token are rejected.Expected
iss claim. Used in the single-provider shorthand form.Accepted
aud claim values. Used in the single-provider shorthand form.JWKS source. One of
file (path on disk, relative to binary working directory) or url (HTTP endpoint).List of JWT providers for multi-provider configurations. Each provider has
issuer, audiences, jwks, and jwtValidationOptions fields identical to the single-provider shorthand.Claims that must be present in the token. Recognized values:
exp, nbf, aud, iss, sub. Defaults to ["exp"].jwt.<claim> in CEL expressions used by mcpAuthorization and authorization policies.
apiKey
TheapiKey policy authenticates requests using static API keys passed in the Authorization: Bearer header or x-api-key header.
Configuration location: binds[].listeners[].routes[].policies.apiKey
Fields
List of valid API keys.
Enforcement mode. When set to
strict, requests without a valid key are rejected.apiKey.key and any custom metadata fields under apiKey.<field>.
basicAuth
ThebasicAuth policy authenticates requests using HTTP Basic Authentication validated against an htpasswd file.
Configuration location: binds[].listeners[].routes[].policies.basicAuth
Fields
Source of the htpasswd credentials.
Realm name sent in the
WWW-Authenticate header when authentication fails.Enforcement mode. When set to
strict, unauthenticated requests are rejected with 401.basicAuth.username.