Skip to content

Commit b3ea6ad

Browse files
authored
docs: update OAuth and OIDC proxy documentation (#1880)
1 parent 7176d4f commit b3ea6ad

2 files changed

Lines changed: 89 additions & 49 deletions

File tree

docs/servers/auth/oauth-proxy.mdx

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ MCP clients expect to register automatically and obtain credentials on the fly,
1616

1717
This approach enables any MCP client (whether using random localhost ports or fixed URLs like Claude.ai) to authenticate with any traditional OAuth provider, all while maintaining full OAuth 2.1 and PKCE security.
1818

19+
<Note>
20+
For providers that support OIDC discovery (Auth0, Google with OIDC
21+
configuration, Azure AD), consider using [`OIDC
22+
Proxy`](/servers/auth/oidc-proxy) for automatic configuration. OIDC Proxy
23+
extends OAuth Proxy to automatically discover endpoints from the provider's
24+
`/.well-known/openid-configuration` URL, simplifying setup.
25+
</Note>
26+
1927
## Implementation
2028

2129
### Provider Setup Requirements
@@ -24,7 +32,7 @@ Before using OAuth Proxy, you need to register your application with your OAuth
2432

2533
1. **Register your application** in the provider's developer console (GitHub Settings, Google Cloud Console, Azure Portal, etc.)
2634
2. **Configure the redirect URI** as your FastMCP server URL plus your chosen callback path:
27-
- Default: `https://your-server.com/auth/callback`
35+
- Default: `https://your-server.com/auth/callback`
2836
- Custom: `https://your-server.com/your/custom/path` (if you set `redirect_path`)
2937
- Development: `http://localhost:8000/auth/callback`
3038
3. **Obtain your credentials**: Client ID and Client Secret
@@ -68,7 +76,7 @@ auth = OAuthProxy(
6876

6977
# Your FastMCP server's public URL
7078
base_url="https://your-server.com",
71-
79+
7280
# Optional: customize the callback path (default is "/auth/callback")
7381
# redirect_path="/custom/callback",
7482
)
@@ -84,7 +92,8 @@ mcp = FastMCP(name="My Server", auth=auth)
8492
</ParamField>
8593

8694
<ParamField body="upstream_token_endpoint" type="str" required>
87-
URL of your OAuth provider's token endpoint (e.g., `https://github.com/login/oauth/access_token`)
95+
URL of your OAuth provider's token endpoint (e.g.,
96+
`https://github.com/login/oauth/access_token`)
8897
</ParamField>
8998

9099
<ParamField body="upstream_client_id" type="str" required>
@@ -96,15 +105,17 @@ mcp = FastMCP(name="My Server", auth=auth)
96105
</ParamField>
97106

98107
<ParamField body="token_verifier" type="TokenVerifier" required>
99-
A [`TokenVerifier`](/servers/auth/token-verification) instance to validate the provider's tokens
108+
A [`TokenVerifier`](/servers/auth/token-verification) instance to validate the
109+
provider's tokens
100110
</ParamField>
101111

102112
<ParamField body="base_url" type="AnyHttpUrl | str" required>
103113
Public URL of your FastMCP server (e.g., `https://your-server.com`)
104114
</ParamField>
105115

106116
<ParamField body="redirect_path" type="str" default="/auth/callback">
107-
Path for OAuth callbacks. Must match the redirect URI configured in your OAuth application
117+
Path for OAuth callbacks. Must match the redirect URI configured in your OAuth
118+
application
108119
</ParamField>
109120

110121
<ParamField body="upstream_revocation_endpoint" type="str | None">
@@ -120,32 +131,39 @@ mcp = FastMCP(name="My Server", auth=auth)
120131
</ParamField>
121132

122133
<ParamField body="forward_pkce" type="bool" default="True">
123-
Whether to forward PKCE (Proof Key for Code Exchange) to the upstream OAuth provider. When enabled and the client uses PKCE, the proxy generates its own PKCE parameters to send upstream while separately validating the client's PKCE. This ensures end-to-end PKCE security at both layers (client-to-proxy and proxy-to-upstream).
124-
- `True` (default): Forward PKCE for providers that support it (Google, Azure, GitHub, etc.)
125-
- `False`: Disable only if upstream provider doesn't support PKCE
134+
Whether to forward PKCE (Proof Key for Code Exchange) to the upstream OAuth
135+
provider. When enabled and the client uses PKCE, the proxy generates its own
136+
PKCE parameters to send upstream while separately validating the client's
137+
PKCE. This ensures end-to-end PKCE security at both layers (client-to-proxy
138+
and proxy-to-upstream). - `True` (default): Forward PKCE for providers that
139+
support it (Google, Azure, GitHub, etc.) - `False`: Disable only if upstream
140+
provider doesn't support PKCE
126141
</ParamField>
127142

