Overview
Secure MCP Gateway provides comprehensive OAuth 2.0 and 2.1 support for authenticating with remote MCP servers. This includes client credentials flow, mutual TLS (mTLS), automatic token management, and secure token caching.Supported Features
OAuth 2.0 & 2.1
Client Credentials
Mutual TLS (mTLS)
Token Caching
Token Revocation
Scope Validation
Retry Logic
Metrics & Monitoring
Quick Start
Basic OAuth 2.1 Setup
Obtain OAuth Credentials
Add Server with OAuth
Configure OAuth
~/.enkrypt/enkrypt_mcp_config.json and add OAuth config:Test Connection
Configuration Reference
Minimal Configuration
Complete Configuration
Configuration Fields
Core Settings
enabled: true
Server Detection
npx, mcp-remote, curl, or http(s):// in command/args. Set is_remote: true explicitly to avoid false detection.Scope & Audience
Security Settings
Token Management
Token Acquired
expires_in: 3600 (1 hour)Cached with Expiry
expires_at timestampProactive Refresh
expires_at - 300s < now (5 min before expiry)Automatic Retry
Mutual TLS (mTLS)
What is mTLS?
Mutual TLS provides enhanced security by requiring both client and server to present certificates during the TLS handshake. This is specified in RFC 8705.Setting Up mTLS
Generate Client Certificate
Upload Certificate to OAuth Provider
Configure Gateway
Test Connection
Token Injection
For Remote Servers
Tokens are automatically injected as HTTP headers:is_remote: true.
For Local Servers
Tokens are injected as environment variables:Provider-Specific Examples
Auth0
Okta
Keycloak
GitHub Apps (mTLS)
Monitoring & Troubleshooting
Enable Debug Logging
Common Errors
Invalid Credentials
Invalid Credentials
OAUTH_CLIENT_ID and OAUTH_CLIENT_SECRET are correctHTTPS Required
HTTPS Required
https:// URL or set OAUTH_VERSION: "2.0"Certificate Not Found
Certificate Not Found
chmod 600)Scope Validation Failed
Scope Validation Failed
OAUTH_VALIDATE_SCOPES: falseNetwork Errors (Auto-Retry)
Network Errors (Auto-Retry)
Viewing Metrics
OAuth metrics are available programmatically:Security Best Practices
Use OAuth 2.1
Enable HTTPS
Use Basic Auth
client_secret_basic over client_secret_postValidate Scopes
Enable mTLS
Rotate Secrets
Minimal Scopes
Secure Storage
Security Checklist
HTTPS Enforced
OAUTH_ENFORCE_HTTPS: true for productionScope Validation Enabled
OAUTH_VALIDATE_SCOPES: trueCredentials Not Committed
.enkrypt/ to .gitignoreCertificates Secured
chmod 600 on all certificate filesDifferent Creds per Environment
Monitoring Enabled
Advanced Topics
Token Revocation
Revoke tokens programmatically:Force Token Refresh
Invalidate Cached Token
FAQ
How do I know if my server is remote?
How do I know if my server is remote?
is_remote: true explicitly in oauth_config. Auto-detection checks for npx, mcp-remote, curl, or http(s):// in command/args.Do tokens work with stdio MCP servers?
Do tokens work with stdio MCP servers?
How often are tokens refreshed?
How often are tokens refreshed?
OAUTH_TOKEN_EXPIRY_BUFFER.Can I use OAuth without mTLS?
Can I use OAuth without mTLS?
What happens if token acquisition fails?
What happens if token acquisition fails?