Write call_tool(name, args, registry) — the full dispatcher.
It must:
- If
nameis not inregistry, return the MCP error envelope with textunknown tool: <name>. - Otherwise, loop over
tool["inputSchema"]["required"]and return an error envelope with textmissing required arg: <key>for the first missing required arg. - If everything validates, call
tool["handler"](args)and wrap the return value as the MCP success envelope.
All envelopes have the shape:
{"isError": bool, "content": [{"type": "text", "text": str}]}
Expected output:
ok hello alex
err missing required arg: name
err unknown tool: ghost