promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_promptdojo_

Wire an MCP tool — load tools from a server, not a registry — step 8 of 9

Write bridge_mcp_tools(tools_list_response, mcp_call) that:

  • Takes a tools/list response (a dict with response["result"]["tools"]) and a mcp_call(tool_name, args) function (which simulates calling the server's tools/call and returns a tools/call response dict).
  • Returns a tuple (tools, schemas):
    • tools is a dict mapping each tool's name to a closure that calls mcp_call(name, args), unwraps response["result"]["content"][0]["text"], and returns it (prefixed with "TOOL_ERROR: " if isError is True).
    • schemas is a dict mapping each tool's name to its inputSchema.

Three tools come back. After bridging, dispatch one of them to prove it works. Expected output:

tool_names: ['search', 'read_url', 'summarize']
search_result: 3 results for ramen

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