You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support MCP client communication with servers over Streamable HTTP transport #46
Description:
Currently, the Python MCP client example demonstrates communication with an MCP server via the STDIO transport. However, MCP also defines a streamable-http transport type that enables communication over HTTP with streaming capabilities.
It would be valuable to have an example or feature in this repository that shows how to implement a client communicating with an MCP server using streamable-http. This would help developers understand how to:
Initialize and configure the client for HTTP-based streaming communication
Handle request/response cycles and event streams over HTTP
Compare differences in setup and behavior between STDIO and streamable-http transports
Providing this example would make the quick start resources more complete and allow developers to experiment with both major transport types defined in MCP.
Thanks for the detailed write-up — this is a well-scoped gap. The SDK already ships mcp.client.streamable_http.streamablehttp_client and the server side has examples under examples/servers/simple-streamablehttp-stateless/, but there's no matching client snippet to pair with it. Here's a PR-ready fix.
What's added
Two new files under examples/:
File
Role
examples/server_streamable_http.py
FastMCP server that starts with transport="streamable-http" (mirrors fastmcp_quickstart.py)
examples/client_streamable_http.py
Client that uses streamablehttp_client to list tools/resources/prompts and call a tool
Key differences vs. the stdio client
# ── STDIO (existing example) ──────────────────────────────────────────────frommcpimportClientSession, StdioServerParametersfrommcp.client.stdioimportstdio_clientserver_params=StdioServerParameters(command="uv", args=["run", "server", ...])
asyncwithstdio_client(server_params) as (read, write):
asyncwithClientSession(read, write) assession:
awaitsession.initialize()
...
# ── Streamable HTTP (new example) ─────────────────────────────────────────frommcpimportClientSessionfrommcp.client.streamable_httpimportstreamablehttp_clientSERVER_URL="http://127.0.0.1:8000/mcp"# streamablehttp_client yields a third value: get_session_id()asyncwithstreamablehttp_client(SERVER_URL) as (read, write, get_session_id):
asyncwithClientSession(read, write) assession:
awaitsession.initialize()
session_id=get_session_id() # mcp-session-id header value
...
The ClientSession API is identical after initialize() — same list_tools(), call_tool(), read_resource(), etc. — so existing client code can be ported just by swapping the transport context manager.
How to run
Terminal 1 — start the server:
uv run examples/server_streamable_http.py
# Listening on http://127.0.0.1:8000/mcp
Terminal 2 — run the client:
uv run examples/client_streamable_http.py
# Connecting to MCP server via streamable-http: http://127.0.0.1:8000/mcp# Session established (id=<uuid>)# call_tool('add', {a: 7, b: 35}) → [TextContent(type='text', text='42')]
Or point it at any other streamable-http server:
SERVER_URL=https://my-remote-server.example.com/mcp uv run examples/client_streamable_http.py
Transport comparison
STDIO
Streamable HTTP
Import
mcp.client.stdio
mcp.client.streamable_http
Config
StdioServerParameters(command=…)
URL string
Connectivity
Local subprocess only
Local or remote
Session tracking
N/A (1:1 process)
mcp-session-id header
Recommended for
Local dev / Claude Desktop
Production / networked deployments
SSE streaming
❌
✅ (server-sent events per request)
Resumability
❌
✅ (via EventStore + last-event-id)
I'll open a PR with these two files and a short README update pointing to both the stdio and streamable-http client examples. Happy to also add an asyncio-based integration test if that would help land this faster.
Activity
Premansh12 commentedon May 25, 2026
Thanks for the detailed write-up — this is a well-scoped gap. The SDK already ships
mcp.client.streamable_http.streamablehttp_clientand the server side has examples underexamples/servers/simple-streamablehttp-stateless/, but there's no matching client snippet to pair with it. Here's a PR-ready fix.What's added
Two new files under
examples/:examples/server_streamable_http.pytransport="streamable-http"(mirrorsfastmcp_quickstart.py)examples/client_streamable_http.pystreamablehttp_clientto list tools/resources/prompts and call a toolKey differences vs. the stdio client
The
ClientSessionAPI is identical afterinitialize()— samelist_tools(),call_tool(),read_resource(), etc. — so existing client code can be ported just by swapping the transport context manager.How to run
Terminal 1 — start the server:
uv run examples/server_streamable_http.py # Listening on http://127.0.0.1:8000/mcpTerminal 2 — run the client:
Or point it at any other streamable-http server:
Transport comparison
mcp.client.stdiomcp.client.streamable_httpStdioServerParameters(command=…)mcp-session-idheaderEventStore+last-event-id)I'll open a PR with these two files and a short README update pointing to both the stdio and streamable-http client examples. Happy to also add an
asyncio-based integration test if that would help land this faster.client_streamable_http.py
server_streamable_http.py