MCP Client
If you build your own agent, you need a client so any MCP server can plug in without custom GitHub or Slack code.
The client is a universal remote. Pair it once, then it can press any button the device exposes.
Visual Workflows
Start here — scroll inside each diagram frame to explore, then use + / − to zoom up to 200% if needed.
Overview
Scroll inside the frame to explore · use + / − to zoom up to 200%
Scroll inside the frame to explore · use + / − to zoom up to 200%
Client call order
Scroll inside the frame to explore · use + / − to zoom up to 200%
initialize → list_tools → call_tool. Same shape in TypeScript and Python.
Key Takeaways
- 1.The client lives inside the host and talks to exactly one server. It starts the process (or HTTP session), then calls initialize.
- 2.It asks list_tools and list_resources so the LLM can choose. When the LLM picks a tool, the client sends call_tool and waits.
- 3.Use the official SDK: mcp in Python or @modelcontextprotocol/sdk in TypeScript. One ClientSession per server.
- 4.Merge tools from several clients in the host, not inside one session.
Learn elsewhere
- →Writing the server handlers — next module
- →mcp.json config — Local MCP
Real Example
Scenario
Your agent starts three clients at boot: filesystem, GitHub, and Postgres. The LLM sees a combined tool list and the host routes each call to the right client.
What you would do
In Model Context Protocol, apply MCP Client to this scenario: Your agent starts three clients at boot: filesystem, GitHub, and Postgres. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.
Commands
Commands to Remember
pip install mcpClientSession + stdio_client for local serversawait session.initialize() before anything elseOne client instance per server
Cheat Sheet
Quick recap
quick ref- •Client = connector inside the host
- •initialize then list then call
- •One session per server
- •Host merges tools from many clients
Common Mistakes
- ✕Forgetting initialize before list_tools
- ✕Putting three servers on one ClientSession
- ✕Swallowing server stderr so you cannot debug startup
