Quick Start
OAuth Authentication
For servers that support OAuth, you can use Dynamic Client Registration (automatic) or pre-registered clients:Bearer Token Authentication
For servers requiring API keys:Custom Port Configuration
You can specify a custom port for OAuth callbacks to avoid conflicts:Authentication Methods
1. OAuth 2.0 Authentication
OAuth 2.0 is the most common authentication method for MCP servers. mcp-use supports:- Dynamic Client Registration (DCR) - Automatic client registration
- Pre-registered Clients - Using existing OAuth applications
- Custom OAuth Providers - With explicit metadata
Dynamic Client Registration
For servers that support DCR, you don’t need to register a client manually:Pre-registered OAuth Client
For servers requiring manual client registration:OAuth Provider with Metadata
For servers with known OAuth endpoints, provide metadata upfront:2. Bearer Token Authentication
For servers requiring simple API keys or bearer tokens:3. Custom Authentication
For servers requiring custom authentication methods:4. No Authentication
For public servers or servers without authentication:Complete Examples
GitHub MCP Server Example
The GitHub MCP server requires OAuth authentication. You’ll need to create a GitHub OAuth App first:-
Create a GitHub OAuth App:
- Go to GitHub OAuth Apps
- Set Application name:
your-app-name - Set Homepage URL:
http://localhost:8080(or your custom port) - Set Authorization callback URL:
http://localhost:8080/callback(or your custom port) - Click “Register application”
- Copy your Client ID and Client Secret
- Configure mcp-use:
Multi-Server Configuration
You can mix different authentication methods across servers:OAuth Flow Process
When OAuth authentication is required:- Browser Opens: Your default browser opens to the authorization page
- Grant Access: Review and approve the requested permissions
- Automatic Redirect: You’re redirected to a local callback URL
- Token Storage: Access tokens are stored securely in
~/.mcp_use/tokens/
Token Storage
Authentication data is stored securely:- Access Tokens:
~/.mcp_use/tokens/{server_domain}.json - Client Registrations:
~/.mcp_use/tokens/registrations/{server_domain}_registration.json
Configuration Options
OAuth Configuration Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
client_id | string | No* | OAuth client ID (required if not using DCR) |
client_secret | string | No | OAuth client secret (required if not using DCR) |
scope | string | No | OAuth scopes to request |
callback_port | integer | No | Port for OAuth callback (default: 8080) |
oauth_provider | object | No | OAuth provider metadata |
Port Configuration
- Default Port: 8080
- Custom Ports: Any available port (e.g., 8081, 8082, 3000)
- Port Conflicts: mcp-use will check if the port is available before starting OAuth flow
Troubleshooting
Common Issues
OAuth Discovery Fails
If a server doesn’t support OAuth discovery:- Provide an
oauth_providerwith metadata - Use a pre-registered
client_id - Check if the server requires different authentication
”Invalid redirect URI” Error
Solutions:- Use Dynamic Client Registration (omit
client_id) - Register your app with supported redirect URIs
- Check if your provider supports wildcard redirect URIs
- Ensure callback URL matches your OAuth app configuration
Port Already in Use
If you get a port conflict error:GitHub OAuth Issues
For GitHub specifically:- Ensure your OAuth app callback URL matches:
http://localhost:8080/callback(or your custom port) - Use correct scopes:
repo,read:user, etc. - Check that your GitHub OAuth app is properly configured
Debugging
Enable debug logging to see detailed authentication flow:Security Best Practices
- Token Storage: Tokens are stored with restricted permissions
- Version Control: Never commit authentication files to version control
- CSRF Protection: OAuth flow uses state parameter for CSRF protection
- Localhost Callbacks: All callbacks use localhost (127.0.0.1) for security
- Isolation: Each server’s authentication is isolated
- Environment Variables: Use environment variables for sensitive data:
Example Servers that support OAuth
OAuth with DCR Support
- Linear:
https://mcp.linear.app/sse - Asana:
https://mcp.asana.com/sse - Atlassian:
https://mcp.atlassian.com/v1/sse
OAuth with Manual Registration
- GitHub:
https://api.githubcopilot.com/mcp/
Bearer Token
- Most API-based MCP servers