Overview
MCP servers can require authentication to protect resources and control access.mcp-use handles authentication automatically based on your configuration.
Choose Your Method
Bearer Token
Simplest optionUse a static API key or token. Best for services that issue long-lived credentials.
OAuth 2.1
MCP standardFull OAuth flow with automatic discovery, PKCE, and token refresh. Required by many MCP servers.
Custom Auth
Full controlUse any
httpx.Auth object for Basic, Digest, or custom authentication schemes.Quick Start Examples
- OAuth (Auto)
- OAuth (Pre-registered)
- Bearer Token
- No Auth
For servers with OAuth support, just provide the URL:
mcp-use will:- Discover the authorization server
- Register a client (or use CIMD/pre-registered credentials)
- Open your browser for authorization
- Store and refresh tokens automatically
Token Storage
Authentication tokens are stored securely on disk:Debugging
Enable verbose logging to troubleshoot authentication:Security Best Practices
- Environment variables - Never hardcode credentials in source code
- Token rotation - Rotate long-lived tokens regularly
- Minimal scopes - Request only the permissions you need
- HTTPS only - All OAuth endpoints use HTTPS (except localhost callbacks)