mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-12 16:49:10 +02:00
Adds the PropelAuthProvider which delegates to the IntrospectionTokenVerifier and optionally does an additional resource check. Adds an example server and client which makes an authenticated request and gets information from the token. Updates the documentation (but only for v3 as this isn't in v2). |
||
|---|---|---|
| .. | ||
| client.py | ||
| README.md | ||
| server.py | ||
PropelAuth OAuth Example
Demonstrates FastMCP server protection with PropelAuth OAuth.
Setup
1. Configure MCP Authentication in PropelAuth
Create a PropelAuth Account:
- Go to PropelAuth Dashboard
- Navigate to the MCP section and click Enable MCP
Configure Allowed MCP Clients:
- Under MCP > Allowed MCP Clients, add redirect URIs for each MCP client you want to allow
- PropelAuth provides templates for popular clients like Claude, Cursor, and ChatGPT
Configure Scopes:
- Under MCP > Scopes, define the permissions available to MCP clients (e.g.,
read:user_data)
Generate Introspection Credentials:
- Go to MCP > Request Validation and click Create Credentials
- Note the Client ID and Client Secret
Note Your Auth URL:
- Find your Auth URL in the Backend Integration section (e.g.,
https://auth.yourdomain.com)
Create a .env file:
# Required PropelAuth credentials
PROPELAUTH_AUTH_URL=https://auth.yourdomain.com
PROPELAUTH_INTROSPECTION_CLIENT_ID=your-client-id
PROPELAUTH_INTROSPECTION_CLIENT_SECRET=your-client-secret
BASE_URL=http://localhost:8000/
# Optional: additional scopes tokens must include (comma-separated)
# PROPELAUTH_REQUIRED_SCOPES=read:user_data
2. Run the Example
Start the server:
# From this directory
uv run python server.py
The server will start on http://localhost:8000/mcp with PropelAuth OAuth authentication enabled.
Test with client:
uv run python client.py
The client.py will:
- Attempt to connect to the server
- Detect that OAuth authentication is required
- Open a browser for PropelAuth authentication
- Complete the OAuth flow and connect to the server
- Demonstrate calling authenticated tools (echo and whoami)