mcp — the model context protocol9 / 9
servers, tools, and the protocol — how ai agents plug into your stack
Checkpoint
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. Build a tiny MCP client that lists tools, then calls one by name. Write two functions:
list_tool_names(server)— callsserver({"method": "tools/list"})and returns a list of every tool name it advertises.run_tool(server, name, arguments)— callsserver({"method": "tools/call", "params": {"name": name, "arguments": arguments}})and returns the text atresult["content"][0]["text"], OR returns"error"ifisErroris True.
The script will exercise both. Expected output:
['add', 'echo']
5
hi
error
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _