[{"data":1,"prerenderedAt":2834},["ShallowReactive",2],{"navigation_docs":3,"-advanced-code-mode":139,"-advanced-code-mode-surround":2829},[4,40,65,110],{"title":5,"path":6,"stem":7,"children":8,"page":39},"Getting Started","\u002Fgetting-started","1.getting-started",[9,14,19,24,29,34],{"title":10,"path":11,"stem":12,"icon":13},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-book-open",{"title":15,"path":16,"stem":17,"icon":18},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":20,"path":21,"stem":22,"icon":23},"Configuration","\u002Fgetting-started\u002Fconfiguration","1.getting-started\u002F3.configuration","i-lucide-settings",{"title":25,"path":26,"stem":27,"icon":28},"MCP Inspector","\u002Fgetting-started\u002Finspector","1.getting-started\u002F4.inspector","i-lucide-circuit-board",{"title":30,"path":31,"stem":32,"icon":33},"Connection","\u002Fgetting-started\u002Fconnection","1.getting-started\u002F5.connection","i-lucide-plug",{"title":35,"path":36,"stem":37,"icon":38},"Agent Skills","\u002Fgetting-started\u002Fagent-skills","1.getting-started\u002F6.agent-skills","i-lucide-sparkles",false,{"title":41,"path":42,"stem":43,"children":44,"page":39},"Core Concepts","\u002Fcore-concepts","2.core-concepts",[45,50,55,60],{"title":46,"path":47,"stem":48,"icon":49},"Tools","\u002Fcore-concepts\u002Ftools","2.core-concepts\u002F2.tools","i-lucide-wrench",{"title":51,"path":52,"stem":53,"icon":54},"Resources","\u002Fcore-concepts\u002Fresources","2.core-concepts\u002F3.resources","i-lucide-package",{"title":56,"path":57,"stem":58,"icon":59},"Prompts","\u002Fcore-concepts\u002Fprompts","2.core-concepts\u002F4.prompts","i-lucide-message-square",{"title":61,"path":62,"stem":63,"icon":64},"Handlers","\u002Fcore-concepts\u002Fhandlers","2.core-concepts\u002F5.handlers","i-lucide-server",{"title":66,"path":67,"stem":68,"children":69,"page":39},"Advanced Topics","\u002Fadvanced","3.advanced",[70,75,80,85,90,95,100,105],{"title":71,"path":72,"stem":73,"icon":74},"Custom Paths","\u002Fadvanced\u002Fcustom-paths","3.advanced\u002F1.custom-paths","i-lucide-folder",{"title":76,"path":77,"stem":78,"icon":79},"Middleware","\u002Fadvanced\u002Fmiddleware","3.advanced\u002F2.middleware","i-lucide-shield",{"title":81,"path":82,"stem":83,"icon":84},"TypeScript","\u002Fadvanced\u002Ftypescript","3.advanced\u002F3.typescript","i-lucide-type",{"title":86,"path":87,"stem":88,"icon":89},"Hooks","\u002Fadvanced\u002Fhooks","3.advanced\u002F4.hooks","i-lucide-webhook",{"title":91,"path":92,"stem":93,"icon":94},"MCP Evals","\u002Fadvanced\u002Fevals","3.advanced\u002F5.evals","i-lucide-flask-conical",{"title":96,"path":97,"stem":98,"icon":99},"Sessions","\u002Fadvanced\u002Fsessions","3.advanced\u002F6.sessions","i-lucide-database",{"title":101,"path":102,"stem":103,"icon":104},"Dynamic Definitions","\u002Fadvanced\u002Fdynamic-definitions","3.advanced\u002F7.dynamic-definitions","i-lucide-toggle-right",{"title":106,"path":107,"stem":108,"icon":109},"Code Mode","\u002Fadvanced\u002Fcode-mode","3.advanced\u002F8.code-mode","i-lucide-code",{"title":111,"path":112,"stem":113,"children":114,"page":39},"Examples","\u002Fexamples","4.examples",[115,120,125,130,135],{"title":116,"path":117,"stem":118,"icon":119},"Authentication","\u002Fexamples\u002Fauthentication","4.examples\u002F1.authentication","i-lucide-shield-check",{"title":121,"path":122,"stem":123,"icon":124},"API Integration","\u002Fexamples\u002Fapi-integration","4.examples\u002F2.api-integration","i-lucide-globe",{"title":126,"path":127,"stem":128,"icon":129},"Common Patterns","\u002Fexamples\u002Fcommon-patterns","4.examples\u002F3.common-patterns","i-lucide-lightbulb",{"title":131,"path":132,"stem":133,"icon":134},"File Operations","\u002Fexamples\u002Ffile-operations","4.examples\u002F4.file-operations","i-lucide-file",{"title":136,"path":137,"stem":138,"icon":59},"Prompt Examples","\u002Fexamples\u002Fprompt-examples","4.examples\u002F5.prompt-examples",{"id":140,"title":106,"body":141,"description":2821,"extension":2822,"links":2823,"meta":2824,"navigation":2825,"path":107,"seo":2826,"stem":108,"__hash__":2828},"docs\u002F3.advanced\u002F8.code-mode.md",{"type":142,"value":143,"toc":2792},"minimark",[144,149,157,244,318,327,331,338,343,353,446,453,466,470,473,514,518,522,533,599,603,610,751,757,761,764,786,790,805,1415,1419,1426,1521,1603,1606,1612,1629,1674,1677,1729,1734,1738,1744,1814,1823,1832,1836,1843,1847,1859,1901,1905,1908,1945,1949,1952,1980,1983,1987,2078,2082,2085,2115,2119,2126,2130,2133,2610,2629,2633,2639,2697,2706,2710,2716,2761,2765,2788],[145,146,148],"h2",{"id":147},"what-is-code-mode","What is Code Mode?",[150,151,152,153,156],"p",{},"Code Mode replaces the traditional multi-turn tool calling pattern with a single ",[154,155,154],"code",{}," tool. Instead of the LLM calling tools one at a time — each requiring a round-trip — it writes JavaScript code that orchestrates multiple tools in one execution.",[158,159,160],"code-collapse",{},[161,162,168],"pre",{"className":163,"code":164,"filename":165,"language":166,"meta":167,"style":167},"language-txt shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","Enable Code Mode in my Nuxt MCP server (@nuxtjs\u002Fmcp-toolkit).\n\n- Install secure-exec: pnpm add secure-exec\n- Set experimental_codeMode: true on the handler in server\u002Fmcp\u002Findex.ts (via defineMcpHandler)\n- Code Mode replaces all registered tools with a single 'code' tool\n- The LLM writes JavaScript that calls tools via a codemode object (e.g. await codemode.listUsers())\n- This reduces round-trips and token usage — especially with many tools (10+ tools saves 50%+ tokens)\n- Code runs in a secure V8 sandbox (workerd) — no access to filesystem, network, or Node APIs\n- If there are many tools (10+), consider progressive mode (experimental_codeMode: { progressive: true }) to keep both individual tools and the code tool — for fewer tools, standard mode is sufficient\n- Code Mode is experimental — the API may evolve\n\nDocs: https:\u002F\u002Fmcp-toolkit.nuxt.dev\u002Fadvanced\u002Fcode-mode\n","Prompt","txt","",[154,169,170,178,185,191,197,203,209,215,221,227,233,238],{"__ignoreMap":167},[171,172,175],"span",{"class":173,"line":174},"line",1,[171,176,177],{},"Enable Code Mode in my Nuxt MCP server (@nuxtjs\u002Fmcp-toolkit).\n",[171,179,181],{"class":173,"line":180},2,[171,182,184],{"emptyLinePlaceholder":183},true,"\n",[171,186,188],{"class":173,"line":187},3,[171,189,190],{},"- Install secure-exec: pnpm add secure-exec\n",[171,192,194],{"class":173,"line":193},4,[171,195,196],{},"- Set experimental_codeMode: true on the handler in server\u002Fmcp\u002Findex.ts (via defineMcpHandler)\n",[171,198,200],{"class":173,"line":199},5,[171,201,202],{},"- Code Mode replaces all registered tools with a single 'code' tool\n",[171,204,206],{"class":173,"line":205},6,[171,207,208],{},"- The LLM writes JavaScript that calls tools via a codemode object (e.g. await codemode.listUsers())\n",[171,210,212],{"class":173,"line":211},7,[171,213,214],{},"- This reduces round-trips and token usage — especially with many tools (10+ tools saves 50%+ tokens)\n",[171,216,218],{"class":173,"line":217},8,[171,219,220],{},"- Code runs in a secure V8 sandbox (workerd) — no access to filesystem, network, or Node APIs\n",[171,222,224],{"class":173,"line":223},9,[171,225,226],{},"- If there are many tools (10+), consider progressive mode (experimental_codeMode: { progressive: true }) to keep both individual tools and the code tool — for fewer tools, standard mode is sufficient\n",[171,228,230],{"class":173,"line":229},10,[171,231,232],{},"- Code Mode is experimental — the API may evolve\n",[171,234,236],{"class":173,"line":235},11,[171,237,184],{"emptyLinePlaceholder":183},[171,239,241],{"class":173,"line":240},12,[171,242,243],{},"Docs: https:\u002F\u002Fmcp-toolkit.nuxt.dev\u002Fadvanced\u002Fcode-mode\n",[245,246,247,261],"table",{},[248,249,250],"thead",{},[251,252,253,256,259],"tr",{},[254,255],"th",{},[254,257,258],{},"Traditional MCP",[254,260,106],{},[262,263,264,279,292,305],"tbody",{},[251,265,266,273,276],{},[267,268,269],"td",{},[270,271,272],"strong",{},"Pattern",[267,274,275],{},"LLM calls tools one by one",[267,277,278],{},"LLM writes JS that calls tools",[251,280,281,286,289],{},[267,282,283],{},[270,284,285],{},"Round-trips",[267,287,288],{},"One per tool call",[267,290,291],{},"One for all operations",[251,293,294,299,302],{},[267,295,296],{},[270,297,298],{},"Complex logic",[267,300,301],{},"Multiple turns for conditionals\u002Floops",[267,303,304],{},"Native JS control flow",[251,306,307,312,315],{},[267,308,309],{},[270,310,311],{},"Token usage",[267,313,314],{},"Higher (repeated context)",[267,316,317],{},"Lower (single invocation)",[319,320,322,323,326],"callout",{"color":321,"icon":94},"warning","Code Mode is ",[270,324,325],{},"experimental for now",". The API may evolve as we stabilize this feature based on feedback.",[145,328,330],{"id":329},"why-code-mode","Why Code Mode?",[150,332,333,334,337],{},"Every LLM round-trip resends ",[270,335,336],{},"all tool descriptions"," as context. With traditional MCP, a task that requires 5 steps with 50 tools sends the full tool catalog 5 times — that's 15,500 tokens just for tool descriptions. Code Mode sends compact TypeScript signatures in a single tool, cutting that to ~3,000 tokens.",[339,340,342],"h3",{"id":341},"the-scaling-problem","The scaling problem",[150,344,345,346,349,350,352],{},"In traditional MCP, tool description overhead scales as ",[270,347,348],{},"tools × round-trips",". Code Mode replaces all tools with one ",[154,351,154],{}," tool containing compact type signatures — and usually needs fewer round-trips.",[245,354,355,369],{},[248,356,357],{},[251,358,359,362,364,366],{},[254,360,361],{},"Server size",[254,363,258],{},[254,365,106],{},[254,367,368],{},"Savings",[262,370,371,390,409,428],{},[251,372,373,379,382,385],{},[267,374,375,378],{},[270,376,377],{},"10 tools",", 3-step task",[267,380,381],{},"~1,860 tokens in tool descriptions",[267,383,384],{},"~920 tokens",[267,386,387],{},[270,388,389],{},"-51%",[251,391,392,398,401,404],{},[267,393,394,397],{},[270,395,396],{},"25 tools",", 4-step task",[267,399,400],{},"~6,200 tokens",[267,402,403],{},"~1,700 tokens",[267,405,406],{},[270,407,408],{},"-73%",[251,410,411,417,420,423],{},[267,412,413,416],{},[270,414,415],{},"50 tools",", 5-step task",[267,418,419],{},"~15,500 tokens",[267,421,422],{},"~3,000 tokens",[267,424,425],{},[270,426,427],{},"-81%",[251,429,430,435,438,441],{},[267,431,432,416],{},[270,433,434],{},"100 tools",[267,436,437],{},"~31,000 tokens",[267,439,440],{},"~5,600 tokens",[267,442,443],{},[270,444,445],{},"-82%",[150,447,448,449,452],{},"These numbers represent tool description overhead only. Total savings depend on the task, but the trend is clear: ",[270,450,451],{},"the more tools you have, the bigger the savings",".",[319,454,457,458,461,462,465],{"color":455,"icon":456},"primary","i-lucide-zap","On a real benchmark with Claude Sonnet (9 tools, 7 tasks), Code Mode saved ",[270,459,460],{},"15% of total tokens overall"," and up to ",[270,463,464],{},"33% on complex batch operations"," — collapsing 8 tool calls into a single JavaScript block.",[339,467,469],{"id":468},"beyond-token-savings","Beyond token savings",[150,471,472],{},"Code Mode also unlocks patterns that traditional MCP cannot do efficiently:",[474,475,476,487,496,505],"ul",{},[477,478,479,482,483,486],"li",{},[270,480,481],{},"Parallel execution"," — ",[154,484,485],{},"Promise.all()"," for independent calls instead of sequential round-trips",[477,488,489,482,492,495],{},[270,490,491],{},"Conditional logic",[154,493,494],{},"if\u002Felse"," branching without an extra LLM step",[477,497,498,482,501,504],{},[270,499,500],{},"Loops",[154,502,503],{},"for"," over data instead of repeating tool calls one by one",[477,506,507,482,510,513],{},[270,508,509],{},"Error handling",[154,511,512],{},"try\u002Fcatch"," to handle failures mid-workflow",[145,515,517],{"id":516},"setup","Setup",[339,519,521],{"id":520},"_1-install-secure-exec","1. Install secure-exec",[150,523,524,525,532],{},"Code Mode uses ",[526,527,531],"a",{"href":528,"rel":529},"https:\u002F\u002Fgithub.com\u002Fnicolo-ribaudo\u002Fsecure-exec",[530],"nofollow","secure-exec"," to run LLM-generated code in a secure V8 isolate:",[534,535,536,556,571,585],"code-group",{},[161,537,542],{"className":538,"code":539,"filename":540,"language":541,"meta":167,"style":167},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm add secure-exec\n","pnpm","bash",[154,543,544],{"__ignoreMap":167},[171,545,546,549,553],{"class":173,"line":174},[171,547,540],{"class":548},"sBMFI",[171,550,552],{"class":551},"sfazB"," add",[171,554,555],{"class":551}," secure-exec\n",[161,557,560],{"className":538,"code":558,"filename":559,"language":541,"meta":167,"style":167},"npm install secure-exec\n","npm",[154,561,562],{"__ignoreMap":167},[171,563,564,566,569],{"class":173,"line":174},[171,565,559],{"class":548},[171,567,568],{"class":551}," install",[171,570,555],{"class":551},[161,572,575],{"className":538,"code":573,"filename":574,"language":541,"meta":167,"style":167},"yarn add secure-exec\n","yarn",[154,576,577],{"__ignoreMap":167},[171,578,579,581,583],{"class":173,"line":174},[171,580,574],{"class":548},[171,582,552],{"class":551},[171,584,555],{"class":551},[161,586,589],{"className":538,"code":587,"filename":588,"language":541,"meta":167,"style":167},"bun add secure-exec\n","bun",[154,590,591],{"__ignoreMap":167},[171,592,593,595,597],{"class":173,"line":174},[171,594,588],{"class":548},[171,596,552],{"class":551},[171,598,555],{"class":551},[339,600,602],{"id":601},"_2-enable-on-a-handler","2. Enable on a handler",[150,604,605,606,609],{},"Add ",[154,607,608],{},"experimental_codeMode"," to any handler:",[534,611,612,671],{},[161,613,618],{"className":614,"code":615,"filename":616,"language":617,"meta":167,"style":167},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F server\u002Fmcp\u002Findex.ts\nexport default defineMcpHandler({\n  experimental_codeMode: true,\n})\n","Default handler","typescript",[154,619,620,626,647,663],{"__ignoreMap":167},[171,621,622],{"class":173,"line":174},[171,623,625],{"class":624},"sHwdD","\u002F\u002F server\u002Fmcp\u002Findex.ts\n",[171,627,628,632,635,639,643],{"class":173,"line":180},[171,629,631],{"class":630},"s7zQu","export",[171,633,634],{"class":630}," default",[171,636,638],{"class":637},"s2Zo4"," defineMcpHandler",[171,640,642],{"class":641},"sTEyZ","(",[171,644,646],{"class":645},"sMK4o","{\n",[171,648,649,653,656,660],{"class":173,"line":187},[171,650,652],{"class":651},"swJcz","  experimental_codeMode",[171,654,655],{"class":645},":",[171,657,659],{"class":658},"sfNiH"," true",[171,661,662],{"class":645},",\n",[171,664,665,668],{"class":173,"line":193},[171,666,667],{"class":645},"}",[171,669,670],{"class":641},")\n",[161,672,675],{"className":614,"code":673,"filename":674,"language":617,"meta":167,"style":167},"\u002F\u002F server\u002Fmcp\u002Fai-agent.ts\nexport default defineMcpHandler({\n  name: 'ai-agent',\n  experimental_codeMode: true,\n  tools: [getUserTool, listTodosTool, createTodoTool],\n})\n","Custom handler",[154,676,677,682,694,712,722,745],{"__ignoreMap":167},[171,678,679],{"class":173,"line":174},[171,680,681],{"class":624},"\u002F\u002F server\u002Fmcp\u002Fai-agent.ts\n",[171,683,684,686,688,690,692],{"class":173,"line":180},[171,685,631],{"class":630},[171,687,634],{"class":630},[171,689,638],{"class":637},[171,691,642],{"class":641},[171,693,646],{"class":645},[171,695,696,699,701,704,707,710],{"class":173,"line":187},[171,697,698],{"class":651},"  name",[171,700,655],{"class":645},[171,702,703],{"class":645}," '",[171,705,706],{"class":551},"ai-agent",[171,708,709],{"class":645},"'",[171,711,662],{"class":645},[171,713,714,716,718,720],{"class":173,"line":193},[171,715,652],{"class":651},[171,717,655],{"class":645},[171,719,659],{"class":658},[171,721,662],{"class":645},[171,723,724,727,729,732,735,738,740,743],{"class":173,"line":199},[171,725,726],{"class":651},"  tools",[171,728,655],{"class":645},[171,730,731],{"class":641}," [getUserTool",[171,733,734],{"class":645},",",[171,736,737],{"class":641}," listTodosTool",[171,739,734],{"class":645},[171,741,742],{"class":641}," createTodoTool]",[171,744,662],{"class":645},[171,746,747,749],{"class":173,"line":205},[171,748,667],{"class":645},[171,750,670],{"class":641},[150,752,753,754,756],{},"That's it. The module replaces all your tools with a single ",[154,755,154],{}," tool that the LLM uses to orchestrate them.",[145,758,760],{"id":759},"how-it-works","How It Works",[150,762,763],{},"When Code Mode is enabled:",[765,766,767,770,776,783],"ol",{},[477,768,769],{},"All registered tools are converted to TypeScript type definitions",[477,771,772,773,775],{},"A ",[154,774,154],{}," tool is created with those types embedded in its description",[477,777,778,779,782],{},"The LLM writes JavaScript using a ",[154,780,781],{},"codemode"," object to call tools",[477,784,785],{},"The code runs in a V8 isolate with only RPC access to your tools",[339,787,789],{"id":788},"example-what-the-llm-generates","Example: what the LLM generates",[150,791,792,793,796,797,800,801,804],{},"Given tools ",[154,794,795],{},"get-user",", ",[154,798,799],{},"list-todos",", and ",[154,802,803],{},"create-todo",", the LLM receives type definitions and writes code like:",[534,806,807,1019,1192],{},[161,808,813],{"className":809,"code":810,"filename":811,"language":812,"meta":167,"style":167},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const user = await codemode.get_user({ id: \"123\" });\nconst todos = await codemode.list_todos({ userId: user.id });\n\nif (todos.length === 0) {\n  await codemode.create_todo({\n    title: \"Welcome task\",\n    userId: user.id,\n  });\n}\n\nreturn { user, todos };\n","Sequential calls","javascript",[154,814,815,866,907,911,936,952,968,984,993,998,1002],{"__ignoreMap":167},[171,816,817,821,824,827,830,833,835,838,840,843,846,848,851,854,857,860,863],{"class":173,"line":174},[171,818,820],{"class":819},"spNyl","const",[171,822,823],{"class":641}," user ",[171,825,826],{"class":645},"=",[171,828,829],{"class":630}," await",[171,831,832],{"class":641}," codemode",[171,834,452],{"class":645},[171,836,837],{"class":637},"get_user",[171,839,642],{"class":641},[171,841,842],{"class":645},"{",[171,844,845],{"class":651}," id",[171,847,655],{"class":645},[171,849,850],{"class":645}," \"",[171,852,853],{"class":551},"123",[171,855,856],{"class":645},"\"",[171,858,859],{"class":645}," }",[171,861,862],{"class":641},")",[171,864,865],{"class":645},";\n",[171,867,868,870,873,875,877,879,881,884,886,888,891,893,896,898,901,903,905],{"class":173,"line":180},[171,869,820],{"class":819},[171,871,872],{"class":641}," todos ",[171,874,826],{"class":645},[171,876,829],{"class":630},[171,878,832],{"class":641},[171,880,452],{"class":645},[171,882,883],{"class":637},"list_todos",[171,885,642],{"class":641},[171,887,842],{"class":645},[171,889,890],{"class":651}," userId",[171,892,655],{"class":645},[171,894,895],{"class":641}," user",[171,897,452],{"class":645},[171,899,900],{"class":641},"id ",[171,902,667],{"class":645},[171,904,862],{"class":641},[171,906,865],{"class":645},[171,908,909],{"class":173,"line":187},[171,910,184],{"emptyLinePlaceholder":183},[171,912,913,916,919,921,924,927,931,934],{"class":173,"line":193},[171,914,915],{"class":630},"if",[171,917,918],{"class":641}," (todos",[171,920,452],{"class":645},[171,922,923],{"class":641},"length ",[171,925,926],{"class":645},"===",[171,928,930],{"class":929},"sbssI"," 0",[171,932,933],{"class":641},") ",[171,935,646],{"class":645},[171,937,938,941,943,945,948,950],{"class":173,"line":199},[171,939,940],{"class":630},"  await",[171,942,832],{"class":641},[171,944,452],{"class":645},[171,946,947],{"class":637},"create_todo",[171,949,642],{"class":651},[171,951,646],{"class":645},[171,953,954,957,959,961,964,966],{"class":173,"line":205},[171,955,956],{"class":651},"    title",[171,958,655],{"class":645},[171,960,850],{"class":645},[171,962,963],{"class":551},"Welcome task",[171,965,856],{"class":645},[171,967,662],{"class":645},[171,969,970,973,975,977,979,982],{"class":173,"line":211},[171,971,972],{"class":651},"    userId",[171,974,655],{"class":645},[171,976,895],{"class":641},[171,978,452],{"class":645},[171,980,981],{"class":641},"id",[171,983,662],{"class":645},[171,985,986,989,991],{"class":173,"line":217},[171,987,988],{"class":645},"  }",[171,990,862],{"class":651},[171,992,865],{"class":645},[171,994,995],{"class":173,"line":223},[171,996,997],{"class":645},"}\n",[171,999,1000],{"class":173,"line":229},[171,1001,184],{"emptyLinePlaceholder":183},[171,1003,1004,1007,1010,1012,1014,1016],{"class":173,"line":235},[171,1005,1006],{"class":630},"return",[171,1008,1009],{"class":645}," {",[171,1011,895],{"class":641},[171,1013,734],{"class":645},[171,1015,872],{"class":641},[171,1017,1018],{"class":645},"};\n",[161,1020,1023],{"className":809,"code":1021,"filename":1022,"language":812,"meta":167,"style":167},"const [users, products, orders] = await Promise.all([\n  codemode.list_users(),\n  codemode.list_products(),\n  codemode.list_orders({ status: \"pending\" }),\n]);\n\nreturn {\n  userCount: users.length,\n  productCount: products.length,\n  pendingOrders: orders.length,\n};\n","Parallel calls",[154,1024,1025,1064,1079,1092,1123,1130,1134,1141,1158,1173,1188],{"__ignoreMap":167},[171,1026,1027,1029,1032,1035,1037,1040,1042,1045,1048,1051,1053,1056,1058,1061],{"class":173,"line":174},[171,1028,820],{"class":819},[171,1030,1031],{"class":645}," [",[171,1033,1034],{"class":641},"users",[171,1036,734],{"class":645},[171,1038,1039],{"class":641}," products",[171,1041,734],{"class":645},[171,1043,1044],{"class":641}," orders",[171,1046,1047],{"class":645},"]",[171,1049,1050],{"class":645}," =",[171,1052,829],{"class":630},[171,1054,1055],{"class":548}," Promise",[171,1057,452],{"class":645},[171,1059,1060],{"class":637},"all",[171,1062,1063],{"class":641},"([\n",[171,1065,1066,1069,1071,1074,1077],{"class":173,"line":180},[171,1067,1068],{"class":641},"  codemode",[171,1070,452],{"class":645},[171,1072,1073],{"class":637},"list_users",[171,1075,1076],{"class":641},"()",[171,1078,662],{"class":645},[171,1080,1081,1083,1085,1088,1090],{"class":173,"line":187},[171,1082,1068],{"class":641},[171,1084,452],{"class":645},[171,1086,1087],{"class":637},"list_products",[171,1089,1076],{"class":641},[171,1091,662],{"class":645},[171,1093,1094,1096,1098,1101,1103,1105,1108,1110,1112,1115,1117,1119,1121],{"class":173,"line":193},[171,1095,1068],{"class":641},[171,1097,452],{"class":645},[171,1099,1100],{"class":637},"list_orders",[171,1102,642],{"class":641},[171,1104,842],{"class":645},[171,1106,1107],{"class":651}," status",[171,1109,655],{"class":645},[171,1111,850],{"class":645},[171,1113,1114],{"class":551},"pending",[171,1116,856],{"class":645},[171,1118,859],{"class":645},[171,1120,862],{"class":641},[171,1122,662],{"class":645},[171,1124,1125,1128],{"class":173,"line":199},[171,1126,1127],{"class":641},"])",[171,1129,865],{"class":645},[171,1131,1132],{"class":173,"line":205},[171,1133,184],{"emptyLinePlaceholder":183},[171,1135,1136,1138],{"class":173,"line":211},[171,1137,1006],{"class":630},[171,1139,1140],{"class":645}," {\n",[171,1142,1143,1146,1148,1151,1153,1156],{"class":173,"line":217},[171,1144,1145],{"class":651},"  userCount",[171,1147,655],{"class":645},[171,1149,1150],{"class":641}," users",[171,1152,452],{"class":645},[171,1154,1155],{"class":641},"length",[171,1157,662],{"class":645},[171,1159,1160,1163,1165,1167,1169,1171],{"class":173,"line":223},[171,1161,1162],{"class":651},"  productCount",[171,1164,655],{"class":645},[171,1166,1039],{"class":641},[171,1168,452],{"class":645},[171,1170,1155],{"class":641},[171,1172,662],{"class":645},[171,1174,1175,1178,1180,1182,1184,1186],{"class":173,"line":229},[171,1176,1177],{"class":651},"  pendingOrders",[171,1179,655],{"class":645},[171,1181,1044],{"class":641},[171,1183,452],{"class":645},[171,1185,1155],{"class":641},[171,1187,662],{"class":645},[171,1189,1190],{"class":173,"line":235},[171,1191,1018],{"class":645},[161,1193,1196],{"className":809,"code":1194,"filename":1195,"language":812,"meta":167,"style":167},"const users = await codemode.list_users();\nconst results = [];\n\nfor (const user of users) {\n  const todos = await codemode.list_todos({ userId: user.id });\n  if (todos.some(t => t.overdue)) {\n    await codemode.send_reminder({ userId: user.id });\n    results.push(user.name);\n  }\n}\n\nreturn { reminded: results };\n","Loop + conditional",[154,1197,1198,1219,1233,1237,1256,1294,1331,1363,1387,1392,1396,1400],{"__ignoreMap":167},[171,1199,1200,1202,1205,1207,1209,1211,1213,1215,1217],{"class":173,"line":174},[171,1201,820],{"class":819},[171,1203,1204],{"class":641}," users ",[171,1206,826],{"class":645},[171,1208,829],{"class":630},[171,1210,832],{"class":641},[171,1212,452],{"class":645},[171,1214,1073],{"class":637},[171,1216,1076],{"class":641},[171,1218,865],{"class":645},[171,1220,1221,1223,1226,1228,1231],{"class":173,"line":180},[171,1222,820],{"class":819},[171,1224,1225],{"class":641}," results ",[171,1227,826],{"class":645},[171,1229,1230],{"class":641}," []",[171,1232,865],{"class":645},[171,1234,1235],{"class":173,"line":187},[171,1236,184],{"emptyLinePlaceholder":183},[171,1238,1239,1241,1244,1246,1248,1251,1254],{"class":173,"line":193},[171,1240,503],{"class":630},[171,1242,1243],{"class":641}," (",[171,1245,820],{"class":819},[171,1247,823],{"class":641},[171,1249,1250],{"class":645},"of",[171,1252,1253],{"class":641}," users) ",[171,1255,646],{"class":645},[171,1257,1258,1261,1264,1266,1268,1270,1272,1274,1276,1278,1280,1282,1284,1286,1288,1290,1292],{"class":173,"line":199},[171,1259,1260],{"class":819},"  const",[171,1262,1263],{"class":641}," todos",[171,1265,1050],{"class":645},[171,1267,829],{"class":630},[171,1269,832],{"class":641},[171,1271,452],{"class":645},[171,1273,883],{"class":637},[171,1275,642],{"class":651},[171,1277,842],{"class":645},[171,1279,890],{"class":651},[171,1281,655],{"class":645},[171,1283,895],{"class":641},[171,1285,452],{"class":645},[171,1287,981],{"class":641},[171,1289,859],{"class":645},[171,1291,862],{"class":651},[171,1293,865],{"class":645},[171,1295,1296,1299,1301,1304,1306,1309,1311,1315,1318,1321,1323,1326,1329],{"class":173,"line":205},[171,1297,1298],{"class":630},"  if",[171,1300,1243],{"class":651},[171,1302,1303],{"class":641},"todos",[171,1305,452],{"class":645},[171,1307,1308],{"class":637},"some",[171,1310,642],{"class":651},[171,1312,1314],{"class":1313},"sHdIc","t",[171,1316,1317],{"class":819}," =>",[171,1319,1320],{"class":641}," t",[171,1322,452],{"class":645},[171,1324,1325],{"class":641},"overdue",[171,1327,1328],{"class":651},")) ",[171,1330,646],{"class":645},[171,1332,1333,1336,1338,1340,1343,1345,1347,1349,1351,1353,1355,1357,1359,1361],{"class":173,"line":211},[171,1334,1335],{"class":630},"    await",[171,1337,832],{"class":641},[171,1339,452],{"class":645},[171,1341,1342],{"class":637},"send_reminder",[171,1344,642],{"class":651},[171,1346,842],{"class":645},[171,1348,890],{"class":651},[171,1350,655],{"class":645},[171,1352,895],{"class":641},[171,1354,452],{"class":645},[171,1356,981],{"class":641},[171,1358,859],{"class":645},[171,1360,862],{"class":651},[171,1362,865],{"class":645},[171,1364,1365,1368,1370,1373,1375,1378,1380,1383,1385],{"class":173,"line":217},[171,1366,1367],{"class":641},"    results",[171,1369,452],{"class":645},[171,1371,1372],{"class":637},"push",[171,1374,642],{"class":651},[171,1376,1377],{"class":641},"user",[171,1379,452],{"class":645},[171,1381,1382],{"class":641},"name",[171,1384,862],{"class":651},[171,1386,865],{"class":645},[171,1388,1389],{"class":173,"line":223},[171,1390,1391],{"class":645},"  }\n",[171,1393,1394],{"class":173,"line":229},[171,1395,997],{"class":645},[171,1397,1398],{"class":173,"line":235},[171,1399,184],{"emptyLinePlaceholder":183},[171,1401,1402,1404,1406,1409,1411,1413],{"class":173,"line":240},[171,1403,1006],{"class":630},[171,1405,1009],{"class":645},[171,1407,1408],{"class":651}," reminded",[171,1410,655],{"class":645},[171,1412,1225],{"class":641},[171,1414,1018],{"class":645},[145,1416,1418],{"id":1417},"configuration-options","Configuration Options",[150,1420,1421,1422,1425],{},"Pass an options object instead of ",[154,1423,1424],{},"true"," for fine-grained control:",[161,1427,1430],{"className":614,"code":1428,"filename":1429,"language":617,"meta":167,"style":167},"export default defineMcpHandler({\n  experimental_codeMode: {\n    memoryLimit: 64,\n    cpuTimeLimitMs: 10_000,\n    maxResultSize: 102_400,\n    progressive: false,\n    description: undefined,\n  },\n})\n","server\u002Fmcp\u002Findex.ts",[154,1431,1432,1444,1452,1464,1476,1488,1500,1510,1515],{"__ignoreMap":167},[171,1433,1434,1436,1438,1440,1442],{"class":173,"line":174},[171,1435,631],{"class":630},[171,1437,634],{"class":630},[171,1439,638],{"class":637},[171,1441,642],{"class":641},[171,1443,646],{"class":645},[171,1445,1446,1448,1450],{"class":173,"line":180},[171,1447,652],{"class":651},[171,1449,655],{"class":645},[171,1451,1140],{"class":645},[171,1453,1454,1457,1459,1462],{"class":173,"line":187},[171,1455,1456],{"class":651},"    memoryLimit",[171,1458,655],{"class":645},[171,1460,1461],{"class":929}," 64",[171,1463,662],{"class":645},[171,1465,1466,1469,1471,1474],{"class":173,"line":193},[171,1467,1468],{"class":651},"    cpuTimeLimitMs",[171,1470,655],{"class":645},[171,1472,1473],{"class":929}," 10_000",[171,1475,662],{"class":645},[171,1477,1478,1481,1483,1486],{"class":173,"line":199},[171,1479,1480],{"class":651},"    maxResultSize",[171,1482,655],{"class":645},[171,1484,1485],{"class":929}," 102_400",[171,1487,662],{"class":645},[171,1489,1490,1493,1495,1498],{"class":173,"line":205},[171,1491,1492],{"class":651},"    progressive",[171,1494,655],{"class":645},[171,1496,1497],{"class":658}," false",[171,1499,662],{"class":645},[171,1501,1502,1505,1507],{"class":173,"line":211},[171,1503,1504],{"class":651},"    description",[171,1506,655],{"class":645},[171,1508,1509],{"class":645}," undefined,\n",[171,1511,1512],{"class":173,"line":217},[171,1513,1514],{"class":645},"  },\n",[171,1516,1517,1519],{"class":173,"line":223},[171,1518,667],{"class":645},[171,1520,670],{"class":641},[1522,1523,1524,1542,1553,1565,1582],"field-group",{},[1525,1526,1529,1535],"field",{"name":1527,"type":1528},"memoryLimit","number",[150,1530,1531,1532],{},"Default: ",[154,1533,1534],{},"64",[150,1536,1537,1538,1541],{},"V8 isolate memory limit in MB. Set once at first execution — call ",[154,1539,1540],{},"disposeCodeMode()"," to change.",[1525,1543,1545,1550],{"name":1544,"type":1528},"cpuTimeLimitMs",[150,1546,1531,1547],{},[154,1548,1549],{},"10000",[150,1551,1552],{},"CPU time limit per execution in milliseconds. The sandbox is killed after this duration.",[1525,1554,1556,1562],{"name":1555,"type":1528},"maxResultSize",[150,1557,1531,1558,1561],{},[154,1559,1560],{},"102400"," (100 KB)",[150,1563,1564],{},"Maximum result size in bytes before truncation. Large results are intelligently truncated — arrays by number of items, objects by number of keys.",[1525,1566,1569,1574],{"name":1567,"type":1568},"progressive","boolean",[150,1570,1531,1571],{},[154,1572,1573],{},"false",[150,1575,1576,1577,1581],{},"Enable progressive disclosure mode. See ",[526,1578,1580],{"href":1579},"#progressive-mode","Progressive Mode"," below.",[1525,1583,1586,1589],{"name":1584,"type":1585},"description","string",[150,1587,1588],{},"Default: built-in template",[150,1590,1591,1592,1594,1595,1598,1599,1602],{},"Custom description for the ",[154,1593,154],{}," tool. Supports ",[154,1596,1597],{},"{{types}}"," and ",[154,1600,1601],{},"{{count}}"," placeholders.",[145,1604,1580],{"id":1605},"progressive-mode",[150,1607,1608,1609,1611],{},"When your server exposes many tools (50+), embedding all type definitions in the ",[154,1610,154],{}," tool description becomes expensive in tokens. Progressive mode solves this by splitting into two tools:",[765,1613,1614,1622],{},[477,1615,1616,1621],{},[270,1617,1618],{},[154,1619,1620],{},"search"," — discovers tools by keyword, returns their signatures",[477,1623,1624,1628],{},[270,1625,1626],{},[154,1627,154],{}," — executes code using discovered tools",[161,1630,1632],{"className":614,"code":1631,"filename":1429,"language":617,"meta":167,"style":167},"export default defineMcpHandler({\n  experimental_codeMode: {\n    progressive: true,\n  },\n})\n",[154,1633,1634,1646,1654,1664,1668],{"__ignoreMap":167},[171,1635,1636,1638,1640,1642,1644],{"class":173,"line":174},[171,1637,631],{"class":630},[171,1639,634],{"class":630},[171,1641,638],{"class":637},[171,1643,642],{"class":641},[171,1645,646],{"class":645},[171,1647,1648,1650,1652],{"class":173,"line":180},[171,1649,652],{"class":651},[171,1651,655],{"class":645},[171,1653,1140],{"class":645},[171,1655,1656,1658,1660,1662],{"class":173,"line":187},[171,1657,1492],{"class":651},[171,1659,655],{"class":645},[171,1661,659],{"class":658},[171,1663,662],{"class":645},[171,1665,1666],{"class":173,"line":193},[171,1667,1514],{"class":645},[171,1669,1670,1672],{"class":173,"line":199},[171,1671,667],{"class":645},[171,1673,670],{"class":641},[150,1675,1676],{},"The LLM workflow becomes:",[534,1678,1679,1709],{},[161,1680,1683],{"className":163,"code":1681,"filename":1682,"language":166,"meta":167,"style":167},"LLM calls: search({ query: \"user\" })\n\n→ Found 2\u002F12 tools matching \"user\":\n  codemode.get_user: (input: { id: string }) => Promise\u003Cunknown>; \u002F\u002F Get user by ID\n  codemode.list_users: () => Promise\u003Cunknown>; \u002F\u002F List all users\n","Step 1 — Search",[154,1684,1685,1690,1694,1699,1704],{"__ignoreMap":167},[171,1686,1687],{"class":173,"line":174},[171,1688,1689],{},"LLM calls: search({ query: \"user\" })\n",[171,1691,1692],{"class":173,"line":180},[171,1693,184],{"emptyLinePlaceholder":183},[171,1695,1696],{"class":173,"line":187},[171,1697,1698],{},"→ Found 2\u002F12 tools matching \"user\":\n",[171,1700,1701],{"class":173,"line":193},[171,1702,1703],{},"  codemode.get_user: (input: { id: string }) => Promise\u003Cunknown>; \u002F\u002F Get user by ID\n",[171,1705,1706],{"class":173,"line":199},[171,1707,1708],{},"  codemode.list_users: () => Promise\u003Cunknown>; \u002F\u002F List all users\n",[161,1710,1713],{"className":163,"code":1711,"filename":1712,"language":166,"meta":167,"style":167},"LLM calls: code({ code: \"...\" })\n\n→ Executes code using the discovered tools\n","Step 2 — Execute",[154,1714,1715,1720,1724],{"__ignoreMap":167},[171,1716,1717],{"class":173,"line":174},[171,1718,1719],{},"LLM calls: code({ code: \"...\" })\n",[171,1721,1722],{"class":173,"line":180},[171,1723,184],{"emptyLinePlaceholder":183},[171,1725,1726],{"class":173,"line":187},[171,1727,1728],{},"→ Executes code using the discovered tools\n",[319,1730,1733],{"color":1731,"icon":1732},"info","i-lucide-info","Progressive mode adds an extra tool call but significantly reduces the initial prompt size. Only use it when you have a large number of tools — for small toolsets, standard mode is more efficient.",[145,1735,1737],{"id":1736},"custom-description","Custom Description",[150,1739,1740,1741,1743],{},"Override the ",[154,1742,154],{}," tool description to customize LLM instructions:",[161,1745,1747],{"className":614,"code":1746,"filename":1429,"language":617,"meta":167,"style":167},"export default defineMcpHandler({\n  experimental_codeMode: {\n    description: `You have {{count}} tools available. Write JavaScript using the codemode object.\n\n{{types}}\n\nAlways combine related operations into a single code block.`,\n  },\n})\n",[154,1748,1749,1761,1769,1781,1785,1790,1794,1804,1808],{"__ignoreMap":167},[171,1750,1751,1753,1755,1757,1759],{"class":173,"line":174},[171,1752,631],{"class":630},[171,1754,634],{"class":630},[171,1756,638],{"class":637},[171,1758,642],{"class":641},[171,1760,646],{"class":645},[171,1762,1763,1765,1767],{"class":173,"line":180},[171,1764,652],{"class":651},[171,1766,655],{"class":645},[171,1768,1140],{"class":645},[171,1770,1771,1773,1775,1778],{"class":173,"line":187},[171,1772,1504],{"class":651},[171,1774,655],{"class":645},[171,1776,1777],{"class":645}," `",[171,1779,1780],{"class":551},"You have {{count}} tools available. Write JavaScript using the codemode object.\n",[171,1782,1783],{"class":173,"line":193},[171,1784,184],{"emptyLinePlaceholder":183},[171,1786,1787],{"class":173,"line":199},[171,1788,1789],{"class":551},"{{types}}\n",[171,1791,1792],{"class":173,"line":205},[171,1793,184],{"emptyLinePlaceholder":183},[171,1795,1796,1799,1802],{"class":173,"line":211},[171,1797,1798],{"class":551},"Always combine related operations into a single code block.",[171,1800,1801],{"class":645},"`",[171,1803,662],{"class":645},[171,1805,1806],{"class":173,"line":217},[171,1807,1514],{"class":645},[171,1809,1810,1812],{"class":173,"line":223},[171,1811,667],{"class":645},[171,1813,670],{"class":641},[150,1815,1816,1817,1819,1820,1822],{},"The ",[154,1818,1597],{}," placeholder is replaced with the generated TypeScript definitions. The ",[154,1821,1601],{}," placeholder is replaced with the number of available tools.",[150,1824,1825,1826,1828,1829,1831],{},"In progressive mode, ",[154,1827,1597],{}," is not available since types are discovered via the ",[154,1830,1620],{}," tool.",[145,1833,1835],{"id":1834},"security","Security",[150,1837,1838,1839,1842],{},"Running LLM-generated code requires serious security measures. Code Mode implements ",[270,1840,1841],{},"defense in depth"," across 7 layers to ensure the sandbox cannot escape, access unauthorized resources, or exhaust host resources.",[339,1844,1846],{"id":1845},"sandbox-isolation","Sandbox Isolation",[150,1848,1849,1850,1855,1856,1858],{},"LLM-generated code runs in a separate ",[526,1851,1854],{"href":1852,"rel":1853},"https:\u002F\u002Fv8.dev\u002Fdocs\u002Fembed",[530],"V8 isolate"," via ",[154,1857,531],{},". This is the same isolation technology used by Cloudflare Workers and similar platforms. The sandbox has:",[474,1860,1861,1867,1889,1895],{},[477,1862,1863,1866],{},[270,1864,1865],{},"No filesystem access"," — cannot read, write, or list files",[477,1868,1869,1872,1873,796,1876,796,1879,796,1882,796,1885,1888],{},[270,1870,1871],{},"No Node.js APIs"," — no ",[154,1874,1875],{},"require()",[154,1877,1878],{},"import()",[154,1880,1881],{},"process",[154,1883,1884],{},"fs",[154,1886,1887],{},"child_process",", etc.",[477,1890,1891,1894],{},[270,1892,1893],{},"No environment variables"," — cannot read secrets or configuration",[477,1896,1897,1900],{},[270,1898,1899],{},"No host process access"," — cannot modify the parent process in any way",[339,1902,1904],{"id":1903},"network-restrictions","Network Restrictions",[150,1906,1907],{},"The sandbox can only communicate with the internal RPC server. All other network access is blocked:",[474,1909,1910,1916,1929,1935],{},[477,1911,1912,1915],{},[270,1913,1914],{},"Port-locked"," — Only the randomly-assigned RPC port is accessible. Other localhost services (databases, admin panels, other apps) are blocked.",[477,1917,1918,1921,1922,1598,1925,1928],{},[270,1919,1920],{},"Host-locked"," — Only ",[154,1923,1924],{},"127.0.0.1",[154,1926,1927],{},"localhost"," are allowed. External hosts are rejected.",[477,1930,1931,1934],{},[270,1932,1933],{},"No DNS"," — DNS resolution is disabled entirely.",[477,1936,1937,1940,1941,1944],{},[270,1938,1939],{},"No redirects"," — HTTP redirects are rejected (",[154,1942,1943],{},"redirect: 'error'","), preventing SSRF via open redirects.",[339,1946,1948],{"id":1947},"rpc-authentication","RPC Authentication",[150,1950,1951],{},"Communication between the sandbox and the host uses a per-session cryptographic token:",[474,1953,1954,1964,1974],{},[477,1955,1956,1959,1960,1963],{},[270,1957,1958],{},"256-bit token"," — Generated with ",[154,1961,1962],{},"crypto.randomBytes(32)"," at RPC server startup.",[477,1965,1966,1969,1970,1973],{},[270,1967,1968],{},"Header-based auth"," — Every request must include the token via ",[154,1971,1972],{},"x-rpc-token"," header.",[477,1975,1976,1979],{},[270,1977,1978],{},"403 on mismatch"," — Requests without a valid token are rejected immediately.",[150,1981,1982],{},"This prevents other local processes from calling your MCP tools through the RPC port.",[339,1984,1986],{"id":1985},"resource-limits","Resource Limits",[245,1988,1989,2005],{},[248,1990,1991],{},[251,1992,1993,1996,1999,2002],{},[254,1994,1995],{},"Resource",[254,1997,1998],{},"Default",[254,2000,2001],{},"Configurable",[254,2003,2004],{},"Protection",[262,2006,2007,2024,2041,2058],{},[251,2008,2009,2014,2017,2021],{},[267,2010,2011],{},[270,2012,2013],{},"CPU time",[267,2015,2016],{},"10 seconds",[267,2018,2019],{},[154,2020,1544],{},[267,2022,2023],{},"Sandbox is killed on timeout — prevents infinite loops",[251,2025,2026,2031,2034,2038],{},[267,2027,2028],{},[270,2029,2030],{},"Memory",[267,2032,2033],{},"64 MB",[267,2035,2036],{},[154,2037,1527],{},[267,2039,2040],{},"V8 isolate hard limit — prevents OOM crashes",[251,2042,2043,2048,2051,2055],{},[267,2044,2045],{},[270,2046,2047],{},"Result size",[267,2049,2050],{},"100 KB",[267,2052,2053],{},[154,2054,1555],{},[267,2056,2057],{},"Intelligent truncation (arrays by items, objects by keys)",[251,2059,2060,2065,2068,2071],{},[267,2061,2062],{},[270,2063,2064],{},"Log entries",[267,2066,2067],{},"200",[267,2069,2070],{},"No",[267,2072,2073,2074,2077],{},"Console output capped — prevents ",[154,2075,2076],{},"console.log"," flooding",[339,2079,2081],{"id":2080},"input-validation","Input Validation",[150,2083,2084],{},"Tool names are interpolated into the sandbox code template. To prevent code injection:",[474,2086,2087,2097,2109],{},[477,2088,2089,2092,2093,2096],{},[270,2090,2091],{},"Strict identifier regex"," — Every tool name is validated against ",[154,2094,2095],{},"\u002F^[\\w$]+$\u002F"," before being injected into the sandbox template.",[477,2098,2099,2102,2103,2105,2106,2108],{},[270,2100,2101],{},"Sanitization"," — Names are sanitized upstream (",[154,2104,795],{}," → ",[154,2107,837],{},"), but a second validation layer at the template level ensures defense in depth.",[477,2110,2111,2114],{},[270,2112,2113],{},"Rejection"," — If a name fails validation, the execution throws immediately — no partial injection.",[339,2116,2118],{"id":2117},"summary","Summary",[319,2120,2121,2122,2125],{"color":1731,"icon":79},"The sandbox can ",[270,2123,2124],{},"only"," communicate with your registered MCP tools via the authenticated RPC bridge. It cannot access the filesystem, network, environment, or any other host resources.",[145,2127,2129],{"id":2128},"usage-with-other-features","Usage with Other Features",[150,2131,2132],{},"Code Mode is fully compatible with other module features. Your tools remain unchanged — only the way they are exposed to the LLM changes.",[534,2134,2135,2282,2443],{},[161,2136,2139],{"className":614,"code":2137,"filename":2138,"language":617,"meta":167,"style":167},"\u002F\u002F server\u002Fmcp\u002Findex.ts\nexport default defineMcpHandler({\n  experimental_codeMode: true,\n  middleware: async (event) => {\n    const user = await getUser(event)\n    if (!user) {\n      throw createError({ statusCode: 401 })\n    }\n    event.context.user = user\n  },\n})\n","With Middleware",[154,2140,2141,2145,2157,2167,2188,2208,2224,2248,2253,2272,2276],{"__ignoreMap":167},[171,2142,2143],{"class":173,"line":174},[171,2144,625],{"class":624},[171,2146,2147,2149,2151,2153,2155],{"class":173,"line":180},[171,2148,631],{"class":630},[171,2150,634],{"class":630},[171,2152,638],{"class":637},[171,2154,642],{"class":641},[171,2156,646],{"class":645},[171,2158,2159,2161,2163,2165],{"class":173,"line":187},[171,2160,652],{"class":651},[171,2162,655],{"class":645},[171,2164,659],{"class":658},[171,2166,662],{"class":645},[171,2168,2169,2172,2174,2177,2179,2182,2184,2186],{"class":173,"line":193},[171,2170,2171],{"class":637},"  middleware",[171,2173,655],{"class":645},[171,2175,2176],{"class":819}," async",[171,2178,1243],{"class":645},[171,2180,2181],{"class":1313},"event",[171,2183,862],{"class":645},[171,2185,1317],{"class":819},[171,2187,1140],{"class":645},[171,2189,2190,2193,2195,2197,2199,2202,2204,2206],{"class":173,"line":199},[171,2191,2192],{"class":819},"    const",[171,2194,895],{"class":641},[171,2196,1050],{"class":645},[171,2198,829],{"class":630},[171,2200,2201],{"class":637}," getUser",[171,2203,642],{"class":651},[171,2205,2181],{"class":641},[171,2207,670],{"class":651},[171,2209,2210,2213,2215,2218,2220,2222],{"class":173,"line":205},[171,2211,2212],{"class":630},"    if",[171,2214,1243],{"class":651},[171,2216,2217],{"class":645},"!",[171,2219,1377],{"class":641},[171,2221,933],{"class":651},[171,2223,646],{"class":645},[171,2225,2226,2229,2232,2234,2236,2239,2241,2244,2246],{"class":173,"line":211},[171,2227,2228],{"class":630},"      throw",[171,2230,2231],{"class":637}," createError",[171,2233,642],{"class":651},[171,2235,842],{"class":645},[171,2237,2238],{"class":651}," statusCode",[171,2240,655],{"class":645},[171,2242,2243],{"class":929}," 401",[171,2245,859],{"class":645},[171,2247,670],{"class":651},[171,2249,2250],{"class":173,"line":217},[171,2251,2252],{"class":645},"    }\n",[171,2254,2255,2258,2260,2263,2265,2267,2269],{"class":173,"line":223},[171,2256,2257],{"class":641},"    event",[171,2259,452],{"class":645},[171,2261,2262],{"class":641},"context",[171,2264,452],{"class":645},[171,2266,1377],{"class":641},[171,2268,1050],{"class":645},[171,2270,2271],{"class":641}," user\n",[171,2273,2274],{"class":173,"line":229},[171,2275,1514],{"class":645},[171,2277,2278,2280],{"class":173,"line":235},[171,2279,667],{"class":645},[171,2281,670],{"class":641},[161,2283,2286],{"className":614,"code":2284,"filename":2285,"language":617,"meta":167,"style":167},"\u002F\u002F server\u002Fmcp\u002Ftools\u002Fadmin-tool.ts\nexport default defineMcpTool({\n  name: 'admin-delete',\n  description: 'Delete a resource (admin only)',\n  enabled: event => event.context.user?.role === 'admin',\n  inputSchema: {\n    id: z.string(),\n  },\n  handler: async ({ id }) => {\n    \u002F\u002F Only visible in code mode when user is admin\n  },\n})\n","With Dynamic Definitions",[154,2287,2288,2293,2306,2321,2337,2376,2385,2403,2407,2428,2433,2437],{"__ignoreMap":167},[171,2289,2290],{"class":173,"line":174},[171,2291,2292],{"class":624},"\u002F\u002F server\u002Fmcp\u002Ftools\u002Fadmin-tool.ts\n",[171,2294,2295,2297,2299,2302,2304],{"class":173,"line":180},[171,2296,631],{"class":630},[171,2298,634],{"class":630},[171,2300,2301],{"class":637}," defineMcpTool",[171,2303,642],{"class":641},[171,2305,646],{"class":645},[171,2307,2308,2310,2312,2314,2317,2319],{"class":173,"line":187},[171,2309,698],{"class":651},[171,2311,655],{"class":645},[171,2313,703],{"class":645},[171,2315,2316],{"class":551},"admin-delete",[171,2318,709],{"class":645},[171,2320,662],{"class":645},[171,2322,2323,2326,2328,2330,2333,2335],{"class":173,"line":193},[171,2324,2325],{"class":651},"  description",[171,2327,655],{"class":645},[171,2329,703],{"class":645},[171,2331,2332],{"class":551},"Delete a resource (admin only)",[171,2334,709],{"class":645},[171,2336,662],{"class":645},[171,2338,2339,2342,2344,2347,2349,2351,2353,2355,2357,2359,2362,2365,2367,2369,2372,2374],{"class":173,"line":199},[171,2340,2341],{"class":637},"  enabled",[171,2343,655],{"class":645},[171,2345,2346],{"class":1313}," event",[171,2348,1317],{"class":819},[171,2350,2346],{"class":641},[171,2352,452],{"class":645},[171,2354,2262],{"class":641},[171,2356,452],{"class":645},[171,2358,1377],{"class":641},[171,2360,2361],{"class":645},"?.",[171,2363,2364],{"class":641},"role ",[171,2366,926],{"class":645},[171,2368,703],{"class":645},[171,2370,2371],{"class":551},"admin",[171,2373,709],{"class":645},[171,2375,662],{"class":645},[171,2377,2378,2381,2383],{"class":173,"line":205},[171,2379,2380],{"class":651},"  inputSchema",[171,2382,655],{"class":645},[171,2384,1140],{"class":645},[171,2386,2387,2390,2392,2395,2397,2399,2401],{"class":173,"line":211},[171,2388,2389],{"class":651},"    id",[171,2391,655],{"class":645},[171,2393,2394],{"class":641}," z",[171,2396,452],{"class":645},[171,2398,1585],{"class":637},[171,2400,1076],{"class":641},[171,2402,662],{"class":645},[171,2404,2405],{"class":173,"line":217},[171,2406,1514],{"class":645},[171,2408,2409,2412,2414,2416,2419,2421,2424,2426],{"class":173,"line":223},[171,2410,2411],{"class":637},"  handler",[171,2413,655],{"class":645},[171,2415,2176],{"class":819},[171,2417,2418],{"class":645}," ({",[171,2420,845],{"class":1313},[171,2422,2423],{"class":645}," })",[171,2425,1317],{"class":819},[171,2427,1140],{"class":645},[171,2429,2430],{"class":173,"line":229},[171,2431,2432],{"class":624},"    \u002F\u002F Only visible in code mode when user is admin\n",[171,2434,2435],{"class":173,"line":235},[171,2436,1514],{"class":645},[171,2438,2439,2441],{"class":173,"line":240},[171,2440,667],{"class":645},[171,2442,670],{"class":641},[161,2444,2447],{"className":614,"code":2445,"filename":2446,"language":617,"meta":167,"style":167},"\u002F\u002F server\u002Fmcp\u002Findex.ts\nexport default defineMcpHandler({\n  experimental_codeMode: {\n    progressive: true,\n    cpuTimeLimitMs: 15_000,\n  },\n  middleware: async (event) => {\n    const apiKey = getHeader(event, 'x-api-key')\n    if (!apiKey) throw createError({ statusCode: 401 })\n    event.context.user = await getUserByApiKey(apiKey)\n  },\n})\n","With Progressive + Auth",[154,2448,2449,2453,2465,2473,2483,2494,2498,2516,2543,2575,2600,2604],{"__ignoreMap":167},[171,2450,2451],{"class":173,"line":174},[171,2452,625],{"class":624},[171,2454,2455,2457,2459,2461,2463],{"class":173,"line":180},[171,2456,631],{"class":630},[171,2458,634],{"class":630},[171,2460,638],{"class":637},[171,2462,642],{"class":641},[171,2464,646],{"class":645},[171,2466,2467,2469,2471],{"class":173,"line":187},[171,2468,652],{"class":651},[171,2470,655],{"class":645},[171,2472,1140],{"class":645},[171,2474,2475,2477,2479,2481],{"class":173,"line":193},[171,2476,1492],{"class":651},[171,2478,655],{"class":645},[171,2480,659],{"class":658},[171,2482,662],{"class":645},[171,2484,2485,2487,2489,2492],{"class":173,"line":199},[171,2486,1468],{"class":651},[171,2488,655],{"class":645},[171,2490,2491],{"class":929}," 15_000",[171,2493,662],{"class":645},[171,2495,2496],{"class":173,"line":205},[171,2497,1514],{"class":645},[171,2499,2500,2502,2504,2506,2508,2510,2512,2514],{"class":173,"line":211},[171,2501,2171],{"class":637},[171,2503,655],{"class":645},[171,2505,2176],{"class":819},[171,2507,1243],{"class":645},[171,2509,2181],{"class":1313},[171,2511,862],{"class":645},[171,2513,1317],{"class":819},[171,2515,1140],{"class":645},[171,2517,2518,2520,2523,2525,2528,2530,2532,2534,2536,2539,2541],{"class":173,"line":217},[171,2519,2192],{"class":819},[171,2521,2522],{"class":641}," apiKey",[171,2524,1050],{"class":645},[171,2526,2527],{"class":637}," getHeader",[171,2529,642],{"class":651},[171,2531,2181],{"class":641},[171,2533,734],{"class":645},[171,2535,703],{"class":645},[171,2537,2538],{"class":551},"x-api-key",[171,2540,709],{"class":645},[171,2542,670],{"class":651},[171,2544,2545,2547,2549,2551,2554,2556,2559,2561,2563,2565,2567,2569,2571,2573],{"class":173,"line":223},[171,2546,2212],{"class":630},[171,2548,1243],{"class":651},[171,2550,2217],{"class":645},[171,2552,2553],{"class":641},"apiKey",[171,2555,933],{"class":651},[171,2557,2558],{"class":630},"throw",[171,2560,2231],{"class":637},[171,2562,642],{"class":651},[171,2564,842],{"class":645},[171,2566,2238],{"class":651},[171,2568,655],{"class":645},[171,2570,2243],{"class":929},[171,2572,859],{"class":645},[171,2574,670],{"class":651},[171,2576,2577,2579,2581,2583,2585,2587,2589,2591,2594,2596,2598],{"class":173,"line":229},[171,2578,2257],{"class":641},[171,2580,452],{"class":645},[171,2582,2262],{"class":641},[171,2584,452],{"class":645},[171,2586,1377],{"class":641},[171,2588,1050],{"class":645},[171,2590,829],{"class":630},[171,2592,2593],{"class":637}," getUserByApiKey",[171,2595,642],{"class":651},[171,2597,2553],{"class":641},[171,2599,670],{"class":651},[171,2601,2602],{"class":173,"line":235},[171,2603,1514],{"class":645},[171,2605,2606,2608],{"class":173,"line":240},[171,2607,667],{"class":645},[171,2609,670],{"class":641},[150,2611,2612,2614,2615,2618,2619,2625,2626,2628],{},[526,2613,76],{"href":77}," runs before tool execution — your tools access ",[154,2616,2617],{},"event.context"," as usual. Tools with ",[526,2620,2621,2624],{"href":102},[154,2622,2623],{},"enabled"," guards"," are excluded from the generated type definitions and the ",[154,2627,781],{}," object.",[145,2630,2632],{"id":2631},"tool-name-sanitization","Tool Name Sanitization",[150,2634,2635,2636,2638],{},"MCP tool names (kebab-case) are automatically converted to valid JavaScript identifiers for the ",[154,2637,781],{}," object:",[245,2640,2641,2651],{},[248,2642,2643],{},[251,2644,2645,2648],{},[254,2646,2647],{},"MCP Name",[254,2649,2650],{},"JavaScript Name",[262,2652,2653,2663,2673,2685],{},[251,2654,2655,2659],{},[267,2656,2657],{},[154,2658,795],{},[267,2660,2661],{},[154,2662,837],{},[251,2664,2665,2669],{},[267,2666,2667],{},[154,2668,799],{},[267,2670,2671],{},[154,2672,883],{},[251,2674,2675,2680],{},[267,2676,2677],{},[154,2678,2679],{},"123-tool",[267,2681,2682],{},[154,2683,2684],{},"_123_tool",[251,2686,2687,2692],{},[267,2688,2689],{},[154,2690,2691],{},"delete",[267,2693,2694],{},[154,2695,2696],{},"delete_",[150,2698,2699,2700,2703,2704,452],{},"Reserved JavaScript words are suffixed with ",[154,2701,2702],{},"_",". Names starting with a digit are prefixed with ",[154,2705,2702],{},[145,2707,2709],{"id":2708},"cleanup","Cleanup",[150,2711,2712,2713,2715],{},"Call ",[154,2714,1540],{}," during shutdown to release resources (V8 runtime, RPC server):",[161,2717,2719],{"className":614,"code":2718,"language":617,"meta":167,"style":167},"import { disposeCodeMode } from '#imports'\n\n\u002F\u002F In a shutdown hook or cleanup function\ndisposeCodeMode()\n",[154,2720,2721,2744,2748,2753],{"__ignoreMap":167},[171,2722,2723,2726,2728,2731,2733,2736,2738,2741],{"class":173,"line":174},[171,2724,2725],{"class":630},"import",[171,2727,1009],{"class":645},[171,2729,2730],{"class":641}," disposeCodeMode",[171,2732,859],{"class":645},[171,2734,2735],{"class":630}," from",[171,2737,703],{"class":645},[171,2739,2740],{"class":551},"#imports",[171,2742,2743],{"class":645},"'\n",[171,2745,2746],{"class":173,"line":180},[171,2747,184],{"emptyLinePlaceholder":183},[171,2749,2750],{"class":173,"line":187},[171,2751,2752],{"class":624},"\u002F\u002F In a shutdown hook or cleanup function\n",[171,2754,2755,2758],{"class":173,"line":193},[171,2756,2757],{"class":637},"disposeCodeMode",[171,2759,2760],{"class":641},"()\n",[145,2762,2764],{"id":2763},"next-steps","Next Steps",[474,2766,2767,2772,2777,2782],{},[477,2768,2769,2771],{},[526,2770,61],{"href":62}," - Create custom MCP endpoints",[477,2773,2774,2776],{},[526,2775,76],{"href":77}," - Add authentication",[477,2778,2779,2781],{},[526,2780,101],{"href":102}," - Conditionally register tools",[477,2783,2784,2787],{},[526,2785,2786],{"href":92},"Evals"," - Benchmark code mode vs standard MCP",[2789,2790,2791],"style",{},"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 .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}",{"title":167,"searchDepth":180,"depth":180,"links":2793},[2794,2795,2799,2803,2806,2807,2808,2809,2817,2818,2819,2820],{"id":147,"depth":180,"text":148},{"id":329,"depth":180,"text":330,"children":2796},[2797,2798],{"id":341,"depth":187,"text":342},{"id":468,"depth":187,"text":469},{"id":516,"depth":180,"text":517,"children":2800},[2801,2802],{"id":520,"depth":187,"text":521},{"id":601,"depth":187,"text":602},{"id":759,"depth":180,"text":760,"children":2804},[2805],{"id":788,"depth":187,"text":789},{"id":1417,"depth":180,"text":1418},{"id":1605,"depth":180,"text":1580},{"id":1736,"depth":180,"text":1737},{"id":1834,"depth":180,"text":1835,"children":2810},[2811,2812,2813,2814,2815,2816],{"id":1845,"depth":187,"text":1846},{"id":1903,"depth":187,"text":1904},{"id":1947,"depth":187,"text":1948},{"id":1985,"depth":187,"text":1986},{"id":2080,"depth":187,"text":2081},{"id":2117,"depth":187,"text":2118},{"id":2128,"depth":180,"text":2129},{"id":2631,"depth":180,"text":2632},{"id":2708,"depth":180,"text":2709},{"id":2763,"depth":180,"text":2764},"Let LLMs orchestrate multiple tool calls in a single JavaScript execution.","md",null,{},{"icon":109},{"title":106,"description":2827},"Reduce token usage and latency by letting LLMs write JavaScript that orchestrates MCP tools in a secure V8 sandbox.","Jsa8Jk0wq6cewKL9CXsT-57Lllt3bBMWd77DaCaR1zE",[2830,2832],{"title":101,"path":102,"stem":103,"description":2831,"icon":104,"children":-1},"Conditionally register tools, resources, and prompts based on authentication, roles, or request context.",{"title":116,"path":117,"stem":118,"description":2833,"icon":119,"children":-1},"Secure your MCP endpoints with Bearer token authentication.",1774895332388]