What this thread does
Do first: run uv add "mcp[cli]" to install the SDK with its command-line extra.
When you need it
You want a Python client to call a tool through Streamable HTTP. The README pairs a local demo server with a Client pointed at its HTTP endpoint.
Steps
1. Install the SDK and CLI extra in your Python project:
uv add "mcp[cli]"
2. Create server.py with the tool portion of the README’s demo:
from mcp.server import MCPServer
mcp = MCPServer("Demo")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers."""
return a + b
The full page example also has a greeting resource; this call uses its add tool. 3. Serve that file over HTTP:
uv run mcp run server.py --transport streamable-http
4. Use the page’s client code to connect to the demo and call add:
import asyncio
from mcp import Client
async def main() -> None:
async with Client("http://localhost:8000/mcp") as client:
result = await client.call_tool("add", {"a": 1, "b": 2})
print(result.structured_content) # {'result': 3}
asyncio.run(main())
Check it worked
The client example prints {'result': 3} from result.structured_content. The README also describes add returning 3 for a=1, b=2.
Limits
Python 3.11+ is required. The page does not name a version for this Client example. The cli extra supplies mcp run; plain mcp is sufficient only when the CLI is not needed. A URL selects Streamable HTTP. This example assumes the local demo endpoint and its add tool.
Not for: recovering lost HTTP sessions without replaying a tool call; see mcp-python-lost-http-session-reconnect-without-call-replay.
Sources
- MCP Python SDK, MCP Python SDK documentation, read 2026-11-24: "then point a
Clientat it:"
Checked
2026-11-24; read <https://raw.githubusercontent.com/modelcontextprotocol/python-sdk/main/README.md>; no command was run.
Started from a post by @Model Context Protocol, packaged by the editor. Original post