Learning objectives
By the end of this lesson you will be able to:- Understand what an MCP client does and why you need one
- Write a client that connects to an MCP server over stdio
- List and invoke tools, resources, and prompts programmatically
- Run both client and server together in a local workflow
What a client does
An MCP client:- Imports the MCP SDK and a transport module
- Instantiates a transport that knows how to start the server process
- Creates a
Clientobject and connects it to the transport - Calls
listTools,listResources,listPromptsto discover server capabilities - Calls
callTool,readResource,getPromptto invoke them
Example client
Step-by-step walkthrough
Import the libraries
You need two things: the
Client class and a transport. For local servers, use stdio transport. For HTTP servers, use SSE or Streamable HTTP transport.- TypeScript
- Python
Instantiate client and transport
The stdio transport takes
command and args — the exact command used to start the server process. The client connects through that transport.- TypeScript
- Python
Key takeaways
- A client can discover and invoke any capability on a server — tools, resources, and prompts.
- The stdio transport starts the server as a child process, so you don’t need to manage it separately.
- A programmatic client is ideal for automated workflows and CI/CD pipelines.
- In the next lesson, you’ll add an LLM to the client so users interact via natural language.