Skip to content

Commit 5424832

Browse files
committed
update docs
1 parent 0f7b167 commit 5424832

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The Model Context Protocol allows applications to provide context for LLMs in a
6666

6767
- Build MCP clients that can connect to any MCP server
6868
- Create MCP servers that expose resources, prompts and tools
69-
- Use standard transports like stdio and SSE
69+
- Use standard transports like stdio, SSE, and Streamable HTTP
7070
- Handle all MCP protocol messages and lifecycle events
7171

7272
## Installation
@@ -387,8 +387,40 @@ python server.py
387387
mcp run server.py
388388
```
389389

390+
### Streamable HTTP Transport
391+
392+
> **Note**: Streamable HTTP transport is superseding SSE transport for production deployments.
393+
394+
```python
395+
from mcp.server.fastmcp import FastMCP
396+
397+
# Stateful server (maintains session state)
398+
mcp = FastMCP("StatefulServer")
399+
400+
# Stateless server (no session persistence)
401+
mcp = FastMCP("StatelessServer", stateless_http=True)
402+
403+
# Run server with streamable_http transport
404+
mcp.run(transport="streamable-http")
405+
```
406+
407+
For low level server with Streamable HTTP implementations, see:
408+
- Stateful server: [`examples/servers/simple-streamablehttp/`](examples/servers/simple-streamablehttp/)
409+
- Stateless server: [`examples/servers/simple-streamablehttp-stateless/`](examples/servers/simple-streamablehttp-stateless/)
410+
411+
412+
413+
The streamable HTTP transport supports:
414+
- Stateful and stateless operation modes
415+
- Resumability with event stores
416+
- JSON or SSE response formats
417+
- Better scalability for multi-node deployments
418+
419+
390420
### Mounting to an Existing ASGI Server
391421

422+
> **Note**: SSE transport is being superseded by streamable HTTP transport. Consider using streamable HTTP for production deployments.
423+
392424
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.
393425

394426
```python
@@ -621,7 +653,7 @@ if __name__ == "__main__":
621653

622654
### Writing MCP Clients
623655

624-
The SDK provides a high-level client interface for connecting to MCP servers:
656+
The SDK provides a high-level client interface for connecting to MCP servers using various transports:
625657

626658
```python
627659
from mcp import ClientSession, StdioServerParameters, types
@@ -685,6 +717,24 @@ if __name__ == "__main__":
685717
asyncio.run(run())
686718
```
687719

720+
Clients can also connect using streamable HTTP transport:
721+
722+
```python
723+
724+
# Connect to a streamable HTTP server
725+
async with streamablehttp_client(http_server_url + "/mcp") as (
726+
read_stream,
727+
write_stream,
728+
_,
729+
):
730+
# Create a session using the client streams
731+
async with ClientSession(read_stream, write_stream) as session:
732+
# Initialize the connection
733+
await session.initialize()
734+
# Call a tool
735+
tool_result = await session.call_tool("echo", {"message": "hello"})
736+
```
737+
688738
### MCP Primitives
689739

690740
The MCP protocol defines three core primitives that servers can implement:

0 commit comments

Comments
 (0)