promptdojo_

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

Build the client side of a tools/call. Write call_tool(name, arguments) that:

  • Builds a request dict {"name": name, "arguments": arguments}.
  • Passes it to the provided fake_server(request) (a stand-in for an MCP server).
  • Reads the response. If isError is True, return the string "error". Otherwise return the text at response["content"][0]["text"].

Then call call_tool("greet", {"name": "alex"}) and print the result.

Expected output:

hello alex

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