From b8484990e42e27da88d84d372559bfb6668e8981 Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Wed, 28 May 2025 15:06:26 +0200 Subject: [PATCH 1/4] Fix indentation and add missing lang in snippet in `README.md` --- README.md | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4c8bb90dc..e8adb7fc8 100644 --- a/README.md +++ b/README.md @@ -317,21 +317,21 @@ Authentication can be used by servers that want to expose tools accessing protec `mcp.server.auth` implements an OAuth 2.0 server interface, which servers can use by providing an implementation of the `OAuthServerProvider` protocol. -``` +```python mcp = FastMCP("My App", - auth_server_provider=MyOAuthServerProvider(), - auth=AuthSettings( - issuer_url="https://myapp.com", - revocation_options=RevocationOptions( - enabled=True, - ), - client_registration_options=ClientRegistrationOptions( - enabled=True, - valid_scopes=["myscope", "myotherscope"], - default_scopes=["myscope"], - ), - required_scopes=["myscope"], + auth_server_provider=MyOAuthServerProvider(), + auth=AuthSettings( + issuer_url="https://myapp.com", + revocation_options=RevocationOptions( + enabled=True, ), + client_registration_options=ClientRegistrationOptions( + enabled=True, + valid_scopes=["myscope", "myotherscope"], + default_scopes=["myscope"], + ), + required_scopes=["myscope"], + ), ) ``` @@ -462,15 +462,12 @@ For low level server with Streamable HTTP implementations, see: - Stateful server: [`examples/servers/simple-streamablehttp/`](examples/servers/simple-streamablehttp/) - Stateless server: [`examples/servers/simple-streamablehttp-stateless/`](examples/servers/simple-streamablehttp-stateless/) - - The streamable HTTP transport supports: - Stateful and stateless operation modes - Resumability with event stores -- JSON or SSE response formats +- JSON or SSE response formats - Better scalability for multi-node deployments - ### Mounting to an Existing ASGI Server > **Note**: SSE transport is being superseded by [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http). From f3db78d9d91bc51124eee44e66d454940a2c093f Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Wed, 28 May 2025 15:15:37 +0200 Subject: [PATCH 2/4] Add missing imports for `OAuthServerProvider` --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e8adb7fc8..807a05901 100644 --- a/README.md +++ b/README.md @@ -318,6 +318,16 @@ Authentication can be used by servers that want to expose tools accessing protec providing an implementation of the `OAuthServerProvider` protocol. ```python +from mcp import FastMCP +from mcp.server.auth.provider import OAuthAuthorizationServerProvider +from mcp.server.auth.settings import AuthSettings, ClientRegistrationOptions, RevocationOptions + + +class MyOAuthServerProvider(OAuthAuthorizationServerProvider): + # See an example on how to implement at `examples/servers/simple-auth` + ... + + mcp = FastMCP("My App", auth_server_provider=MyOAuthServerProvider(), auth=AuthSettings( From 9568c6d2431929d5807d524f89afab67120db4b1 Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Wed, 28 May 2025 15:17:27 +0200 Subject: [PATCH 3/4] Fix references to `OAuthAuthorizationServerProvider` It was being referenced as `OAuthServerProvider` instead of `OAuthAuthorizationServerProvider` which is the actual class name in the codebase --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 807a05901..95d3d0950 100644 --- a/README.md +++ b/README.md @@ -315,7 +315,7 @@ async def long_task(files: list[str], ctx: Context) -> str: Authentication can be used by servers that want to expose tools accessing protected resources. `mcp.server.auth` implements an OAuth 2.0 server interface, which servers can use by -providing an implementation of the `OAuthServerProvider` protocol. +providing an implementation of the `OAuthAuthorizationServerProvider` protocol. ```python from mcp import FastMCP @@ -345,7 +345,7 @@ mcp = FastMCP("My App", ) ``` -See [OAuthServerProvider](src/mcp/server/auth/provider.py) for more details. +See [OAuthAuthorizationServerProvider](src/mcp/server/auth/provider.py) for more details. ## Running Your Server From e8d0d7e9685f8d84e8963abbe797caefdcdbf891 Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Wed, 28 May 2025 15:38:16 +0200 Subject: [PATCH 4/4] Fix style --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 95d3d0950..d76d3d267 100644 --- a/README.md +++ b/README.md @@ -320,7 +320,11 @@ providing an implementation of the `OAuthAuthorizationServerProvider` protocol. ```python from mcp import FastMCP from mcp.server.auth.provider import OAuthAuthorizationServerProvider -from mcp.server.auth.settings import AuthSettings, ClientRegistrationOptions, RevocationOptions +from mcp.server.auth.settings import ( + AuthSettings, + ClientRegistrationOptions, + RevocationOptions, +) class MyOAuthServerProvider(OAuthAuthorizationServerProvider): @@ -328,7 +332,8 @@ class MyOAuthServerProvider(OAuthAuthorizationServerProvider): ... -mcp = FastMCP("My App", +mcp = FastMCP( + "My App", auth_server_provider=MyOAuthServerProvider(), auth=AuthSettings( issuer_url="https://myapp.com",