When to Use
Custom auth is for MCP servers where:- Authentication uses API keys instead of OAuth
- Internal servers use static tokens
- The server expects specific headers for authorization
- You want shared credentials (all users use the same authentication)
Static Headers
Configure headers that Portkey includes with every request to the MCP server.Common Patterns
Bearer token:Passthrough Headers
Add static metadata headers separate from authentication:- API versioning
- Client identification
- Metadata the server expects
Header Merge Order
When multiple header sources are configured, they merge in this order (later values override earlier):| Priority | Source | Description |
|---|---|---|
| 1 (lowest) | Forwarded headers | Headers from agent requests (via forward_headers) |
| 2 | Auth headers | headers configured on the MCP server |
| 3 | Passthrough headers | passthrough_headers configured on the server |
| 4 (highest) | Identity headers | Headers from identity forwarding |
- Auth headers override anything forwarded from agents
- Passthrough headers override auth headers if there’s a conflict
- Identity headers always win (prevents spoofing)
X-Custom: auth-value (auth headers take precedence).
Combining with Forwarded Headers
Combine static headers with forwarded headers:Authorization: Bearer api_key_xxx(authentication)X-API-Version: v2(static metadata)x-request-idandx-trace-id(from agent, if provided)
- Shared authentication to the MCP server
- Distributed tracing from agents
- Consistent API versioning
Complete Configuration Example
Full server configuration combining all header features:| Header | Source | Value |
|---|---|---|
Authorization | Auth headers | Bearer sk_live_xxx |
X-API-Version | Passthrough | 2024-01 |
X-Client-ID | Passthrough | portkey-mcp-gateway |
x-request-id | Forwarded | From agent request |
x-correlation-id | Forwarded | From agent request |
x-tenant-id | Forwarded | From agent request |
X-User-Claims | Identity | JSON with user claims |
When to Use Shared Credentials
Shared credentials make sense when:- The MCP server provides shared resources (knowledge bases, analytics)
- All users should see the same data
- You don’t need per-user attribution at the MCP server level
- The external service doesn’t support per-user OAuth
- Users access personal data (email, messages, private repos)
- Actions need attribution to individual users
- The MCP server enforces per-user permissions
Security Considerations
Credential Storage
Headers configured in the MCP Registry are stored encrypted. They’re never exposed to agents or included in logs.Credential Isolation
Rotation
To rotate MCP server credentials:- Generate new credentials with the MCP server
- Update the headers in Portkey’s MCP Registry
- Old credentials can be revoked immediately
Related
| Topic | Description |
|---|---|
| Forwarding Headers | Pass headers from agents to MCP servers |
| Identity Forwarding | Pass user identity to MCP servers |
| Authentication Overview | Understanding gateway authentication |

