MCPServer; mcp-use then attaches authenticated user data to tool context.
This guide helps you choose the right authentication path. Use the auth providers API reference for exact provider options, defaults, return shapes, and verification behavior.
Choose an authentication path
Most MCP servers should use a Dynamic Client Registration provider. Use OAuth Proxy only when the upstream identity provider cannot register MCP clients dynamically.
With a Dynamic Client Registration provider, clients register directly with the upstream identity provider. Your MCP server exposes discovery metadata and verifies bearer tokens. It does not handle the authorization code or token exchange.
With OAuth Proxy, your MCP server mediates authorization and token exchange because the upstream provider cannot register each MCP client itself.
Start with a built-in provider
Choose the provider that matches your identity system:- Auth0: Auth0 OAuth with Dynamic Client Registration.
- Better Auth: Self-hosted OAuth with Better Auth’s OAuth Provider plugin.
- Clerk: Clerk OAuth with user and organization claims.
- Keycloak: Keycloak realm authentication with role mapping.
- Supabase: Supabase OAuth 2.1 server authentication.
- WorkOS: WorkOS AuthKit authentication with organization context.
- Custom Provider: Any DCR-capable OAuth provider with custom token verification.
Configure the server
Pass the selected provider toMCPServer.
Protect tools with user context
When OAuth is configured and the request is authenticated, tools can readctx.auth.
What authentication changes
Whenoauth is configured:
- MCP discovery endpoints advertise OAuth metadata.
- MCP transport endpoints, including
/mcp/*, requireAuthorization: Bearer <token>. - Invalid, expired, or unverifiable tokens are rejected before tool code runs.
- Tool callbacks receive authenticated user data on
ctx.auth.
Next steps
User Context
Read identity, scopes, roles, and permissions inside tools.
Auth providers API reference
Look up exact provider options, defaults, and verification behavior.
Client Authentication
Connect a TypeScript MCP client to an OAuth-protected server.
OAuth Proxy
Bridge providers that do not support Dynamic Client Registration.