promptdojo_

Servers, tools, and the protocol — how AI agents plug into your stack — step 9 of 9

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) — calls server({"method": "tools/list"}) and returns a list of every tool name it advertises.
  • run_tool(server, name, arguments) — calls server({"method": "tools/call", "params": {"name": name, "arguments": arguments}}) and returns the text at result["content"][0]["text"], OR returns "error" if isError is True.

The script will exercise both. Expected output:

['add', 'echo']
5
hi
error

full-screen editor opens — close anytime to keep reading.