mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2026-01-03 22:14:24 +01:00
Add support for serverside oauth (#255)
Co-authored-by: David Soria Parra <davidsp@anthropic.com> Co-authored-by: Basil Hosmer <basil@anthropic.com> Co-authored-by: ihrpr <inna@anthropic.com>
This commit is contained in:
27
README.md
27
README.md
@@ -309,6 +309,33 @@ async def long_task(files: list[str], ctx: Context) -> str:
|
||||
return "Processing complete"
|
||||
```
|
||||
|
||||
### Authentication
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
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"],
|
||||
),
|
||||
)
|
||||
```
|
||||
|
||||
See [OAuthServerProvider](mcp/server/auth/provider.py) for more details.
|
||||
|
||||
## Running Your Server
|
||||
|
||||
### Development Mode
|
||||
|
||||
Reference in New Issue
Block a user