External OAuth enables using your existing identity provider (Okta, Auth0, Azure AD, Descope, Cognito) instead of Portkeyâs built-in authentication. Users authenticate with corporate credentialsâno Portkey accounts needed.
When to Use
Organizations with existing IdPs can use External OAuth. Users authenticate through the IdP for other services, and MCP access works the same way.
Common scenarios:
- SSO for internal developers. Engineers use corporate credentials to access MCP servers
- B2B applications. Your customers authenticate through their own IdP
- Compliance requirements. Mandate use of your own identity infrastructure
- No Portkey accounts. Users who arenât in Portkey need MCP access
How It Works
Portkey never handles user credentials. Your IdP remains the source of truth for identity.
Configuration
Configure JWT validation for your MCP server. Portkey validates incoming tokens using your IdPâs public keys or introspection endpoint.
Option 1: JWKS URI (Recommended)
The most common setup. Portkey fetches public keys from your IdPâs JWKS endpoint.
How it works:
- Portkey fetches and caches your IdPâs public keys
- Keys are cached for 24 hours by default
- If a key rotates, Portkey automatically refetches
- Validation happens locally (no network call per request)
Option 2: Token Introspection
For opaque tokens requiring real-time validation, or for immediate revocation.
How it works:
- Portkey calls your IdPâs introspection endpoint
- Response is cached for the configured duration (default: no caching)
- With
introspectCacheMaxAge: 300, results are cached for 5 minutes
Caching tradeoff:
- No cache: Every request calls introspection endpoint (slower, but immediate revocation)
- With cache: Better performance, but revocation takes up to cache TTL to take effect
See JWT Validation for full configuration options.
Client Configuration
Agents include the IdP token instead of a Portkey API key:
Or in code:
Validating Claim Values
Validate that tokens are issued by the correct IdP and intended for MCP access:
This prevents:
- Tokens from other IdPs being accepted
- Tokens intended for other services being used for MCP
Combining with Identity Forwarding
External OAuth pairs naturally with identity forwarding. Portkey validates the incoming JWT, extracts user claims, and forwards them to MCP servers.
The MCP server receives user identity without handling OAuth itself. It can use this for:
- Authorization: Check if user belongs to required groups
- Logging: Audit trail with user identity
- Personalization: Customize responses based on user
See Identity Forwarding.
IdP-Specific Examples
Descope
- Create a project in the Descope Console
- Note your Project ID (found in Project Settings)
- Enable DCR, under DCR Settings under Inbound Applications
- Create an authorization server in Okta Admin Console
- Create an OAuth application (Web or SPA)
- Note your issuer URL (e.g.,
https://dev-12345.okta.com/oauth2/default)
- Create an API in Auth0 Dashboard
- Note your tenant domain and API identifier
Azure AD / Entra ID
- Register an application in Azure Portal
- Note your tenant ID and client ID
AWS Cognito
- Create a User Pool in AWS Console
- Note your region and pool ID
Securing Your Setup
Validate Issuer and Audience
Always configure claimValues to verify iss and aud:
Without this, tokens intended for other applications might be accepted.
Require Essential Claims
Require essential claims:
If a claim is missing, the request is rejected.
Use Short Token Lifetimes
Configure the IdP to issue short-lived access tokens (15-60 minutes). This limits the window if a token is compromised.
Troubleshooting
âInvalid issuerâ Error
The tokenâs iss claim doesnât match your configuration. Verify the issuer URL exactly matchesâincluding trailing slashes.
âMissing required claimsâ Error
The token doesnât include claims you specified in requiredClaims. Check your IdPâs token configuration and scopes.
âInvalid audienceâ Error
The tokenâs aud claim doesnât match your configuration. Verify the correct API identifier or client ID.
âJWKS fetch failedâ Error
Portkey couldnât fetch keys from your JWKS URI. Verify the URL is accessible and returns valid JWKS JSON.
Last modified on April 22, 2026