M16: Building MCP servers & clients (breadth module, best after M9)
In M9 your agent's tools lived inside one script. MCP (Model Context Protocol) is the standard that frees them: wrap your tools in an MCP server and any MCP-aware app, Claude Desktop, an IDE, an agent, can discover and use them, with no custom glue per app. Today you build a real MCP server and the client that talks to it, and it all runs on your machine, no key needed.
Today's win: a working MCP server exposing your tools, and a client that discovers and calls them, the "USB-C for AI tools" you met in M9, now built with your own hands.
Today you will
- Build an MCP server that exposes tools (a decorator turns a function into a discoverable tool)
- Build an MCP client that connects, lists the server's tools, and calls them
- Understand the MCP handshake (discover → call) and why it matters: tools become reusable across apps
Run of show (~50 min)
| Time | What we do |
|---|---|
| 0:00 | Hook + the win we're chasing |
| 0:05 | The one idea: MCP = a standard plug between tools and AI apps (full read in notes.md) |
| 0:10 | Lab Part A: run a server + client; watch tools get discovered and called |
| 0:30 | Lab Part B: add your own tool to the server |
| 0:45 | Show: post your server's tool list |
| 0:50 | Wrap + connecting your server to a real app |
If you get stuck
- One new install:
pip install mcp. No API key, no internet: the client talks to your local server over "stdio" (standard input/output). Nothing here can harm your computer. - The server is started by the client, you usually run the client, which launches the server for you.
- A tool not showing up? Check it has the
@mcp.tool()decorator and a docstring. Re-read the You should now see line.
Optional challenge
Connect your server to a real MCP app: add it to Claude Desktop's MCP config (point it at
python mcp_server.py) and watch Claude itself discover and use your calculate/lookup_ioc tools.
That's the payoff, you built a tool, and a finished AI app can now use it with zero extra code.