mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-27 07:50:43 +02:00
* Add Auth0MCPProvider for Auth0 Auth for MCP * Document Auth0 MCP provider integration * Add Auth0MCPProvider scope and auth rejection tests Cover permissions-based required_scopes enforcement and unauthenticated MCP 401 responses. * fixed documentation * Narrow Auth0 docs to integration guide only * Fix Auth0 provider: use httpx2 instead of httpx httpx is a dev-only transitive dependency in this repo; runtime installs declare httpx2 exclusively. The module-level 'import httpx' in auth0.py broke import on a clean install of fastmcp or fastmcp-slim[server]. --------- Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com>
28 lines
1 KiB
Markdown
28 lines
1 KiB
Markdown
# Auth0 Auth for MCP Example
|
|
|
|
Protects a FastMCP server with Auth0 [Auth for MCP](https://auth0.com/ai/docs/mcp/intro/overview). Auth0 handles OAuth and client registration; FastMCP validates access tokens.
|
|
|
|
## Auth0 setup
|
|
|
|
1. Enable **Resource Parameter Compatibility Profile** (Settings → Advanced).
|
|
2. Create an API whose identifier is `http://127.0.0.1:8000/mcp` (must match the URL logged at server startup).
|
|
3. Promote your login connections to domain-level (required for third-party DCR clients).
|
|
|
|
See Auth0's [authorization quickstart](https://auth0.com/ai/docs/mcp/get-started/authorization-for-your-mcp-server) for details.
|
|
|
|
## Running
|
|
|
|
```bash
|
|
export AUTH0_CONFIG_URL="https://YOUR_TENANT.auth0.com/.well-known/openid-configuration"
|
|
python server.py
|
|
```
|
|
|
|
In another terminal:
|
|
|
|
```bash
|
|
python client.py
|
|
```
|
|
|
|
Use `127.0.0.1` consistently — mixing `localhost` and `127.0.0.1` breaks audience validation.
|
|
|
|
For troubleshooting (DCR grants, token exchange errors, MCP Inspector), see the [Auth0 integration guide](https://gofastmcp.com/integrations/auth0).
|