128143
<ParamField body="token_endpoint_auth_method" type="str | None">
129-
Token endpoint authentication method for the upstream OAuth server. Controls how the proxy authenticates when exchanging authorization codes and refresh tokens with the upstream provider.
130-
- `"client_secret_basic"`: Send credentials in Authorization header (most common)
131-
- `"client_secret_post"`: Send credentials in request body (required by some providers)
132-
- `"none"`: No authentication (for public clients)
133-
- `None` (default): Uses authlib's default (typically `"client_secret_basic"`)
134-
135-
Set this if your provider requires a specific authentication method and the default doesn't work.
144+
Token endpoint authentication method for the upstream OAuth server. Controls
145+
how the proxy authenticates when exchanging authorization codes and refresh
146+
tokens with the upstream provider. - `"client_secret_basic"`: Send credentials
147+
in Authorization header (most common) - `"client_secret_post"`: Send
148+
credentials in request body (required by some providers) - `"none"`: No
149+
authentication (for public clients) - `None` (default): Uses authlib's default
150+
(typically `"client_secret_basic"`) Set this if your provider requires a
151+
specific authentication method and the default doesn't work.
136152
</ParamField>
137153

138154
<ParamField body="allowed_client_redirect_uris" type="list[str] | None">
139-
List of allowed redirect URI patterns for MCP clients. Patterns support wildcards (e.g., `"http://localhost:*"`, `"https://*.example.com/*"`).
140-
- `None` (default): All redirect URIs allowed (for MCP/DCR compatibility)
141-
- Empty list `[]`: No redirect URIs allowed
142-
- Custom list: Only matching patterns allowed
143-
144-
These patterns apply to MCP client loopback redirects, NOT the upstream OAuth app redirect URI.
155+
List of allowed redirect URI patterns for MCP clients. Patterns support
156+
wildcards (e.g., `"http://localhost:*"`, `"https://*.example.com/*"`). -
157+
`None` (default): All redirect URIs allowed (for MCP/DCR compatibility) -
158+
Empty list `[]`: No redirect URIs allowed - Custom list: Only matching
159+
patterns allowed These patterns apply to MCP client loopback redirects, NOT
160+
the upstream OAuth app redirect URI.
145161
</ParamField>
146162

147163
<ParamField body="valid_scopes" type="list[str] | None">
148-
List of all possible valid scopes for the OAuth provider. These are advertised to clients through the `/.well-known` endpoints. Defaults to `required_scopes` from your TokenVerifier if not specified.
164+
List of all possible valid scopes for the OAuth provider. These are advertised
165+
to clients through the `/.well-known` endpoints. Defaults to `required_scopes`
166+
from your TokenVerifier if not specified.
149167
</ParamField>
150168

151169
<ParamField body="extra_authorize_params" type="dict[str, str] | None">
@@ -162,23 +180,26 @@ mcp = FastMCP(name="My Server", auth=auth)
162180
<ParamField body="extra_token_params" type="dict[str, str] | None">
163181
Additional parameters to forward to the upstream token endpoint during code exchange and token refresh. Useful for provider-specific requirements during token operations.
164182

165-
For example, some providers require additional context during token exchange:
166-
```python
167-
extra_token_params={"audience": "https://api.example.com"}
168-
```
183+
For example, some providers require additional context during token exchange:
184+
185+
```python
186+
extra_token_params={"audience": "https://api.example.com"}
187+
```
188+
189+
These parameters are included in all token requests to the upstream provider.
169190

170-
These parameters are included in all token requests to the upstream provider.
171191
</ParamField>
172192

173193
<ParamField body="client_storage" type="KVStorage | None">
174194
Storage backend for persisting OAuth client registrations. By default, clients are automatically persisted to disk in `~/.config/fastmcp/oauth-proxy-clients/`, allowing them to survive server restarts as long as the filesystem remains accessible. This means MCP clients only need to register once and can reconnect seamlessly after your server restarts.
175195

176-
```python
177-
from fastmcp.utilities.storage import InMemoryStorage
196+
```python
197+
from fastmcp.utilities.storage import InMemoryStorage
198+
199+
# Use in-memory storage for testing (clients lost on restart)
200+
auth = OAuthProxy(..., client_storage=InMemoryStorage())
201+
```
178202

179-
# Use in-memory storage for testing (clients lost on restart)
180-
auth = OAuthProxy(..., client_storage=InMemoryStorage())
181-
```
182203
</ParamField>
183204
</Card>
184205

