npx mcp-remote
. We recommend you use it as well, and we’ll show our examples using it.
Basic Token Passthrough
If you just want to be able to pass a valid authorization header, without supporting a full authentication flow, you don’t need to do anything special. You just need to make sure your MCP client is sending it:OAuth Flow
FastAPI-MCP supports the full OAuth 2 flow, compliant with MCP Spec 2025-03-26. It would look something like this:Custom OAuth Metadata
If you already have a properly configured OAuth server that works with MCP clients, or if you want full control over the metadata, you can provide your own OAuth metadata directly:- You have a fully MCP-compliant OAuth server already configured
- You need to customize the OAuth flow beyond what the proxy approach offers
- You’re using a custom or specialized OAuth implementation
8080
, and then configure the callback URL to http://127.0.0.1:8080/oauth/callback
in your OAuth provider.
Working Example with Auth0
For a complete working example of OAuth integration with Auth0, check out the Auth0 Example in the examples folder. This example demonstrates the simple case of using Auth0 as an OAuth provider, with a working example of the OAuth flow. For it to work, you need an .env file in the root of the project with the following variables:AuthConfig Explained
setup_proxies=True
Most OAuth providers need some adaptation to work with MCP clients. This is where setup_proxies=True
comes in - it creates proxy endpoints that make your OAuth provider compatible with MCP clients:
Why Use Proxies?
Proxies solve several problems:-
Missing registration endpoints:
The MCP spec expects OAuth providers to support dynamic client registration (RFC 7591), but many don’t. Furthermore, dynamic client registration is probably overkill for most use cases. Thesetup_fake_dynamic_registration
option (True by default) creates a compatible endpoint that just returns a static client ID and secret. -
Scope handling:
Some MCP clients don’t properly request scopes, so our proxy adds the necessary scopes for you. -
Audience requirements:
Some OAuth providers require an audience parameter that MCP clients don’t always provide. The proxy adds this automatically.
Add a fixed port to mcp-remote
8080
, and then configure the callback URL to http://127.0.0.1:8080/oauth/callback
in your OAuth provider.