@@ -315,27 +315,42 @@ async def long_task(files: list[str], ctx: Context) -> str:
315
315
Authentication can be used by servers that want to expose tools accessing protected resources.
316
316
317
317
` mcp.server.auth ` implements an OAuth 2.0 server interface, which servers can use by
318
- providing an implementation of the ` OAuthServerProvider ` protocol.
318
+ providing an implementation of the ` OAuthAuthorizationServerProvider ` protocol.
319
319
320
- ```
321
- mcp = FastMCP("My App",
322
- auth_server_provider=MyOAuthServerProvider(),
323
- auth=AuthSettings(
324
- issuer_url="https://myapp.com",
325
- revocation_options=RevocationOptions(
326
- enabled=True,
327
- ),
328
- client_registration_options=ClientRegistrationOptions(
329
- enabled=True,
330
- valid_scopes=["myscope", "myotherscope"],
331
- default_scopes=["myscope"],
332
- ),
333
- required_scopes=["myscope"],
320
+ ``` python
321
+ from mcp import FastMCP
322
+ from mcp.server.auth.provider import OAuthAuthorizationServerProvider
323
+ from mcp.server.auth.settings import (
324
+ AuthSettings,
325
+ ClientRegistrationOptions,
326
+ RevocationOptions,
327
+ )
328
+
329
+
330
+ class MyOAuthServerProvider (OAuthAuthorizationServerProvider ):
331
+ # See an example on how to implement at `examples/servers/simple-auth`
332
+ ...
333
+
334
+
335
+ mcp = FastMCP(
336
+ " My App" ,
337
+ auth_server_provider = MyOAuthServerProvider(),
338
+ auth = AuthSettings(
339
+ issuer_url = " https://myapp.com" ,
340
+ revocation_options = RevocationOptions(
341
+ enabled = True ,
342
+ ),
343
+ client_registration_options = ClientRegistrationOptions(
344
+ enabled = True ,
345
+ valid_scopes = [" myscope" , " myotherscope" ],
346
+ default_scopes = [" myscope" ],
334
347
),
348
+ required_scopes = [" myscope" ],
349
+ ),
335
350
)
336
351
```
337
352
338
- See [ OAuthServerProvider ] ( src/mcp/server/auth/provider.py ) for more details.
353
+ See [ OAuthAuthorizationServerProvider ] ( src/mcp/server/auth/provider.py ) for more details.
339
354
340
355
## Running Your Server
341
356
@@ -462,15 +477,12 @@ For low level server with Streamable HTTP implementations, see:
462
477
- Stateful server: [ ` examples/servers/simple-streamablehttp/ ` ] ( examples/servers/simple-streamablehttp/ )
463
478
- Stateless server: [ ` examples/servers/simple-streamablehttp-stateless/ ` ] ( examples/servers/simple-streamablehttp-stateless/ )
464
479
465
-
466
-
467
480
The streamable HTTP transport supports:
468
481
- Stateful and stateless operation modes
469
482
- Resumability with event stores
470
- - JSON or SSE response formats
483
+ - JSON or SSE response formats
471
484
- Better scalability for multi-node deployments
472
485
473
-
474
486
### Mounting to an Existing ASGI Server
475
487
476
488
> ** Note** : SSE transport is being superseded by [ Streamable HTTP transport] ( https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http ) .
0 commit comments