Skip to content

Commit 0d6ff1b

Browse files
authored
Add streamable HTTP to Python SDK docs
1 parent 7b1078b commit 0d6ff1b

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,35 @@ The streamable HTTP transport supports:
838838

839839
### Mounting to an Existing ASGI Server
840840

841-
> **Note**: SSE transport is being superseded by [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http).
842-
843841
By default, SSE servers are mounted at `/sse` and Streamable HTTP servers are mounted at `/mcp`. You can customize these paths using the methods described below.
844842

843+
#### Streamable HTTP servers
844+
845+
The following example shows how to use `streamable_http_app()`, a method that returns a `Starlette` application object.
846+
You can then append additional routes to that application as needed.
847+
848+
```
849+
from starlette.routing import Route
850+
851+
mcp = FastMCP("My App")
852+
853+
app = mcp.streamable_http_app()
854+
# Additional non-MCP routes can be added like so:
855+
# app.router.routes.append(Route("/", endpoint=other_route_function))
856+
```
857+
858+
To customize the route from the default of "/mcp", either specify the `streamable_http_path` option for the `FastMCP` constructor,
859+
or set `FASTMCP_STREAMABLE_HTTP_PATH` environment variable.
860+
861+
Note that in Starlette and FastAPI (which is based on Starlette), the "/mcp" route will redirect to "/mcp/",
862+
so you may need to use "/mcp/" when pointing MCP clients at your servers.
863+
864+
For more information on mounting applications in Starlette, see the [Starlette documentation](https://www.starlette.io/routing/#submounting-routes).
865+
866+
#### SSE servers
867+
868+
> **Note**: SSE transport is being superseded by [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http).
869+
845870
You can mount the SSE server to an existing ASGI server using the `sse_app` method. This allows you to integrate the SSE server with other ASGI applications.
846871

847872
```python

0 commit comments

Comments
 (0)