quickstart-resources/mcp-client-python
Repository files (latest commit first)
Filename Latest commit message Latest commit date
dependabot[bot] 802f71931d
Bump the uv group across 2 directories with 1 update
Bumps the uv group with 1 update in the /mcp-client-python directory: [httpx2](https://github.com/pydantic/httpx2).
Bumps the uv group with 1 update in the /weather-server-python directory: [httpx2](https://github.com/pydantic/httpx2).


Updates `httpx2` from 2.9.1 to 2.12.0
- [Release notes](https://github.com/pydantic/httpx2/releases)
- [Changelog](https://github.com/pydantic/httpx2/blob/main/src/httpx2/CHANGELOG.md)
- [Commits](https://github.com/pydantic/httpx2/compare/v2.9.1...v2.12.0)

Updates `httpx2` from 2.9.1 to 2.12.0
- [Release notes](https://github.com/pydantic/httpx2/releases)
- [Changelog](https://github.com/pydantic/httpx2/blob/main/src/httpx2/CHANGELOG.md)
- [Commits](https://github.com/pydantic/httpx2/compare/v2.9.1...v2.12.0)

---
updated-dependencies:
- dependency-name: httpx2
  dependency-version: 2.12.0
  dependency-type: indirect
  dependency-group: uv
- dependency-name: httpx2
  dependency-version: 2.12.0
  dependency-type: direct:production
  dependency-group: uv
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-08 22:58:47 +00:00
..
.env.example Add .env. to the global gitignore, as well as .env.example to python client 2025-09-29 15:20:00 +02:00
.python-version Move mcp-client to mcp-client-python 2025-02-17 10:46:18 -08:00
client.py Add structured content to the Python weather server and client and update to v2 (#164) 2026-08-09 14:46:03 +02:00
pyproject.toml Add structured content to the Python weather server and client and update to v2 (#164) 2026-08-09 14:46:03 +02:00
README.md Improve all readmes (#188) 2026-08-27 20:32:29 -07:00
uv.lock Bump the uv group across 2 directories with 1 update 2026-09-08 22:58:47 +00:00

An LLM-Powered Chatbot MCP Client written in Python

An interactive chatbot MCP client: it launches an MCP server over stdio, lists its tools, and hands them to Claude, which can call them while answering your questions.

This example accompanies the Build an MCP client tutorial.

Prerequisites

Setup

Put your API key in a .env file (or export ANTHROPIC_API_KEY in your shell):

cp .env.example .env
# then edit .env and add your key

Run the client

Pass the path to a server script. .py servers are launched with uv, .js servers with node:

uv run client.py ../weather-server-python/weather.py

or, against the TypeScript server (build it first — see its README):

uv run client.py ../weather-server-typescript/build/index.js

Type a question (for example, "What's the weather in Sacramento?") and Claude answers using the server's tools. Type quit to exit.

Without an ANTHROPIC_API_KEY, the client still connects, prints the server's tools, and exits — useful for verifying the MCP wiring without credentials.

Structured content

call_tool validates every result against the tool's declared output schema, so the spec's client-side SHOULD needs no code here.

The two channels go to different readers: content is forwarded to the model, while structured_content is used as data — when a tool returns an array, the client counts its items rather than re-reading the prose. See Structured Content.

Client(transport, mode="auto") probes server/discover and falls back to the 2025-11-25 handshake; client.protocol_version reports which era you got. See Protocol versions.