mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-20 07:14:24 +01:00
Fix and update OAuthAuthorizationServerProvider snippet in README.md (#830)
This commit is contained in:
26
README.md
26
README.md
@@ -315,10 +315,25 @@ async def long_task(files: list[str], ctx: Context) -> str:
|
|||||||
Authentication can be used by servers that want to expose tools accessing protected resources.
|
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
|
`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
|
||||||
mcp = FastMCP("My App",
|
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_server_provider=MyOAuthServerProvider(),
|
||||||
auth=AuthSettings(
|
auth=AuthSettings(
|
||||||
issuer_url="https://myapp.com",
|
issuer_url="https://myapp.com",
|
||||||
@@ -335,7 +350,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
|
## Running Your Server
|
||||||
|
|
||||||
@@ -462,15 +477,12 @@ For low level server with Streamable HTTP implementations, see:
|
|||||||
- Stateful server: [`examples/servers/simple-streamablehttp/`](examples/servers/simple-streamablehttp/)
|
- Stateful server: [`examples/servers/simple-streamablehttp/`](examples/servers/simple-streamablehttp/)
|
||||||
- Stateless server: [`examples/servers/simple-streamablehttp-stateless/`](examples/servers/simple-streamablehttp-stateless/)
|
- Stateless server: [`examples/servers/simple-streamablehttp-stateless/`](examples/servers/simple-streamablehttp-stateless/)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The streamable HTTP transport supports:
|
The streamable HTTP transport supports:
|
||||||
- Stateful and stateless operation modes
|
- Stateful and stateless operation modes
|
||||||
- Resumability with event stores
|
- Resumability with event stores
|
||||||
- JSON or SSE response formats
|
- JSON or SSE response formats
|
||||||
- Better scalability for multi-node deployments
|
- Better scalability for multi-node deployments
|
||||||
|
|
||||||
|
|
||||||
### Mounting to an Existing ASGI Server
|
### 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).
|
> **Note**: SSE transport is being superseded by [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http).
|
||||||
|
|||||||
Reference in New Issue
Block a user