OAuth Implementation Guide
Overview
This MCP server supports OAuth 2.1 authentication using stateless mode for secure, scalable API access.How It Works
Authentication Flow
- Initial Request: Client sends request without credentials
- OAuth Challenge: Server returns 401 with WWW-Authenticate header
- Token Acquisition: Client obtains OAuth token from authorization server
- Authenticated Request: Client includes token in Authorization header
- Token Validation: Server validates JWT token on each request
Stateless Mode
The server operates in stateless mode (stateless: true
in config), which means:
- No server-side session storage
- Each request is independently authenticated
- Tokens are validated in real-time
- Perfect for horizontal scaling
Authentication Methods
OAuth JWT Token
API Key
Performance Considerations
What Happens on Each Request
- JWT Validation (~5-10ms): Cryptographic signature verification
- Customer Lookup (~20-50ms with cache): BigQuery query for OAuth users
- Total Overhead: ~30-60ms per request with caching
Optimizations
- In-memory caching: Reduces BigQuery lookups
- Preloading: Common queries cached proactively
- Connection pooling: Reuses database connections
Security Benefits
- Real-time validation: Expired tokens rejected immediately
- No session hijacking: No server sessions to compromise
- Token revocation: Works instantly (no cached sessions)
- Audit trail: Every request independently authenticated
Testing OAuth
Use the provided test script:Configuration
The OAuth setup is configured insrc/server.ts
: