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
isErroris True, return the string"error". Otherwise return the text atresponse["content"][0]["text"].
Then call call_tool("greet", {"name": "alex"}) and print the result.
Expected output:
hello alex
⌘↵ runs the editor.read, then continue.
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
isErroris True, return the string"error". Otherwise return the text atresponse["content"][0]["text"].
Then call call_tool("greet", {"name": "alex"}) and print the result.
Expected output:
hello alex
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.