OAuth Support
At a Glance
- Covers end-to-end OAuth 2.0 Authorization Code with PKCE for upstream MCP servers.
- Supports automatic discovery from
WWW-Authenticateresponses and RFC 8414 metadata. - Implements dynamic client registration (RFC 7591) and resource indicators (RFC 8707).
- Persists client credentials and tokens to
mcp_settings.jsonfor reconnects.
When MCPHub Switches to OAuth
- MCPHub calls an MCP server that requires authorization and receives
401 Unauthorized. - The response exposes a
WWW-Authenticateheader pointing to protected resource metadata (authorization_serveroras_uri). - MCPHub discovers the authorization server metadata, registers (if needed), and opens the browser so the user can authorize once.
- After the callback is handled, MCPHub reconnects with fresh tokens and resumes requests transparently.
MCPHub logs each stage (discovery, registration, authorization URL, token exchange) in the server detail view and the backend logs.
Quick Start by Server Type
Servers with Dynamic Registration Support
Some servers expose complete OAuth metadata and allow dynamic client registration. For example, Vercel and Linear MCP servers only need their SSE endpoint configured:- MCPHub discovers the authorization server, registers the client, and handles PKCE automatically.
- Tokens are stored in
mcp_settings.json; no additional dashboard configuration is needed.
Servers Requiring Manual Client Provisioning
Other providers do not support dynamic registration. GitHub’s MCP endpoint (https://api.githubcopilot.com/mcp/) is one example. To connect:
- Create an OAuth App in the provider’s console (for GitHub, go to Settings → Developer settings → OAuth Apps).
- Set the callback/redirect URL to
http://localhost:3000/oauth/callback(or your deployed dashboard domain). - Copy the issued client ID and client secret.
- Supply the credentials through the MCPHub dashboard or by editing
mcp_settings.jsonas shown below.
- MCPHub skips dynamic registration and uses the credentials you provide to complete the OAuth exchange.
- Update the dashboard or configuration file whenever you rotate secrets.
- Replace
scopeswith the exact scope strings required by the provider.
Configuration Options
You can rely on auto-detection for most servers or declare OAuth settings explicitly inmcp_settings.json. Only populate the fields you need.
Basic Auto Detection (Minimal Config)
- MCPHub will discover the authorization server from challenge headers and walk the user through authorization automatically.
- Tokens (including refresh tokens) are stored on disk and reused on restart.
Static Client Credentials (Bring Your Own Client)
- Use this when the authorization server requires manual client provisioning.
redirectUridefaults tohttp://localhost:3000/oauth/callback; override it when running behind a custom domain.
Dynamic Client Registration (RFC 7591)
- MCPHub discovers endpoints via
issuer, registers itself, and persists the issuedclient_id/client_secret. - Provide
initialAccessTokenonly when the registration endpoint is protected.
Authorization Flow
- Initialization – On startup MCPHub processes every server entry, discovers metadata, and registers the client if
dynamicRegistration.enabledis true. - User Authorization – Initiating a connection launches the system browser to the server’s authorize page with PKCE parameters.
- Callback Handling – The built-in route (
/oauth/callback) verifies thestate, completes the token exchange, and saves the tokens via the MCP SDK. - Token Lifecycle – Access and refresh tokens are cached in memory, refreshed automatically, and written back to
mcp_settings.json.
Tips & Troubleshooting
- Confirm that the redirect URI used during authorization exactly matches one of the
redirect_urisregistered with the authorization server. - When running behind HTTPS, expose the callback URL publicly or configure a reverse proxy at
/oauth/callback. - If discovery fails, supply
authorizationEndpointandtokenEndpointexplicitly to bypass metadata lookup. - Remove stale tokens from
mcp_settings.jsonif an authorization server revokes access—MCPHub will prompt for a fresh login on the next request.