[{"data":1,"prerenderedAt":1233},["ShallowReactive",2],{"series-\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Fbeyond-one-tool-call-at-a-time-introducing-code-mode":3,"series-context-\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers":1043},{"id":4,"title":5,"body":6,"contentId":1028,"date":1029,"description":1030,"extension":1031,"github":1032,"meetTheInstructor":1034,"meta":1035,"navigation":81,"part":60,"path":1036,"rawbody":1037,"robots":1034,"schemaOrg":1034,"seo":1038,"seriesSlug":1039,"sitemap":1040,"stem":1041,"subtitle":1034,"topics":1034,"__hash__":1042},"series\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Fbeyond-one-tool-call-at-a-time-introducing-code-mode.md","Beyond One Tool Call at a Time: Introducing Code Mode",{"type":7,"value":8,"toc":1023},"minimark",[9,25,28,31,34,39,42,45,371,378,388,391,394,398,415,418,421,424,583,587,590,593,596,632,635,646,652,829,834,1007,1016,1019],[10,11,12,13],"p",{},"LLMs can request tool calls. It may sound obvious nowadays, but at first, it was not possible. ",[14,15,16,17,24],"em",{},"It is funny to say \"at first\" as if it were a long time ago, but ",[18,19,23],"a",{"href":20,"rel":21},"https:\u002F\u002Fopenai.com\u002Findex\u002Ffunction-calling-and-other-api-updates\u002F",[22],"nofollow","it was only 3 years ago",".",[10,26,27],{},"Often called \"tool calling\" or \"function calling,\" this capability lets a model interact with an external system. For example, an LLM can read or write a file through a tool call. Without it, a model can still explain and generate content, but it cannot directly act on an external system.",[10,29,30],{},"When paired with useful tools, a model can work towards a goal: it can gather the information it needs and take the necessary actions. A clear request can be enough for a well-scoped task, although reliable results still depend on the available tools, instructions, and safeguards.",[10,32,33],{},"However, we need to provide tools that allow them to perform specific actions on our behalf.",[35,36,38],"h2",{"id":37},"adding-a-custom-tool-to-chatgpt","Adding a custom tool to ChatGPT",[10,40,41],{},"Imagine you are using ChatGPT and want to allow it to read files on your drive to provide contextual answers. You must provide it with a tool to read files, but you do not have access to the model's implementation.",[10,43,44],{},"From a code perspective, this looks like this:",[46,47,53],"pre",{"className":48,"code":49,"filename":50,"language":51,"meta":52,"style":52},"language-ts shiki shiki-themes github-light github-light github-dark","import OpenAI from 'openai'\n\nconst client = new OpenAI()\n\nconst tools = [\n  {\n    type: 'function',\n    name: 'get_weather',\n    description: 'Get current temperature for a given location.',\n    parameters: {\n      type: 'object',\n      properties: {\n        location: {\n          type: 'string',\n          description: 'City and country e.g. Bogotá, Colombia',\n        },\n      },\n      required: ['location'],\n      additionalProperties: false,\n    },\n    strict: true,\n  },\n]\n\nconst response = await client.responses.create({\n  model: 'gpt-5.5',\n  input: [\n    { role: 'user', content: 'What is the weather like in Paris today?' },\n  ],\n  tools,\n})\n\n\u002F\u002F From the OpenAI Developer documentation: https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Ftools?tool-type=function-calling\n","Example","ts","",[54,55,56,76,83,106,111,124,130,142,153,164,170,181,187,193,204,215,221,227,239,250,256,267,273,279,284,306,317,323,341,347,353,359,364],"code",{"__ignoreMap":52},[57,58,61,65,69,72],"span",{"class":59,"line":60},"line",1,[57,62,64],{"class":63},"s8jYJ","import",[57,66,68],{"class":67},"sxrX7"," OpenAI ",[57,70,71],{"class":63},"from",[57,73,75],{"class":74},"sIIMD"," 'openai'\n",[57,77,79],{"class":59,"line":78},2,[57,80,82],{"emptyLinePlaceholder":81},true,"\n",[57,84,86,89,93,96,99,103],{"class":59,"line":85},3,[57,87,88],{"class":63},"const",[57,90,92],{"class":91},"sBjJW"," client",[57,94,95],{"class":63}," =",[57,97,98],{"class":63}," new",[57,100,102],{"class":101},"snPdu"," OpenAI",[57,104,105],{"class":67},"()\n",[57,107,109],{"class":59,"line":108},4,[57,110,82],{"emptyLinePlaceholder":81},[57,112,114,116,119,121],{"class":59,"line":113},5,[57,115,88],{"class":63},[57,117,118],{"class":91}," tools",[57,120,95],{"class":63},[57,122,123],{"class":67}," [\n",[57,125,127],{"class":59,"line":126},6,[57,128,129],{"class":67},"  {\n",[57,131,133,136,139],{"class":59,"line":132},7,[57,134,135],{"class":67},"    type: ",[57,137,138],{"class":74},"'function'",[57,140,141],{"class":67},",\n",[57,143,145,148,151],{"class":59,"line":144},8,[57,146,147],{"class":67},"    name: ",[57,149,150],{"class":74},"'get_weather'",[57,152,141],{"class":67},[57,154,156,159,162],{"class":59,"line":155},9,[57,157,158],{"class":67},"    description: ",[57,160,161],{"class":74},"'Get current temperature for a given location.'",[57,163,141],{"class":67},[57,165,167],{"class":59,"line":166},10,[57,168,169],{"class":67},"    parameters: {\n",[57,171,173,176,179],{"class":59,"line":172},11,[57,174,175],{"class":67},"      type: ",[57,177,178],{"class":74},"'object'",[57,180,141],{"class":67},[57,182,184],{"class":59,"line":183},12,[57,185,186],{"class":67},"      properties: {\n",[57,188,190],{"class":59,"line":189},13,[57,191,192],{"class":67},"        location: {\n",[57,194,196,199,202],{"class":59,"line":195},14,[57,197,198],{"class":67},"          type: ",[57,200,201],{"class":74},"'string'",[57,203,141],{"class":67},[57,205,207,210,213],{"class":59,"line":206},15,[57,208,209],{"class":67},"          description: ",[57,211,212],{"class":74},"'City and country e.g. Bogotá, Colombia'",[57,214,141],{"class":67},[57,216,218],{"class":59,"line":217},16,[57,219,220],{"class":67},"        },\n",[57,222,224],{"class":59,"line":223},17,[57,225,226],{"class":67},"      },\n",[57,228,230,233,236],{"class":59,"line":229},18,[57,231,232],{"class":67},"      required: [",[57,234,235],{"class":74},"'location'",[57,237,238],{"class":67},"],\n",[57,240,242,245,248],{"class":59,"line":241},19,[57,243,244],{"class":67},"      additionalProperties: ",[57,246,247],{"class":91},"false",[57,249,141],{"class":67},[57,251,253],{"class":59,"line":252},20,[57,254,255],{"class":67},"    },\n",[57,257,259,262,265],{"class":59,"line":258},21,[57,260,261],{"class":67},"    strict: ",[57,263,264],{"class":91},"true",[57,266,141],{"class":67},[57,268,270],{"class":59,"line":269},22,[57,271,272],{"class":67},"  },\n",[57,274,276],{"class":59,"line":275},23,[57,277,278],{"class":67},"]\n",[57,280,282],{"class":59,"line":281},24,[57,283,82],{"emptyLinePlaceholder":81},[57,285,287,289,292,294,297,300,303],{"class":59,"line":286},25,[57,288,88],{"class":63},[57,290,291],{"class":91}," response",[57,293,95],{"class":63},[57,295,296],{"class":63}," await",[57,298,299],{"class":67}," client.responses.",[57,301,302],{"class":101},"create",[57,304,305],{"class":67},"({\n",[57,307,309,312,315],{"class":59,"line":308},26,[57,310,311],{"class":67},"  model: ",[57,313,314],{"class":74},"'gpt-5.5'",[57,316,141],{"class":67},[57,318,320],{"class":59,"line":319},27,[57,321,322],{"class":67},"  input: [\n",[57,324,326,329,332,335,338],{"class":59,"line":325},28,[57,327,328],{"class":67},"    { role: ",[57,330,331],{"class":74},"'user'",[57,333,334],{"class":67},", content: ",[57,336,337],{"class":74},"'What is the weather like in Paris today?'",[57,339,340],{"class":67}," },\n",[57,342,344],{"class":59,"line":343},29,[57,345,346],{"class":67},"  ],\n",[57,348,350],{"class":59,"line":349},30,[57,351,352],{"class":67},"  tools,\n",[57,354,356],{"class":59,"line":355},31,[57,357,358],{"class":67},"})\n",[57,360,362],{"class":59,"line":361},32,[57,363,82],{"emptyLinePlaceholder":81},[57,365,367],{"class":59,"line":366},33,[57,368,370],{"class":369},"sCsY4","\u002F\u002F From the OpenAI Developer documentation: https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Ftools?tool-type=function-calling\n",[10,372,373,374,377],{},"We quickly understand that we do not have access to that ",[54,375,376],{},"client"," in ChatGPT. Even if we did have access to it, we would face two problems:",[379,380,381,385],"ol",{},[382,383,384],"li",{},"Non-developers would not make these changes themselves.",[382,386,387],{},"We would have to implement it for all clients, like Claude, VS Code, Dust, etc.",[10,389,390],{},"A nightmare for everyone, including ourselves.",[10,392,393],{},"That's where MCP comes in.",[35,395,397],{"id":396},"mcp-to-uniformly-expose-tools","MCP to uniformly expose tools",[399,400,403],"callout",{"color":401,"icon":402},"info","i-ph-info-duotone",[10,404,405,406,410,411,24],{},"MCP fundamentals are outside the scope of this series. If you need an introduction to the protocol or to the basic relationship between an AI agent and an MCP server, begin with ",[18,407,409],{"href":408},"..\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web","AI Agents and MCP Server: Teaming Up for the Agentic Web",", especially ",[18,412,414],{"href":413},"..\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fmcp-to-provide-additional-capabilities-to-the-ai-agent","its MCP server article",[10,416,417],{},"In short, MCP is a protocol that allows an AI agent to communicate with a server. The server can provide additional capabilities to the agent, such as access to tools. The agent, known as the client, can then use these tools to perform actions on behalf of the user.",[10,419,420],{},"Concretely, the server exposes tools through a uniform API, and the client can call one of these to know what tools are available, and then register them to the model. The model can then call these tools as if they were native functions. When a tool is called, the client sends the request to the server, instead of executing it locally. The server then executes the tool and returns the result to the client, which then returns it to the model.",[10,422,423],{},"From a code point of view, the client looks like this:",[46,425,427],{"className":48,"code":426,"filename":50,"language":51,"meta":52,"style":52},"\u002F\u002F This is pseudo-code, not a real implementation.\nconst client = new LlmClient({\n  provider: 'openai',\n})\n\nconst mcpClient = new McpClient({\n  server: 'https:\u002F\u002Fmcp.example.com',\n})\n\nconst tools = await mcpClient.getTools() \u002F\u002F Provide a weather tool, similar to the previous example.\n\nconst response = await client.responses.create({\n  model: 'gpt-5.5',\n  input: [\n    { role: 'user', content: 'What is the weather like in Paris today?' },\n  ],\n  tools, \u002F\u002F The tools are now provided by the MCP server, not hardcoded in the client.\n})\n",[54,428,429,434,449,459,463,467,483,493,497,501,523,527,543,551,555,567,571,579],{"__ignoreMap":52},[57,430,431],{"class":59,"line":60},[57,432,433],{"class":369},"\u002F\u002F This is pseudo-code, not a real implementation.\n",[57,435,436,438,440,442,444,447],{"class":59,"line":78},[57,437,88],{"class":63},[57,439,92],{"class":91},[57,441,95],{"class":63},[57,443,98],{"class":63},[57,445,446],{"class":101}," LlmClient",[57,448,305],{"class":67},[57,450,451,454,457],{"class":59,"line":85},[57,452,453],{"class":67},"  provider: ",[57,455,456],{"class":74},"'openai'",[57,458,141],{"class":67},[57,460,461],{"class":59,"line":108},[57,462,358],{"class":67},[57,464,465],{"class":59,"line":113},[57,466,82],{"emptyLinePlaceholder":81},[57,468,469,471,474,476,478,481],{"class":59,"line":126},[57,470,88],{"class":63},[57,472,473],{"class":91}," mcpClient",[57,475,95],{"class":63},[57,477,98],{"class":63},[57,479,480],{"class":101}," McpClient",[57,482,305],{"class":67},[57,484,485,488,491],{"class":59,"line":132},[57,486,487],{"class":67},"  server: ",[57,489,490],{"class":74},"'https:\u002F\u002Fmcp.example.com'",[57,492,141],{"class":67},[57,494,495],{"class":59,"line":144},[57,496,358],{"class":67},[57,498,499],{"class":59,"line":155},[57,500,82],{"emptyLinePlaceholder":81},[57,502,503,505,507,509,511,514,517,520],{"class":59,"line":166},[57,504,88],{"class":63},[57,506,118],{"class":91},[57,508,95],{"class":63},[57,510,296],{"class":63},[57,512,513],{"class":67}," mcpClient.",[57,515,516],{"class":101},"getTools",[57,518,519],{"class":67},"() ",[57,521,522],{"class":369},"\u002F\u002F Provide a weather tool, similar to the previous example.\n",[57,524,525],{"class":59,"line":172},[57,526,82],{"emptyLinePlaceholder":81},[57,528,529,531,533,535,537,539,541],{"class":59,"line":183},[57,530,88],{"class":63},[57,532,291],{"class":91},[57,534,95],{"class":63},[57,536,296],{"class":63},[57,538,299],{"class":67},[57,540,302],{"class":101},[57,542,305],{"class":67},[57,544,545,547,549],{"class":59,"line":189},[57,546,311],{"class":67},[57,548,314],{"class":74},[57,550,141],{"class":67},[57,552,553],{"class":59,"line":195},[57,554,322],{"class":67},[57,556,557,559,561,563,565],{"class":59,"line":206},[57,558,328],{"class":67},[57,560,331],{"class":74},[57,562,334],{"class":67},[57,564,337],{"class":74},[57,566,340],{"class":67},[57,568,569],{"class":59,"line":217},[57,570,346],{"class":67},[57,572,573,576],{"class":59,"line":223},[57,574,575],{"class":67},"  tools, ",[57,577,578],{"class":369},"\u002F\u002F The tools are now provided by the MCP server, not hardcoded in the client.\n",[57,580,581],{"class":59,"line":229},[57,582,358],{"class":67},[35,584,586],{"id":585},"dependency-between-tool-calls","Dependency between tool calls",[10,588,589],{},"With this approach, the model receives each tool result before it can decide what to do next. If an action requires three dependent tool calls, the model needs three turns, and the intermediate results become part of its context.",[10,591,592],{},"Let's be honest, this works fine most of the time. However, it's not optimal for all cases.",[10,594,595],{},"And with the MCP server in the loop, the chain of events looks like this:",[379,597,598,601,604,607,610,617,620,623,626,629],{},[382,599,600],{},"MCP client connects to the MCP server",[382,602,603],{},"MCP client requests the list of available tools from the MCP server",[382,605,606],{},"MCP server returns the list of available tools to the MCP client",[382,608,609],{},"MCP client registers the tools with the model",[382,611,612,613,616],{},"Model calls a tool (e.g., ",[54,614,615],{},"get_weather",") with the required parameters",[382,618,619],{},"MCP client receives the tool call request from the model",[382,621,622],{},"MCP client sends the tool call request to the MCP server",[382,624,625],{},"MCP server executes the tool (e.g., fetches the weather data for the specified location)",[382,627,628],{},"MCP server returns the result of the tool execution to the MCP client",[382,630,631],{},"MCP client returns the result of the tool execution to the model",[10,633,634],{},"The good news, and why we call it \"uniform\", is that all MCP-related steps are the same for every client and MCP server. You just need to focus on the tool implementation.",[10,636,637,638,641,642,645],{},"Imagine the following context. You are working on a Drive that contains many Markdown files, and your agent is connected to that Drive using an MCP that contains two tools: ",[54,639,640],{},"readFile"," and ",[54,643,644],{},"writeFile",". Your goal is to create a file that contains all the titles of one Markdown file.",[10,647,648,649,651],{},"The ",[54,650,640],{}," tool is defined as follows in the MCP server:",[46,653,655],{"className":48,"code":654,"filename":50,"language":51,"meta":52,"style":52},"server.registerTool(\n  'readFile',\n  {\n    title: 'Drive Read File',\n    description: 'Read a Markdown file from the local Drive fixture.',\n    inputSchema: z.object({\n      path: z.string().min(1)\n    }),\n    annotations: {\n      title: 'Drive Read File',\n      readOnlyHint: true\n    }\n  },\n  async ({ path }) => {\n    const content = await readDriveFile(path)\n    return { content: [{ type: 'text', text: content }] }\n  }\n)\n",[54,656,657,668,675,679,689,698,708,731,736,741,750,758,763,767,788,806,820,825],{"__ignoreMap":52},[57,658,659,662,665],{"class":59,"line":60},[57,660,661],{"class":67},"server.",[57,663,664],{"class":101},"registerTool",[57,666,667],{"class":67},"(\n",[57,669,670,673],{"class":59,"line":78},[57,671,672],{"class":74},"  'readFile'",[57,674,141],{"class":67},[57,676,677],{"class":59,"line":85},[57,678,129],{"class":67},[57,680,681,684,687],{"class":59,"line":108},[57,682,683],{"class":67},"    title: ",[57,685,686],{"class":74},"'Drive Read File'",[57,688,141],{"class":67},[57,690,691,693,696],{"class":59,"line":113},[57,692,158],{"class":67},[57,694,695],{"class":74},"'Read a Markdown file from the local Drive fixture.'",[57,697,141],{"class":67},[57,699,700,703,706],{"class":59,"line":126},[57,701,702],{"class":67},"    inputSchema: z.",[57,704,705],{"class":101},"object",[57,707,305],{"class":67},[57,709,710,713,716,719,722,725,728],{"class":59,"line":132},[57,711,712],{"class":67},"      path: z.",[57,714,715],{"class":101},"string",[57,717,718],{"class":67},"().",[57,720,721],{"class":101},"min",[57,723,724],{"class":67},"(",[57,726,727],{"class":91},"1",[57,729,730],{"class":67},")\n",[57,732,733],{"class":59,"line":144},[57,734,735],{"class":67},"    }),\n",[57,737,738],{"class":59,"line":155},[57,739,740],{"class":67},"    annotations: {\n",[57,742,743,746,748],{"class":59,"line":166},[57,744,745],{"class":67},"      title: ",[57,747,686],{"class":74},[57,749,141],{"class":67},[57,751,752,755],{"class":59,"line":172},[57,753,754],{"class":67},"      readOnlyHint: ",[57,756,757],{"class":91},"true\n",[57,759,760],{"class":59,"line":183},[57,761,762],{"class":67},"    }\n",[57,764,765],{"class":59,"line":189},[57,766,272],{"class":67},[57,768,769,772,775,779,782,785],{"class":59,"line":195},[57,770,771],{"class":63},"  async",[57,773,774],{"class":67}," ({ ",[57,776,778],{"class":777},"sP4rz","path",[57,780,781],{"class":67}," }) ",[57,783,784],{"class":63},"=>",[57,786,787],{"class":67}," {\n",[57,789,790,793,796,798,800,803],{"class":59,"line":206},[57,791,792],{"class":63},"    const",[57,794,795],{"class":91}," content",[57,797,95],{"class":63},[57,799,296],{"class":63},[57,801,802],{"class":101}," readDriveFile",[57,804,805],{"class":67},"(path)\n",[57,807,808,811,814,817],{"class":59,"line":217},[57,809,810],{"class":63},"    return",[57,812,813],{"class":67}," { content: [{ type: ",[57,815,816],{"class":74},"'text'",[57,818,819],{"class":67},", text: content }] }\n",[57,821,822],{"class":59,"line":223},[57,823,824],{"class":67},"  }\n",[57,826,827],{"class":59,"line":229},[57,828,730],{"class":67},[10,830,831,832,651],{},"and the ",[54,833,644],{},[46,835,837],{"className":48,"code":836,"filename":50,"language":51,"meta":52,"style":52},"server.registerTool(\n  'writeFile',\n  {\n    title: 'Drive Write File',\n    description: 'Write a Markdown file to the local Drive fixture.',\n    inputSchema: z.object({\n      path: z.string().min(1),\n      content: z.string()\n    }),\n    annotations: {\n      title: 'Drive Write File',\n      destructiveHint: true\n    }\n  },\n  async ({ path, content }) => {\n    await writeDriveFile(path, content)\n    return { content: [{ type: 'text', text: JSON.stringify({ success: true }) }] }\n  }\n)\n",[54,838,839,847,854,858,867,876,884,901,910,914,918,926,933,937,941,961,972,999,1003],{"__ignoreMap":52},[57,840,841,843,845],{"class":59,"line":60},[57,842,661],{"class":67},[57,844,664],{"class":101},[57,846,667],{"class":67},[57,848,849,852],{"class":59,"line":78},[57,850,851],{"class":74},"  'writeFile'",[57,853,141],{"class":67},[57,855,856],{"class":59,"line":85},[57,857,129],{"class":67},[57,859,860,862,865],{"class":59,"line":108},[57,861,683],{"class":67},[57,863,864],{"class":74},"'Drive Write File'",[57,866,141],{"class":67},[57,868,869,871,874],{"class":59,"line":113},[57,870,158],{"class":67},[57,872,873],{"class":74},"'Write a Markdown file to the local Drive fixture.'",[57,875,141],{"class":67},[57,877,878,880,882],{"class":59,"line":126},[57,879,702],{"class":67},[57,881,705],{"class":101},[57,883,305],{"class":67},[57,885,886,888,890,892,894,896,898],{"class":59,"line":132},[57,887,712],{"class":67},[57,889,715],{"class":101},[57,891,718],{"class":67},[57,893,721],{"class":101},[57,895,724],{"class":67},[57,897,727],{"class":91},[57,899,900],{"class":67},"),\n",[57,902,903,906,908],{"class":59,"line":144},[57,904,905],{"class":67},"      content: z.",[57,907,715],{"class":101},[57,909,105],{"class":67},[57,911,912],{"class":59,"line":155},[57,913,735],{"class":67},[57,915,916],{"class":59,"line":166},[57,917,740],{"class":67},[57,919,920,922,924],{"class":59,"line":172},[57,921,745],{"class":67},[57,923,864],{"class":74},[57,925,141],{"class":67},[57,927,928,931],{"class":59,"line":183},[57,929,930],{"class":67},"      destructiveHint: ",[57,932,757],{"class":91},[57,934,935],{"class":59,"line":189},[57,936,762],{"class":67},[57,938,939],{"class":59,"line":195},[57,940,272],{"class":67},[57,942,943,945,947,949,952,955,957,959],{"class":59,"line":206},[57,944,771],{"class":63},[57,946,774],{"class":67},[57,948,778],{"class":777},[57,950,951],{"class":67},", ",[57,953,954],{"class":777},"content",[57,956,781],{"class":67},[57,958,784],{"class":63},[57,960,787],{"class":67},[57,962,963,966,969],{"class":59,"line":217},[57,964,965],{"class":63},"    await",[57,967,968],{"class":101}," writeDriveFile",[57,970,971],{"class":67},"(path, content)\n",[57,973,974,976,978,980,983,986,988,991,994,996],{"class":59,"line":223},[57,975,810],{"class":63},[57,977,813],{"class":67},[57,979,816],{"class":74},[57,981,982],{"class":67},", text: ",[57,984,985],{"class":91},"JSON",[57,987,24],{"class":67},[57,989,990],{"class":101},"stringify",[57,992,993],{"class":67},"({ success: ",[57,995,264],{"class":91},[57,997,998],{"class":67}," }) }] }\n",[57,1000,1001],{"class":59,"line":229},[57,1002,824],{"class":67},[57,1004,1005],{"class":59,"line":241},[57,1006,730],{"class":67},[10,1008,1009,1010,1012,1013,1015],{},"With the current MCP approach, the model must call ",[54,1011,640],{}," to read the file, load the content into its context, extract the titles, and then call ",[54,1014,644],{}," to write the titles into a new file. This means that the model must load the entire content of the file into its context, which can be very large and can lead to context overflow, prompt injection, and unnecessary token costs, without the certainty that the model will extract the titles correctly.",[10,1017,1018],{},"That is exactly why Code Mode shines. In the next article, we will transform that MCP server into a Code Mode server and see how the model can orchestrate the tool calls without loading the entire content into its context.",[1020,1021,1022],"style",{},"html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sP4rz, html code.shiki .sP4rz{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":52,"searchDepth":78,"depth":78,"links":1024},[1025,1026,1027],{"id":37,"depth":78,"text":38},{"id":396,"depth":78,"text":397},{"id":585,"depth":78,"text":586},"6f0c6f18-8d31-4b4d-aea6-9b2df779a0d1","2026-07-12","See why dependent direct MCP tool calls make intermediate content part of model context, and how Code Mode moves orchestration into generated code.","md",{"branch":1033},"part-1-direct-tools",null,{},"\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Fbeyond-one-tool-call-at-a-time-introducing-code-mode","---\ncontentId: 6f0c6f18-8d31-4b4d-aea6-9b2df779a0d1\npart: 1\ntitle: \"Beyond One Tool Call at a Time: Introducing Code Mode\"\ndescription: See why dependent direct MCP tool calls make intermediate content part of model context, and how Code Mode moves orchestration into generated code.\ngithub:\n  branch: part-1-direct-tools\ndate: 2026-07-12\nseriesSlug: building-code-mode-for-apis-with-mcp-and-isolated-workers\n---\n\nLLMs can request tool calls. It may sound obvious nowadays, but at first, it was not possible. _It is funny to say \"at first\" as if it were a long time ago, but [it was only 3 years ago](https:\u002F\u002Fopenai.com\u002Findex\u002Ffunction-calling-and-other-api-updates\u002F)._\n\nOften called \"tool calling\" or \"function calling,\" this capability lets a model interact with an external system. For example, an LLM can read or write a file through a tool call. Without it, a model can still explain and generate content, but it cannot directly act on an external system.\n\nWhen paired with useful tools, a model can work towards a goal: it can gather the information it needs and take the necessary actions. A clear request can be enough for a well-scoped task, although reliable results still depend on the available tools, instructions, and safeguards.\n\nHowever, we need to provide tools that allow them to perform specific actions on our behalf.\n\n## Adding a custom tool to ChatGPT\n\nImagine you are using ChatGPT and want to allow it to read files on your drive to provide contextual answers. You must provide it with a tool to read files, but you do not have access to the model's implementation.\n\nFrom a code perspective, this looks like this:\n\n```ts [Example]\nimport OpenAI from 'openai'\n\nconst client = new OpenAI()\n\nconst tools = [\n  {\n    type: 'function',\n    name: 'get_weather',\n    description: 'Get current temperature for a given location.',\n    parameters: {\n      type: 'object',\n      properties: {\n        location: {\n          type: 'string',\n          description: 'City and country e.g. Bogotá, Colombia',\n        },\n      },\n      required: ['location'],\n      additionalProperties: false,\n    },\n    strict: true,\n  },\n]\n\nconst response = await client.responses.create({\n  model: 'gpt-5.5',\n  input: [\n    { role: 'user', content: 'What is the weather like in Paris today?' },\n  ],\n  tools,\n})\n\n\u002F\u002F From the OpenAI Developer documentation: https:\u002F\u002Fdevelopers.openai.com\u002Fapi\u002Fdocs\u002Fguides\u002Ftools?tool-type=function-calling\n```\n\nWe quickly understand that we do not have access to that `client` in ChatGPT. Even if we did have access to it, we would face two problems:\n\n1. Non-developers would not make these changes themselves.\n2. We would have to implement it for all clients, like Claude, VS Code, Dust, etc.\n\nA nightmare for everyone, including ourselves.\n\nThat's where MCP comes in.\n\n## MCP to uniformly expose tools\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nMCP fundamentals are outside the scope of this series. If you need an introduction to the protocol or to the basic relationship between an AI agent and an MCP server, begin with [AI Agents and MCP Server: Teaming Up for the Agentic Web](..\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web.md), especially [its MCP server article](..\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fmcp-to-provide-additional-capabilities-to-the-ai-agent.md).\n::\n\nIn short, MCP is a protocol that allows an AI agent to communicate with a server. The server can provide additional capabilities to the agent, such as access to tools. The agent, known as the client, can then use these tools to perform actions on behalf of the user.\n\nConcretely, the server exposes tools through a uniform API, and the client can call one of these to know what tools are available, and then register them to the model. The model can then call these tools as if they were native functions. When a tool is called, the client sends the request to the server, instead of executing it locally. The server then executes the tool and returns the result to the client, which then returns it to the model.\n\nFrom a code point of view, the client looks like this:\n\n```ts [Example]\n\u002F\u002F This is pseudo-code, not a real implementation.\nconst client = new LlmClient({\n  provider: 'openai',\n})\n\nconst mcpClient = new McpClient({\n  server: 'https:\u002F\u002Fmcp.example.com',\n})\n\nconst tools = await mcpClient.getTools() \u002F\u002F Provide a weather tool, similar to the previous example.\n\nconst response = await client.responses.create({\n  model: 'gpt-5.5',\n  input: [\n    { role: 'user', content: 'What is the weather like in Paris today?' },\n  ],\n  tools, \u002F\u002F The tools are now provided by the MCP server, not hardcoded in the client.\n})\n```\n\n## Dependency between tool calls\n\nWith this approach, the model receives each tool result before it can decide what to do next. If an action requires three dependent tool calls, the model needs three turns, and the intermediate results become part of its context.\n\nLet's be honest, this works fine most of the time. However, it's not optimal for all cases.\n\nAnd with the MCP server in the loop, the chain of events looks like this:\n\n1. MCP client connects to the MCP server\n2. MCP client requests the list of available tools from the MCP server\n3. MCP server returns the list of available tools to the MCP client\n4. MCP client registers the tools with the model\n5. Model calls a tool (e.g., `get_weather`) with the required parameters\n6. MCP client receives the tool call request from the model\n7. MCP client sends the tool call request to the MCP server\n8. MCP server executes the tool (e.g., fetches the weather data for the specified location)\n9. MCP server returns the result of the tool execution to the MCP client\n10. MCP client returns the result of the tool execution to the model\n\nThe good news, and why we call it \"uniform\", is that all MCP-related steps are the same for every client and MCP server. You just need to focus on the tool implementation.\n\nImagine the following context. You are working on a Drive that contains many Markdown files, and your agent is connected to that Drive using an MCP that contains two tools: `readFile` and `writeFile`. Your goal is to create a file that contains all the titles of one Markdown file.\n\nThe `readFile` tool is defined as follows in the MCP server:\n\n```ts [Example]\nserver.registerTool(\n  'readFile',\n  {\n    title: 'Drive Read File',\n    description: 'Read a Markdown file from the local Drive fixture.',\n    inputSchema: z.object({\n      path: z.string().min(1)\n    }),\n    annotations: {\n      title: 'Drive Read File',\n      readOnlyHint: true\n    }\n  },\n  async ({ path }) => {\n    const content = await readDriveFile(path)\n    return { content: [{ type: 'text', text: content }] }\n  }\n)\n```\n\nand the `writeFile` tool is defined as follows in the MCP server:\n\n```ts [Example]\nserver.registerTool(\n  'writeFile',\n  {\n    title: 'Drive Write File',\n    description: 'Write a Markdown file to the local Drive fixture.',\n    inputSchema: z.object({\n      path: z.string().min(1),\n      content: z.string()\n    }),\n    annotations: {\n      title: 'Drive Write File',\n      destructiveHint: true\n    }\n  },\n  async ({ path, content }) => {\n    await writeDriveFile(path, content)\n    return { content: [{ type: 'text', text: JSON.stringify({ success: true }) }] }\n  }\n)\n```\n\nWith the current MCP approach, the model must call `readFile` to read the file, load the content into its context, extract the titles, and then call `writeFile` to write the titles into a new file. This means that the model must load the entire content of the file into its context, which can be very large and can lead to context overflow, prompt injection, and unnecessary token costs, without the certainty that the model will extract the titles correctly.\n\nThat is exactly why Code Mode shines. In the next article, we will transform that MCP server into a Code Mode server and see how the model can orchestrate the tool calls without loading the entire content into its context.\n",{"title":5,"description":1030},"building-code-mode-for-apis-with-mcp-and-isolated-workers",{"loc":1036},"series\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Fbeyond-one-tool-call-at-a-time-introducing-code-mode","i2XTLWsSOc5EqRkUtrMLu5k7zOWVagf5BwoPgham8bk",{"overview":1044,"chapters":1206},{"id":1045,"title":1046,"body":1047,"contentId":1185,"date":1029,"description":1186,"extension":1031,"github":1187,"meetTheInstructor":1189,"meta":1190,"navigation":81,"part":1034,"path":1191,"rawbody":1192,"robots":1034,"schemaOrg":1034,"seo":1193,"seriesSlug":1039,"sitemap":1194,"stem":1195,"subtitle":1196,"topics":1197,"__hash__":1205},"series\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers.md","Building Code Mode for APIs with MCP and Isolated Workers",{"type":7,"value":1048,"toc":1182},[1049,1052,1060,1067,1075,1091,1094,1097,1100,1156,1164,1172,1176],[10,1050,1051],{},"Hello and welcome! 👋",[10,1053,1054,1055,1059],{},"This series is a practical follow-up to ",[18,1056,1058],{"href":1057},"\u002Fposts\u002Fcode-mode-two-tools-and-an-mcp-can-save-your-llm-context","Code Mode, Two Tools, and an MCP Can Save Your LLM Context",". That article introduced the idea: instead of making a model orchestrate every dependent tool call, let it write the orchestration as code and return only the result needed for its next decision.",[10,1061,1062,1063,1066],{},"Here, we will build that idea step by step. We will start with a small local file transformation, move to an OpenAPI-described API, and then replace the trusted local evaluator based on the ",[54,1064,1065],{},"Function"," constructor with an isolated runtime. The final result will be a locally runnable MCP server that can search an API specification and execute a narrow request against the API.",[10,1068,405,1069,410,1072,24],{},[18,1070,409],{"href":1071},"\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web",[18,1073,414],{"href":1074},"\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fmcp-to-provide-additional-capabilities-to-the-ai-agent",[10,1076,1077,1078,1082,1083,1086,1087,1090],{},"Throughout the series, the ",[1079,1080,1081],"strong",{},"model"," generates tool calls or code, the ",[1079,1084,1085],{},"MCP client"," (or agent) runs the model loop, and the ",[1079,1088,1089],{},"MCP server"," provides the capabilities. Keeping these roles separate is important: the host, not generated code, defines which capabilities are available.",[10,1092,1093],{},"The central idea is simple: with direct MCP tools, the model must call one tool, receive the complete intermediate result, and then use that result to decide how to call the next tool. With Code Mode, the model writes the orchestration as code, the code accesses the capabilities it needs inside the execution environment, and the model receives only the desired final result to continue.",[10,1095,1096],{},"Code Mode is not automatically the right choice. Direct MCP tools remain simpler for small, obvious actions. The extra runtime is worthwhile when a task contains dependent calls, requires local data processing, or needs to navigate a large and evolving API surface, like an OpenAPI specification that can be larger than the model's context window.",[10,1098,1099],{},"Throughout this journey, we will:",[379,1101,1102,1111,1126,1136,1150],{},[382,1103,1104,1106,1107,1110],{},[1079,1105,5],{},": Build two direct ",[54,1108,1109],{},"Drive"," tools over a Markdown fixture and observe how the complete file content travels through the model's context before the next tool call.",[382,1112,1113,1116,1117,1119,1120,1122,1123,1125],{},[1079,1114,1115],{},"Let the Model Orchestrate Tools with a Local Code Runtime",": Replace the two direct tools with one generic ",[54,1118,54],{}," tool, expose a typed ",[54,1121,1109],{}," facade, and introduce the executor interface that later parts will replace. The local evaluator based on the ",[54,1124,1065],{}," constructor is intentionally a trusted development shortcut, not a production sandbox.",[382,1127,1128,1131,1132,1135],{},[1079,1129,1130],{},"Searching OpenAPI Specifications Without Filling Context",": Keep the OpenAPI document inside the server, resolve its local ",[54,1133,1134],{},"$ref"," values, and let generated code search a compact type facade instead of returning the complete specification to the model.",[382,1137,1138,1141,1142,1145,1146,1149],{},[1079,1139,1140],{},"Calling APIs with Code Mode and Returning Only What Matters",": Add a separate ",[54,1143,1144],{},"execute"," tool with a host-owned ",[54,1147,1148],{},"api.request()"," helper. We will validate request options, call the local MarketHub fixture, and return a narrow projection rather than the complete API response.",[382,1151,1152,1155],{},[1079,1153,1154],{},"Replacing the Evaluator with Isolated Cloudflare Workers",": Swap only the executor boundary for fresh Dynamic Workers. Search will run without outbound access, execute will use an allowlisted gateway, and credentials will remain outside generated code. We will also cover result bounds, resource limits, and host deadlines.",[10,1157,1158,1159,1163],{},"The companion repository, ",[1160,1161],"git-hub-link",{"repo":1162},"barbapapazes\u002Fcode-mode",", is an executable textbook for the series. Each article has a complete checkpoint branch, a small evaluation, and a focused diff from the previous step. I recommend that you check out a branch and inspect the implementation for a better understanding of the concepts, as the articles will not cover every detail.",[399,1165,1166],{"color":401,"icon":402},[10,1167,1168,1169,1171],{},"This series assumes familiarity with TypeScript, JavaScript promises, HTTP APIs, and basic MCP concepts. The local checkpoints contain no credentials. Parts 2 through 4 use a trusted local evaluator based on the ",[54,1170,1065],{}," constructor for development, while Part 5 provides a Cloudflare deployment scaffold and structural security evaluation.",[35,1173,1175],{"id":1174},"chapters","Chapters",[1177,1178],"series-chapters-list",{"className":1179},[1180,1181],"mx-auto","max-w-5xl",{"title":52,"searchDepth":78,"depth":78,"links":1183},[1184],{"id":1174,"depth":78,"text":1175},"8f6d8d8d-9cc8-4ed3-9f2d-4e3d0b7a4d91","Build an MCP server for an OpenAPI-described API, then replace a trusted local evaluator with isolated Cloudflare Dynamic Workers.",{"name":1188,"repository":1162},"Code Mode","I created this series to turn the Code Mode idea into a practical implementation. We will start with two ordinary MCP tools, move the orchestration into generated code, and finish by replacing a trusted local evaluator based on the Function constructor with isolated Cloudflare Dynamic Workers.",{},"\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers","---\ncontentId: 8f6d8d8d-9cc8-4ed3-9f2d-4e3d0b7a4d91\ntitle: Building Code Mode for APIs with MCP and Isolated Workers\nsubtitle: Build a context-efficient MCP server for OpenAPI-described APIs\ndescription: Build an MCP server for an OpenAPI-described API, then replace a trusted local evaluator with isolated Cloudflare Dynamic Workers.\ndate: 2026-07-12\ntopics:\n  - ai\n  - ai-agents\n  - mcp\n  - code-mode\n  - openapi\n  - cloudflare\n  - typescript\ngithub:\n  name: Code Mode\n  repository: barbapapazes\u002Fcode-mode\nmeetTheInstructor: I created this series to turn the Code Mode idea into a practical implementation. We will start with two ordinary MCP tools, move the orchestration into generated code, and finish by replacing a trusted local evaluator based on the Function constructor with isolated Cloudflare Dynamic Workers.\nseriesSlug: building-code-mode-for-apis-with-mcp-and-isolated-workers\n---\n\nHello and welcome! 👋\n\nThis series is a practical follow-up to [Code Mode, Two Tools, and an MCP Can Save Your LLM Context](\u002Fposts\u002Fcode-mode-two-tools-and-an-mcp-can-save-your-llm-context). That article introduced the idea: instead of making a model orchestrate every dependent tool call, let it write the orchestration as code and return only the result needed for its next decision.\n\nHere, we will build that idea step by step. We will start with a small local file transformation, move to an OpenAPI-described API, and then replace the trusted local evaluator based on the `Function` constructor with an isolated runtime. The final result will be a locally runnable MCP server that can search an API specification and execute a narrow request against the API.\n\nMCP fundamentals are outside the scope of this series. If you need an introduction to the protocol or to the basic relationship between an AI agent and an MCP server, begin with [AI Agents and MCP Server: Teaming Up for the Agentic Web](\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web), especially [its MCP server article](\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fmcp-to-provide-additional-capabilities-to-the-ai-agent).\n\nThroughout the series, the **model** generates tool calls or code, the **MCP client** (or agent) runs the model loop, and the **MCP server** provides the capabilities. Keeping these roles separate is important: the host, not generated code, defines which capabilities are available.\n\nThe central idea is simple: with direct MCP tools, the model must call one tool, receive the complete intermediate result, and then use that result to decide how to call the next tool. With Code Mode, the model writes the orchestration as code, the code accesses the capabilities it needs inside the execution environment, and the model receives only the desired final result to continue.\n\nCode Mode is not automatically the right choice. Direct MCP tools remain simpler for small, obvious actions. The extra runtime is worthwhile when a task contains dependent calls, requires local data processing, or needs to navigate a large and evolving API surface, like an OpenAPI specification that can be larger than the model's context window.\n\nThroughout this journey, we will:\n\n1. **Beyond One Tool Call at a Time: Introducing Code Mode**: Build two direct `Drive` tools over a Markdown fixture and observe how the complete file content travels through the model's context before the next tool call.\n2. **Let the Model Orchestrate Tools with a Local Code Runtime**: Replace the two direct tools with one generic `code` tool, expose a typed `Drive` facade, and introduce the executor interface that later parts will replace. The local evaluator based on the `Function` constructor is intentionally a trusted development shortcut, not a production sandbox.\n3. **Searching OpenAPI Specifications Without Filling Context**: Keep the OpenAPI document inside the server, resolve its local `$ref` values, and let generated code search a compact type facade instead of returning the complete specification to the model.\n4. **Calling APIs with Code Mode and Returning Only What Matters**: Add a separate `execute` tool with a host-owned `api.request()` helper. We will validate request options, call the local MarketHub fixture, and return a narrow projection rather than the complete API response.\n5. **Replacing the Evaluator with Isolated Cloudflare Workers**: Swap only the executor boundary for fresh Dynamic Workers. Search will run without outbound access, execute will use an allowlisted gateway, and credentials will remain outside generated code. We will also cover result bounds, resource limits, and host deadlines.\n\nThe companion repository, \u003CGitHubLink repo=\"barbapapazes\u002Fcode-mode\" \u002F>, is an executable textbook for the series. Each article has a complete checkpoint branch, a small evaluation, and a focused diff from the previous step. I recommend that you check out a branch and inspect the implementation for a better understanding of the concepts, as the articles will not cover every detail.\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nThis series assumes familiarity with TypeScript, JavaScript promises, HTTP APIs, and basic MCP concepts. The local checkpoints contain no credentials. Parts 2 through 4 use a trusted local evaluator based on the `Function` constructor for development, while Part 5 provides a Cloudflare deployment scaffold and structural security evaluation.\n::\n\n## Chapters\n\n::series-chapters-list\n---\nclass: mx-auto max-w-5xl\n---\n::\n",{"title":1046,"description":1186},{"loc":1191},"series\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers","Build a context-efficient MCP server for OpenAPI-described APIs",[1198,1199,1200,1201,1202,1203,1204],"ai","ai-agents","mcp","code-mode","openapi","cloudflare","typescript","WgDRYOu5CDIYY78O1GSEOv6BKbIsrTVwVf8cTOkdsOA",[1207,1209,1215,1221,1227],{"contentId":1028,"title":5,"description":1030,"path":1036,"part":60,"github":1208,"topics":1034},{"branch":1033},{"contentId":1210,"title":1115,"description":1211,"path":1212,"part":78,"github":1213,"topics":1034},"2a9e7d4c-1f6b-4c83-9d52-7e0a6b3f4189","Build a minimal trusted local Code Mode runtime with a typed Drive facade and an executor seam ready for isolation.","\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Flet-the-model-orchestrate-tools-with-a-local-code-runtime",{"branch":1214},"part-2-generic-code-mode",{"contentId":1216,"title":1130,"description":1217,"path":1218,"part":85,"github":1219,"topics":1034},"8c4a1e72-bf39-4d65-a08e-2c7f91b6d543","Keep an OpenAPI specification server-side and search a compact typed facade without returning the complete document.","\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Fsearching-openapi-specification-without-filling-the-context",{"branch":1220},"part-3-search",{"contentId":1222,"title":1140,"description":1223,"path":1224,"part":108,"github":1225,"topics":1034},"1d7b5e93-6a24-4f80-bc19-3e8d0a572f16","Use a host-owned API request helper to validate and execute a narrow API call, then return only the useful projection.","\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Fcalling-apis-with-code-mode-and-returning-only-what-matters",{"branch":1226},"part-4-local-execute",{"contentId":1228,"title":1154,"description":1229,"path":1230,"part":113,"github":1231,"topics":1034},"5e3a9c71-2b48-4d06-8f95-c7a1e0b6342d","Replace a trusted local Function evaluator with isolated Cloudflare Dynamic Workers, controlled outbound access, and bounded execution results.","\u002Fseries\u002Fbuilding-code-mode-for-apis-with-mcp-and-isolated-workers\u002Freplacing-local-eval-with-isolated-cloudflare-workers",{"branch":1232},"part-5-dynamic-workers",1795016691269]