Skip to content

Commit fc41dd5

Browse files
authored
docs: lead the README client example with a URL, not the server object (#3315)
1 parent 5285e93 commit fc41dd5

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,30 @@ Notice what you did **not** write: no JSON Schema (`a: int, b: int` _is_ the sch
8686

8787
## A client in 10 lines
8888

89-
The same package is a full MCP **client**. `Client` connects to a URL, a stdio subprocess, a custom transport, or (for tests) straight to a server object in memory with no transport at all:
89+
The same package is a full MCP **client**. Serve `server.py` over HTTP:
90+
91+
```bash
92+
uv run mcp run server.py --transport streamable-http
93+
```
94+
95+
then point a `Client` at it:
9096

9197
```python
9298
import asyncio
9399

94100
from mcp import Client
95101

96-
from server import mcp
97-
98102

99103
async def main() -> None:
100-
async with Client(mcp) as client:
104+
async with Client("http://localhost:8000/mcp") as client:
101105
result = await client.call_tool("add", {"a": 1, "b": 2})
102106
print(result.structured_content) # {'result': 3}
103107

104108

105109
asyncio.run(main())
106110
```
107111

108-
Swap `mcp` for `"http://localhost:8000/mcp"` and the exact same code talks to a remote server.
112+
A URL means Streamable HTTP, the transport you deploy. `Client` can also launch a local server as a stdio subprocess or take any custom transport; [Clients](https://py.sdk.modelcontextprotocol.io/client/) has the rest.
109113

110114
## Contributing
111115

src/mcp/cli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def run(
311311
typer.Option(
312312
"--transport",
313313
"-t",
314-
help="Transport protocol to use (stdio or sse)",
314+
help="Transport protocol to use (stdio, sse, or streamable-http)",
315315
),
316316
] = None,
317317
) -> None: # pragma: no cover

0 commit comments

Comments
 (0)