refactor: move streamable HTTP app creation from FastMCP to lowlevel Server (#1899)
This commit is contained in:
parent
0f9a41d777
commit
34e66a3812
1 changed files with 189 additions and 122 deletions
|
|
@ -282,7 +282,29 @@ The `ClientSession.read_resource()`, `subscribe_resource()`, and `unsubscribe_re
|
|||
|
||||
## New Features
|
||||
|
||||
<!-- Add new features below -->
|
||||
### `streamable_http_app()` available on lowlevel Server
|
||||
|
||||
The `streamable_http_app()` method is now available directly on the lowlevel `Server` class, not just `FastMCP`. This allows using the streamable HTTP transport without the FastMCP wrapper.
|
||||
|
||||
```python
|
||||
from mcp.server.lowlevel.server import Server
|
||||
|
||||
server = Server("my-server")
|
||||
|
||||
# Register handlers...
|
||||
@server.list_tools()
|
||||
async def list_tools():
|
||||
return [...]
|
||||
|
||||
# Create a Starlette app for streamable HTTP
|
||||
app = server.streamable_http_app(
|
||||
streamable_http_path="/mcp",
|
||||
json_response=False,
|
||||
stateless_http=False,
|
||||
)
|
||||
```
|
||||
|
||||
The lowlevel `Server` also now exposes a `session_manager` property to access the `StreamableHTTPSessionManager` after calling `streamable_http_app()`.
|
||||
|
||||
## Need Help?
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue