From 587a443ce20a305a6cd5a4488e57cef4d4253edd Mon Sep 17 00:00:00 2001 From: Felipe Cestari <34042032+fcestari@users.noreply.github.com> Date: Fri, 2 May 2025 19:23:34 +0200 Subject: [PATCH 1/3] Update README's auth block - Add auth to TOC - Specify python for code block highlighting - Format auth example --- README.md | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3889dc40b0..753326441a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ - [Prompts](#prompts) - [Images](#images) - [Context](#context) + - [Authentication](#authentication) - [Running Your Server](#running-your-server) - [Development Mode](#development-mode) - [Claude Desktop Integration](#claude-desktop-integration) @@ -316,21 +317,29 @@ 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. -``` -mcp = FastMCP("My App", - auth_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"], +```python +from mcp.server.auth.settings import ( + AuthSettings, + ClientRegistrationOptions, + RevocationOptions, +) +from mcp.server.fastmcp import FastMCP + +mcp = FastMCP( + "My App", + auth_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"], + ), ) ``` From 50732586141f8a9c8d59ba3612b75682c2e95487 Mon Sep 17 00:00:00 2001 From: Felipe Cestari <34042032+fcestari@users.noreply.github.com> Date: Thu, 15 May 2025 22:40:55 +0200 Subject: [PATCH 2/3] Fix auth_provider typo Co-authored-by: ihrpr --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d4bff8678..da9263ead9 100644 --- a/README.md +++ b/README.md @@ -327,7 +327,7 @@ from mcp.server.fastmcp import FastMCP mcp = FastMCP( "My App", - auth_provider=MyOAuthServerProvider(), + auth_server_provider=MyOAuthServerProvider(), auth=AuthSettings( issuer_url="https://myapp.com", revocation_options=RevocationOptions( From 2764e72d2bdbcf27537bea4f8a1e97fde1f556e3 Mon Sep 17 00:00:00 2001 From: Felipe Cestari <34042032+fcestari@users.noreply.github.com> Date: Thu, 15 May 2025 21:05:02 +0000 Subject: [PATCH 3/3] Re-add imports and run ruff --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cb96de8ffa..b3a0b90fa5 100644 --- a/README.md +++ b/README.md @@ -318,7 +318,16 @@ Authentication can be used by servers that want to expose tools accessing protec providing an implementation of the `OAuthServerProvider` protocol. ```python -mcp = FastMCP("My App", +from mcp.server.auth.settings import ( + AuthSettings, + ClientRegistrationOptions, + RevocationOptions, +) +from mcp.server.fastmcp import FastMCP + +mcp = ( + FastMCP( + "My App", auth_server_provider=MyOAuthServerProvider(), auth=AuthSettings( issuer_url="https://myapp.com",