@@ -196,21 +217,21 @@ auth = OAuthProxy(
196217
upstream_token_endpoint="https://your-domain.auth0.com/oauth/token",
197218
upstream_client_id="your-auth0-client-id",
198219
upstream_client_secret="your-auth0-client-secret",
199-
220+
200221
# Auth0 requires audience for JWT tokens
201222
extra_authorize_params={
202223
"audience": "https://your-api-identifier.com"
203224
},
204225
extra_token_params={
205-
"audience": "https://your-api-identifier.com"
226+
"audience": "https://your-api-identifier.com"
206227
},
207-
228+
208229
token_verifier=JWTVerifier(
209230
jwks_uri="https://your-domain.auth0.com/.well-known/jwks.json",
210231
issuer="https://your-domain.auth0.com/",
211232
audience="https://your-api-identifier.com"
212233
),
213-
234+
214235
base_url="https://your-server.com"
215236
)
216237
```

docs/servers/auth/oidc-proxy.mdx

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,28 +79,33 @@ mcp = FastMCP(name="My Server", auth=auth)
7979
Public URL of your FastMCP server (e.g., `https://your-server.com`)
8080
</ParamField>
8181

82-
<ParamField body="strict" type="str">
83-
Strict flag for configuration validation
82+
<ParamField body="strict" type="bool | None">
83+
Strict flag for configuration validation. When True, requires all OIDC
84+
mandatory fields.
8485
</ParamField>
8586

86-
<ParamField body="audience" type="str">
87-
Audience from your registered OAuth application
87+
<ParamField body="audience" type="str | None">
88+
Audience parameter for OIDC providers that require it (e.g., Auth0). This is
89+
typically your API identifier.
8890
</ParamField>
8991

90-
<ParamField body="timeout_seconds" type="str">
91-
HTTP request timeout in seconds
92+
<ParamField body="timeout_seconds" type="int | None" default="10">
93+
HTTP request timeout in seconds for fetching OIDC configuration
9294
</ParamField>
9395

94-
<ParamField body="algorithm" type="str">
95-
The algorithm for the token verifier
96+
<ParamField body="algorithm" type="str | None">
97+
JWT algorithm to use for token verification (e.g., "RS256"). If not specified,
98+
uses the provider's default.
9699
</ParamField>
97100

98-
<ParamField body="required_scopes" type="str">
99-
The required scopes for the token verifier
101+
<ParamField body="required_scopes" type="list[str] | None">
102+
List of OAuth scopes to request from the provider. These are automatically
103+
included in authorization requests.
100104
</ParamField>
101105

102106
<ParamField body="redirect_path" type="str" default="/auth/callback">
103-
Path for OAuth callbacks. Must match the redirect URI configured in your OAuth application
107+
Path for OAuth callbacks. Must match the redirect URI configured in your OAuth
108+
application
104109
</ParamField>
105110

106111
<ParamField body="allowed_client_redirect_uris" type="list[str] | None">
@@ -109,7 +114,8 @@ mcp = FastMCP(name="My Server", auth=auth)
109114
- Empty list `[]`: No redirect URIs allowed
110115
- Custom list: Only matching patterns allowed
111116

112-
These patterns apply to MCP client loopback redirects, NOT the upstream OAuth app redirect URI.
117+
These patterns apply to MCP client loopback redirects, NOT the upstream OAuth app redirect URI.
118+
113119
</ParamField>
114120

115121
<ParamField body="token_endpoint_auth_method" type="str | None">
@@ -119,7 +125,20 @@ mcp = FastMCP(name="My Server", auth=auth)
119125
- `"none"`: No authentication (for public clients)
120126
- `None` (default): Uses authlib's default (typically `"client_secret_basic"`)
121127

122-
Set this if your provider requires a specific authentication method and the default doesn't work.
128+
Set this if your provider requires a specific authentication method and the default doesn't work.
129+
130+
</ParamField>
131+
132+
<ParamField body="client_storage" type="KVStorage | None">
133+
Storage backend for persisting OAuth client registrations. By default, clients are automatically persisted to disk in `~/.config/fastmcp/oidc-proxy-clients/`, allowing them to survive server restarts as long as the filesystem remains accessible. This means MCP clients only need to register once and can reconnect seamlessly after your server restarts.
134+
135+
```python
136+
from fastmcp.utilities.storage import InMemoryStorage
137+
138+
# Use in-memory storage for testing (clients lost on restart)
139+
auth = OIDCProxy(..., client_storage=InMemoryStorage())
140+
```
141+
123142
</ParamField>
124143
</Card>
125144

0 commit comments

Comments
 (0)