[{"data":1,"prerenderedAt":1606},["ShallowReactive",2],{"series-\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare":3,"series-context-\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web":1468},{"id":4,"title":5,"body":6,"contentId":1451,"date":1452,"description":1453,"extension":1454,"github":1455,"meetTheInstructor":1457,"meta":1458,"navigation":741,"part":133,"path":1459,"rawbody":1460,"robots":1457,"schemaOrg":1457,"seo":1461,"seriesSlug":1462,"sitemap":1463,"stem":1466,"subtitle":1457,"topics":1457,"__hash__":1467},"series\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare.md","Deploying Our AI Agent to the World Using Cloudflare",{"type":7,"value":8,"toc":1446},"minimark",[9,13,33,38,41,74,81,154,165,241,252,270,277,503,514,638,641,656,659,670,674,685,691,1263,1285,1288,1302,1305,1323,1327,1330,1344,1353,1356,1400,1410,1421,1424,1439,1442],[10,11,12],"p",{},"This final part is optional: you can deploy the application and MCP server wherever you prefer. I chose Cloudflare because it is my daily platform for deploying JavaScript projects. We will make a small refactor to run the MCP server as a Cloudflare Worker, while leaving the agent and its Nuxt interface as a separate application.",[10,14,15,16,23,24,28,29,32],{},"Cloudflare provides several primitives for ",[17,18,22],"a",{"href":19,"rel":20},"https:\u002F\u002Fdevelopers.cloudflare.com\u002Fagents\u002F",[21],"nofollow","AI Agents and MCP servers",". Our addition tool is stateless, so we can host it in a plain Worker. The MCP SDK's Web Standards transport works directly with the Worker's ",[25,26,27],"code",{},"Request"," and ",[25,30,31],{},"Response"," APIs, so we do not need a Durable Object. A stateful MCP server would need persistent session management instead.",[34,35,37],"h2",{"id":36},"setting-up-tooling","Setting up tooling",[10,39,40],{},"First, install the dependencies:",[42,43,49],"pre",{"className":44,"code":45,"filename":46,"language":47,"meta":48,"style":48},"language-bash shiki shiki-themes github-light github-light github-dark","pnpm add -D wrangler @types\u002Fnode\n","terminal","bash","",[25,50,51],{"__ignoreMap":48},[52,53,56,60,64,68,71],"span",{"class":54,"line":55},"line",1,[52,57,59],{"class":58},"snPdu","pnpm",[52,61,63],{"class":62},"sIIMD"," add",[52,65,67],{"class":66},"sBjJW"," -D",[52,69,70],{"class":62}," wrangler",[52,72,73],{"class":62}," @types\u002Fnode\n",[10,75,76,77,80],{},"Then add the following scripts to ",[25,78,79],{},"package.json",":",[42,82,86],{"className":83,"code":84,"filename":79,"language":85,"meta":48,"style":48},"language-json shiki shiki-themes github-light github-light github-dark","{\n  \"scripts\": {\n    \"dev:wrangler\": \"wrangler --config .\u002Fworker\u002Fwrangler.jsonc dev\",\n    \"deploy:wrangler\": \"wrangler --config .\u002Fworker\u002Fwrangler.jsonc deploy\",\n    \"cf-typegen\": \"wrangler --config .\u002Fworker\u002Fwrangler.jsonc types worker\u002Fworker-configuration.d.ts\"\n  }\n}\n","json",[25,87,88,94,103,118,131,142,148],{"__ignoreMap":48},[52,89,90],{"class":54,"line":55},[52,91,93],{"class":92},"sxrX7","{\n",[52,95,97,100],{"class":54,"line":96},2,[52,98,99],{"class":66},"  \"scripts\"",[52,101,102],{"class":92},": {\n",[52,104,106,109,112,115],{"class":54,"line":105},3,[52,107,108],{"class":66},"    \"dev:wrangler\"",[52,110,111],{"class":92},": ",[52,113,114],{"class":62},"\"wrangler --config .\u002Fworker\u002Fwrangler.jsonc dev\"",[52,116,117],{"class":92},",\n",[52,119,121,124,126,129],{"class":54,"line":120},4,[52,122,123],{"class":66},"    \"deploy:wrangler\"",[52,125,111],{"class":92},[52,127,128],{"class":62},"\"wrangler --config .\u002Fworker\u002Fwrangler.jsonc deploy\"",[52,130,117],{"class":92},[52,132,134,137,139],{"class":54,"line":133},5,[52,135,136],{"class":66},"    \"cf-typegen\"",[52,138,111],{"class":92},[52,140,141],{"class":62},"\"wrangler --config .\u002Fworker\u002Fwrangler.jsonc types worker\u002Fworker-configuration.d.ts\"\n",[52,143,145],{"class":54,"line":144},6,[52,146,147],{"class":92},"  }\n",[52,149,151],{"class":54,"line":150},7,[52,152,153],{"class":92},"}\n",[10,155,156,157,160,161,164],{},"We also need a ",[25,158,159],{},"wrangler.jsonc"," to configure our Cloudflare Worker. Create ",[25,162,163],{},"worker\u002Fwrangler.jsonc"," with the following content:",[42,166,171],{"className":167,"code":168,"filename":169,"language":170,"meta":48,"style":48},"language-jsonc shiki shiki-themes github-light github-light github-dark","{\n  \"$schema\": \"node_modules\u002Fwrangler\u002Fconfig-schema.json\",\n  \"name\": \"our-mcp\",\n  \"main\": \"index.ts\",\n  \"compatibility_date\": \"2025-03-10\",\n  \"compatibility_flags\": [\n    \"nodejs_compat\"\n  ],\n  \"observability\": {\n    \"enabled\": true,\n    \"head_sampling_rate\": 0.1\n  }\n}\n","Example","jsonc",[25,172,173,177,182,187,192,197,202,207,213,219,225,231,236],{"__ignoreMap":48},[52,174,175],{"class":54,"line":55},[52,176,93],{},[52,178,179],{"class":54,"line":96},[52,180,181],{},"  \"$schema\": \"node_modules\u002Fwrangler\u002Fconfig-schema.json\",\n",[52,183,184],{"class":54,"line":105},[52,185,186],{},"  \"name\": \"our-mcp\",\n",[52,188,189],{"class":54,"line":120},[52,190,191],{},"  \"main\": \"index.ts\",\n",[52,193,194],{"class":54,"line":133},[52,195,196],{},"  \"compatibility_date\": \"2025-03-10\",\n",[52,198,199],{"class":54,"line":144},[52,200,201],{},"  \"compatibility_flags\": [\n",[52,203,204],{"class":54,"line":150},[52,205,206],{},"    \"nodejs_compat\"\n",[52,208,210],{"class":54,"line":209},8,[52,211,212],{},"  ],\n",[52,214,216],{"class":54,"line":215},9,[52,217,218],{},"  \"observability\": {\n",[52,220,222],{"class":54,"line":221},10,[52,223,224],{},"    \"enabled\": true,\n",[52,226,228],{"class":54,"line":227},11,[52,229,230],{},"    \"head_sampling_rate\": 0.1\n",[52,232,234],{"class":54,"line":233},12,[52,235,147],{},[52,237,239],{"class":54,"line":238},13,[52,240,153],{},[242,243,246],"callout",{"color":244,"icon":245},"info","i-ph-info-duotone",[10,247,248,249,251],{},"The ",[25,250,159],{}," file is not stored in the root directory to avoid conflicts when we will deploy the Nuxt application.",[10,253,254,255,258,259,262,263,266,267,269],{},"With this file, Wrangler will look for ",[25,256,257],{},"index.ts"," relative to the ",[25,260,261],{},"worker"," directory, which resolves to ",[25,264,265],{},"worker\u002Findex.ts",". The configuration lives in the ",[25,268,261],{}," directory so it does not conflict with the Nuxt application's Cloudflare Pages deployment.",[10,271,272,273,276],{},"To finish the tooling setup, create a ",[25,274,275],{},"tsconfig.worker.json"," file to configure TypeScript for the Worker:",[42,278,280],{"className":83,"code":279,"filename":275,"language":85,"meta":48,"style":48},"{\n  \"compilerOptions\": {\n    \"target\": \"es2021\",\n    \"jsx\": \"react-jsx\",\n    \"lib\": [\n      \"es2021\"\n    ],\n    \"module\": \"es2022\",\n    \"moduleResolution\": \"bundler\",\n    \"resolveJsonModule\": true,\n    \"allowJs\": true,\n    \"checkJs\": false,\n    \"strict\": true,\n    \"noEmit\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"isolatedModules\": true,\n    \"skipLibCheck\": true\n  },\n  \"include\": [\n    \"worker\u002Fworker-configuration.d.ts\",\n    \"worker\u002F**\u002F*.ts\"\n  ]\n}\n",[25,281,282,286,293,305,317,325,330,335,347,359,371,382,394,405,417,429,441,453,464,470,478,486,492,498],{"__ignoreMap":48},[52,283,284],{"class":54,"line":55},[52,285,93],{"class":92},[52,287,288,291],{"class":54,"line":96},[52,289,290],{"class":66},"  \"compilerOptions\"",[52,292,102],{"class":92},[52,294,295,298,300,303],{"class":54,"line":105},[52,296,297],{"class":66},"    \"target\"",[52,299,111],{"class":92},[52,301,302],{"class":62},"\"es2021\"",[52,304,117],{"class":92},[52,306,307,310,312,315],{"class":54,"line":120},[52,308,309],{"class":66},"    \"jsx\"",[52,311,111],{"class":92},[52,313,314],{"class":62},"\"react-jsx\"",[52,316,117],{"class":92},[52,318,319,322],{"class":54,"line":133},[52,320,321],{"class":66},"    \"lib\"",[52,323,324],{"class":92},": [\n",[52,326,327],{"class":54,"line":144},[52,328,329],{"class":62},"      \"es2021\"\n",[52,331,332],{"class":54,"line":150},[52,333,334],{"class":92},"    ],\n",[52,336,337,340,342,345],{"class":54,"line":209},[52,338,339],{"class":66},"    \"module\"",[52,341,111],{"class":92},[52,343,344],{"class":62},"\"es2022\"",[52,346,117],{"class":92},[52,348,349,352,354,357],{"class":54,"line":215},[52,350,351],{"class":66},"    \"moduleResolution\"",[52,353,111],{"class":92},[52,355,356],{"class":62},"\"bundler\"",[52,358,117],{"class":92},[52,360,361,364,366,369],{"class":54,"line":221},[52,362,363],{"class":66},"    \"resolveJsonModule\"",[52,365,111],{"class":92},[52,367,368],{"class":66},"true",[52,370,117],{"class":92},[52,372,373,376,378,380],{"class":54,"line":227},[52,374,375],{"class":66},"    \"allowJs\"",[52,377,111],{"class":92},[52,379,368],{"class":66},[52,381,117],{"class":92},[52,383,384,387,389,392],{"class":54,"line":233},[52,385,386],{"class":66},"    \"checkJs\"",[52,388,111],{"class":92},[52,390,391],{"class":66},"false",[52,393,117],{"class":92},[52,395,396,399,401,403],{"class":54,"line":238},[52,397,398],{"class":66},"    \"strict\"",[52,400,111],{"class":92},[52,402,368],{"class":66},[52,404,117],{"class":92},[52,406,408,411,413,415],{"class":54,"line":407},14,[52,409,410],{"class":66},"    \"noEmit\"",[52,412,111],{"class":92},[52,414,368],{"class":66},[52,416,117],{"class":92},[52,418,420,423,425,427],{"class":54,"line":419},15,[52,421,422],{"class":66},"    \"allowSyntheticDefaultImports\"",[52,424,111],{"class":92},[52,426,368],{"class":66},[52,428,117],{"class":92},[52,430,432,435,437,439],{"class":54,"line":431},16,[52,433,434],{"class":66},"    \"forceConsistentCasingInFileNames\"",[52,436,111],{"class":92},[52,438,368],{"class":66},[52,440,117],{"class":92},[52,442,444,447,449,451],{"class":54,"line":443},17,[52,445,446],{"class":66},"    \"isolatedModules\"",[52,448,111],{"class":92},[52,450,368],{"class":66},[52,452,117],{"class":92},[52,454,456,459,461],{"class":54,"line":455},18,[52,457,458],{"class":66},"    \"skipLibCheck\"",[52,460,111],{"class":92},[52,462,463],{"class":66},"true\n",[52,465,467],{"class":54,"line":466},19,[52,468,469],{"class":92},"  },\n",[52,471,473,476],{"class":54,"line":472},20,[52,474,475],{"class":66},"  \"include\"",[52,477,324],{"class":92},[52,479,481,484],{"class":54,"line":480},21,[52,482,483],{"class":62},"    \"worker\u002Fworker-configuration.d.ts\"",[52,485,117],{"class":92},[52,487,489],{"class":54,"line":488},22,[52,490,491],{"class":62},"    \"worker\u002F**\u002F*.ts\"\n",[52,493,495],{"class":54,"line":494},23,[52,496,497],{"class":92},"  ]\n",[52,499,501],{"class":54,"line":500},24,[52,502,153],{"class":92},[10,504,505,506,509,510,513],{},"Add this file to the existing ",[25,507,508],{},"tsconfig.json"," in the ",[25,511,512],{},"references"," section:",[42,515,518],{"className":83,"code":516,"filename":508,"highlights":517,"language":85,"meta":48,"style":48},"{\n  \"files\": [],\n  \"references\": [\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.app.json\"\n    },\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.server.json\"\n    },\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.shared.json\"\n    },\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.node.json\"\n    },\n    {\n      \"path\": \".\u002Ftsconfig.worker.json\"\n    }\n  ]\n}\n",[443],[25,519,520,524,532,539,544,554,559,563,572,576,580,589,593,597,606,610,614,625,630,634],{"__ignoreMap":48},[52,521,522],{"class":54,"line":55},[52,523,93],{"class":92},[52,525,526,529],{"class":54,"line":96},[52,527,528],{"class":66},"  \"files\"",[52,530,531],{"class":92},": [],\n",[52,533,534,537],{"class":54,"line":105},[52,535,536],{"class":66},"  \"references\"",[52,538,324],{"class":92},[52,540,541],{"class":54,"line":120},[52,542,543],{"class":92},"    {\n",[52,545,546,549,551],{"class":54,"line":133},[52,547,548],{"class":66},"      \"path\"",[52,550,111],{"class":92},[52,552,553],{"class":62},"\".\u002F.nuxt\u002Ftsconfig.app.json\"\n",[52,555,556],{"class":54,"line":144},[52,557,558],{"class":92},"    },\n",[52,560,561],{"class":54,"line":150},[52,562,543],{"class":92},[52,564,565,567,569],{"class":54,"line":209},[52,566,548],{"class":66},[52,568,111],{"class":92},[52,570,571],{"class":62},"\".\u002F.nuxt\u002Ftsconfig.server.json\"\n",[52,573,574],{"class":54,"line":215},[52,575,558],{"class":92},[52,577,578],{"class":54,"line":221},[52,579,543],{"class":92},[52,581,582,584,586],{"class":54,"line":227},[52,583,548],{"class":66},[52,585,111],{"class":92},[52,587,588],{"class":62},"\".\u002F.nuxt\u002Ftsconfig.shared.json\"\n",[52,590,591],{"class":54,"line":233},[52,592,558],{"class":92},[52,594,595],{"class":54,"line":238},[52,596,543],{"class":92},[52,598,599,601,603],{"class":54,"line":407},[52,600,548],{"class":66},[52,602,111],{"class":92},[52,604,605],{"class":62},"\".\u002F.nuxt\u002Ftsconfig.node.json\"\n",[52,607,608],{"class":54,"line":419},[52,609,558],{"class":92},[52,611,612],{"class":54,"line":431},[52,613,543],{"class":92},[52,615,618,620,622],{"class":616,"line":443},[54,617],"highlight",[52,619,548],{"class":66},[52,621,111],{"class":92},[52,623,624],{"class":62},"\".\u002Ftsconfig.worker.json\"\n",[52,626,627],{"class":54,"line":455},[52,628,629],{"class":92},"    }\n",[52,631,632],{"class":54,"line":466},[52,633,497],{"class":92},[52,635,636],{"class":54,"line":472},[52,637,153],{"class":92},[10,639,640],{},"Now generate types:",[42,642,644],{"className":44,"code":643,"filename":46,"language":47,"meta":48,"style":48},"pnpm run cf-typegen\n",[25,645,646],{"__ignoreMap":48},[52,647,648,650,653],{"class":54,"line":55},[52,649,59],{"class":58},[52,651,652],{"class":62}," run",[52,654,655],{"class":62}," cf-typegen\n",[10,657,658],{},"This generates types for the Worker bindings and enables correct autocomplete in the worker files.",[10,660,661,662,665,666,669],{},"Don't forget to add the ",[25,663,664],{},".wrangler"," folder to ",[25,667,668],{},".gitignore"," to avoid committing it by mistake.",[34,671,673],{"id":672},"moving-the-mcp-server-to-a-worker","Moving the MCP Server to a Worker",[10,675,676,677,680,681,684],{},"Now that the tooling is ready, move the MCP server into a Cloudflare Worker. A Worker is an exported object with a ",[25,678,679],{},"fetch"," method. For our stateless addition tool, ",[25,682,683],{},"WebStandardStreamableHTTPServerTransport"," provides the Streamable HTTP transport directly through the Worker's standard APIs, without requiring a Durable Object.",[10,686,687,688,690],{},"Replace the old Nitro route with this complete ",[25,689,265],{}," file:",[42,692,696],{"className":693,"code":694,"filename":265,"language":695,"meta":48,"style":48},"language-ts shiki shiki-themes github-light github-light github-dark","import { McpServer } from '@modelcontextprotocol\u002Fsdk\u002Fserver\u002Fmcp.js'\nimport { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol\u002Fsdk\u002Fserver\u002FwebStandardStreamableHttp.js'\nimport { z } from 'zod'\n\nfunction createServer() {\n  const server = new McpServer({\n    name: 'ai-agent',\n    version: '1.0.0',\n  })\n\n  server.tool(\n    'addition',\n    'Adds two numbers',\n    {\n      a: z.number().describe('The first number'),\n      b: z.number().describe('The second number'),\n    },\n    async (params) => {\n      return {\n        content: [\n          {\n            type: 'text',\n            text: String(params.a + params.b),\n          },\n        ],\n      }\n    },\n  )\n\n  return server\n}\n\nexport default {\n  async fetch(request: Request) {\n    if (new URL(request.url).pathname !== '\u002Fmcp') {\n      return new Response('Not found', { status: 404 })\n    }\n\n    const server = createServer()\n    const transport = new WebStandardStreamableHTTPServerTransport({\n      sessionIdGenerator: undefined,\n      enableJsonResponse: true,\n    })\n\n    await server.connect(transport)\n\n    try {\n      return await transport.handleRequest(request)\n    }\n    finally {\n      await transport.close()\n      await server.close()\n    }\n  },\n} satisfies ExportedHandler\u003CEnv>\n","ts",[25,697,698,713,725,737,743,754,774,784,794,799,803,814,821,828,832,855,873,877,898,905,910,915,925,942,947,953,959,964,970,975,984,989,994,1005,1027,1052,1076,1081,1086,1101,1118,1129,1139,1145,1150,1165,1170,1178,1195,1200,1208,1221,1232,1237,1242],{"__ignoreMap":48},[52,699,700,704,707,710],{"class":54,"line":55},[52,701,703],{"class":702},"s8jYJ","import",[52,705,706],{"class":92}," { McpServer } ",[52,708,709],{"class":702},"from",[52,711,712],{"class":62}," '@modelcontextprotocol\u002Fsdk\u002Fserver\u002Fmcp.js'\n",[52,714,715,717,720,722],{"class":54,"line":96},[52,716,703],{"class":702},[52,718,719],{"class":92}," { WebStandardStreamableHTTPServerTransport } ",[52,721,709],{"class":702},[52,723,724],{"class":62}," '@modelcontextprotocol\u002Fsdk\u002Fserver\u002FwebStandardStreamableHttp.js'\n",[52,726,727,729,732,734],{"class":54,"line":105},[52,728,703],{"class":702},[52,730,731],{"class":92}," { z } ",[52,733,709],{"class":702},[52,735,736],{"class":62}," 'zod'\n",[52,738,739],{"class":54,"line":120},[52,740,742],{"emptyLinePlaceholder":741},true,"\n",[52,744,745,748,751],{"class":54,"line":133},[52,746,747],{"class":702},"function",[52,749,750],{"class":58}," createServer",[52,752,753],{"class":92},"() {\n",[52,755,756,759,762,765,768,771],{"class":54,"line":144},[52,757,758],{"class":702},"  const",[52,760,761],{"class":66}," server",[52,763,764],{"class":702}," =",[52,766,767],{"class":702}," new",[52,769,770],{"class":58}," McpServer",[52,772,773],{"class":92},"({\n",[52,775,776,779,782],{"class":54,"line":150},[52,777,778],{"class":92},"    name: ",[52,780,781],{"class":62},"'ai-agent'",[52,783,117],{"class":92},[52,785,786,789,792],{"class":54,"line":209},[52,787,788],{"class":92},"    version: ",[52,790,791],{"class":62},"'1.0.0'",[52,793,117],{"class":92},[52,795,796],{"class":54,"line":215},[52,797,798],{"class":92},"  })\n",[52,800,801],{"class":54,"line":221},[52,802,742],{"emptyLinePlaceholder":741},[52,804,805,808,811],{"class":54,"line":227},[52,806,807],{"class":92},"  server.",[52,809,810],{"class":58},"tool",[52,812,813],{"class":92},"(\n",[52,815,816,819],{"class":54,"line":233},[52,817,818],{"class":62},"    'addition'",[52,820,117],{"class":92},[52,822,823,826],{"class":54,"line":238},[52,824,825],{"class":62},"    'Adds two numbers'",[52,827,117],{"class":92},[52,829,830],{"class":54,"line":407},[52,831,543],{"class":92},[52,833,834,837,840,843,846,849,852],{"class":54,"line":419},[52,835,836],{"class":92},"      a: z.",[52,838,839],{"class":58},"number",[52,841,842],{"class":92},"().",[52,844,845],{"class":58},"describe",[52,847,848],{"class":92},"(",[52,850,851],{"class":62},"'The first number'",[52,853,854],{"class":92},"),\n",[52,856,857,860,862,864,866,868,871],{"class":54,"line":431},[52,858,859],{"class":92},"      b: z.",[52,861,839],{"class":58},[52,863,842],{"class":92},[52,865,845],{"class":58},[52,867,848],{"class":92},[52,869,870],{"class":62},"'The second number'",[52,872,854],{"class":92},[52,874,875],{"class":54,"line":443},[52,876,558],{"class":92},[52,878,879,882,885,889,892,895],{"class":54,"line":455},[52,880,881],{"class":702},"    async",[52,883,884],{"class":92}," (",[52,886,888],{"class":887},"sP4rz","params",[52,890,891],{"class":92},") ",[52,893,894],{"class":702},"=>",[52,896,897],{"class":92}," {\n",[52,899,900,903],{"class":54,"line":466},[52,901,902],{"class":702},"      return",[52,904,897],{"class":92},[52,906,907],{"class":54,"line":472},[52,908,909],{"class":92},"        content: [\n",[52,911,912],{"class":54,"line":480},[52,913,914],{"class":92},"          {\n",[52,916,917,920,923],{"class":54,"line":488},[52,918,919],{"class":92},"            type: ",[52,921,922],{"class":62},"'text'",[52,924,117],{"class":92},[52,926,927,930,933,936,939],{"class":54,"line":494},[52,928,929],{"class":92},"            text: ",[52,931,932],{"class":58},"String",[52,934,935],{"class":92},"(params.a ",[52,937,938],{"class":702},"+",[52,940,941],{"class":92}," params.b),\n",[52,943,944],{"class":54,"line":500},[52,945,946],{"class":92},"          },\n",[52,948,950],{"class":54,"line":949},25,[52,951,952],{"class":92},"        ],\n",[52,954,956],{"class":54,"line":955},26,[52,957,958],{"class":92},"      }\n",[52,960,962],{"class":54,"line":961},27,[52,963,558],{"class":92},[52,965,967],{"class":54,"line":966},28,[52,968,969],{"class":92},"  )\n",[52,971,973],{"class":54,"line":972},29,[52,974,742],{"emptyLinePlaceholder":741},[52,976,978,981],{"class":54,"line":977},30,[52,979,980],{"class":702},"  return",[52,982,983],{"class":92}," server\n",[52,985,987],{"class":54,"line":986},31,[52,988,153],{"class":92},[52,990,992],{"class":54,"line":991},32,[52,993,742],{"emptyLinePlaceholder":741},[52,995,997,1000,1003],{"class":54,"line":996},33,[52,998,999],{"class":702},"export",[52,1001,1002],{"class":702}," default",[52,1004,897],{"class":92},[52,1006,1008,1011,1014,1016,1019,1021,1024],{"class":54,"line":1007},34,[52,1009,1010],{"class":702},"  async",[52,1012,1013],{"class":58}," fetch",[52,1015,848],{"class":92},[52,1017,1018],{"class":887},"request",[52,1020,80],{"class":702},[52,1022,1023],{"class":58}," Request",[52,1025,1026],{"class":92},") {\n",[52,1028,1030,1033,1035,1038,1041,1044,1047,1050],{"class":54,"line":1029},35,[52,1031,1032],{"class":702},"    if",[52,1034,884],{"class":92},[52,1036,1037],{"class":702},"new",[52,1039,1040],{"class":58}," URL",[52,1042,1043],{"class":92},"(request.url).pathname ",[52,1045,1046],{"class":702},"!==",[52,1048,1049],{"class":62}," '\u002Fmcp'",[52,1051,1026],{"class":92},[52,1053,1055,1057,1059,1062,1064,1067,1070,1073],{"class":54,"line":1054},36,[52,1056,902],{"class":702},[52,1058,767],{"class":702},[52,1060,1061],{"class":58}," Response",[52,1063,848],{"class":92},[52,1065,1066],{"class":62},"'Not found'",[52,1068,1069],{"class":92},", { status: ",[52,1071,1072],{"class":66},"404",[52,1074,1075],{"class":92}," })\n",[52,1077,1079],{"class":54,"line":1078},37,[52,1080,629],{"class":92},[52,1082,1084],{"class":54,"line":1083},38,[52,1085,742],{"emptyLinePlaceholder":741},[52,1087,1089,1092,1094,1096,1098],{"class":54,"line":1088},39,[52,1090,1091],{"class":702},"    const",[52,1093,761],{"class":66},[52,1095,764],{"class":702},[52,1097,750],{"class":58},[52,1099,1100],{"class":92},"()\n",[52,1102,1104,1106,1109,1111,1113,1116],{"class":54,"line":1103},40,[52,1105,1091],{"class":702},[52,1107,1108],{"class":66}," transport",[52,1110,764],{"class":702},[52,1112,767],{"class":702},[52,1114,1115],{"class":58}," WebStandardStreamableHTTPServerTransport",[52,1117,773],{"class":92},[52,1119,1121,1124,1127],{"class":54,"line":1120},41,[52,1122,1123],{"class":92},"      sessionIdGenerator: ",[52,1125,1126],{"class":66},"undefined",[52,1128,117],{"class":92},[52,1130,1132,1135,1137],{"class":54,"line":1131},42,[52,1133,1134],{"class":92},"      enableJsonResponse: ",[52,1136,368],{"class":66},[52,1138,117],{"class":92},[52,1140,1142],{"class":54,"line":1141},43,[52,1143,1144],{"class":92},"    })\n",[52,1146,1148],{"class":54,"line":1147},44,[52,1149,742],{"emptyLinePlaceholder":741},[52,1151,1153,1156,1159,1162],{"class":54,"line":1152},45,[52,1154,1155],{"class":702},"    await",[52,1157,1158],{"class":92}," server.",[52,1160,1161],{"class":58},"connect",[52,1163,1164],{"class":92},"(transport)\n",[52,1166,1168],{"class":54,"line":1167},46,[52,1169,742],{"emptyLinePlaceholder":741},[52,1171,1173,1176],{"class":54,"line":1172},47,[52,1174,1175],{"class":702},"    try",[52,1177,897],{"class":92},[52,1179,1181,1183,1186,1189,1192],{"class":54,"line":1180},48,[52,1182,902],{"class":702},[52,1184,1185],{"class":702}," await",[52,1187,1188],{"class":92}," transport.",[52,1190,1191],{"class":58},"handleRequest",[52,1193,1194],{"class":92},"(request)\n",[52,1196,1198],{"class":54,"line":1197},49,[52,1199,629],{"class":92},[52,1201,1203,1206],{"class":54,"line":1202},50,[52,1204,1205],{"class":702},"    finally",[52,1207,897],{"class":92},[52,1209,1211,1214,1216,1219],{"class":54,"line":1210},51,[52,1212,1213],{"class":702},"      await",[52,1215,1188],{"class":92},[52,1217,1218],{"class":58},"close",[52,1220,1100],{"class":92},[52,1222,1224,1226,1228,1230],{"class":54,"line":1223},52,[52,1225,1213],{"class":702},[52,1227,1158],{"class":92},[52,1229,1218],{"class":58},[52,1231,1100],{"class":92},[52,1233,1235],{"class":54,"line":1234},53,[52,1236,629],{"class":92},[52,1238,1240],{"class":54,"line":1239},54,[52,1241,469],{"class":92},[52,1243,1245,1248,1251,1254,1257,1260],{"class":54,"line":1244},55,[52,1246,1247],{"class":92},"} ",[52,1249,1250],{"class":702},"satisfies",[52,1252,1253],{"class":58}," ExportedHandler",[52,1255,1256],{"class":92},"\u003C",[52,1258,1259],{"class":58},"Env",[52,1261,1262],{"class":92},">\n",[10,1264,1265,1268,1269,1272,1273,1276,1277,1280,1281,1284],{},[25,1266,1267],{},"createServer"," creates a fresh MCP server for each request, and ",[25,1270,1271],{},"sessionIdGenerator: undefined"," disables MCP sessions. This prevents request state from being shared between clients. ",[25,1274,1275],{},"enableJsonResponse: true"," is appropriate for this request-response tool and lets us close the server and transport after the response has been created. The route check exposes the MCP server only at ",[25,1278,1279],{},"\u002Fmcp",". You can now delete ",[25,1282,1283],{},"server\u002Froutes\u002Fmcp.ts",".",[10,1286,1287],{},"We can start the development server to test our changes.",[42,1289,1291],{"className":44,"code":1290,"filename":1283,"language":47,"meta":48,"style":48},"pnpm run dev:wrangler\n",[25,1292,1293],{"__ignoreMap":48},[52,1294,1295,1297,1299],{"class":54,"line":55},[52,1296,59],{"class":58},[52,1298,652],{"class":62},[52,1300,1301],{"class":62}," dev:wrangler\n",[10,1303,1304],{},"You can test using either the AI application or the MCP Inspector.",[242,1306,1308],{"color":1307,"icon":245},"primary",[10,1309,1310,1311,1314,1315,1318,1319,1322],{},"Change ",[25,1312,1313],{},"NUXT_MCP_ENDPOINT"," in your ",[25,1316,1317],{},".env"," file to the local MCP endpoint: ",[25,1320,1321],{},"http:\u002F\u002Flocalhost:8787\u002Fmcp",". Use the exact URL printed by Wrangler if it selects a different port.",[34,1324,1326],{"id":1325},"deploying-to-cloudflare","Deploying to Cloudflare",[10,1328,1329],{},"Run:",[42,1331,1333],{"className":44,"code":1332,"filename":46,"language":47,"meta":48,"style":48},"pnpm run deploy:wrangler\n",[25,1334,1335],{"__ignoreMap":48},[52,1336,1337,1339,1341],{"class":54,"line":55},[52,1338,59],{"class":58},[52,1340,652],{"class":62},[52,1342,1343],{"class":62}," deploy:wrangler\n",[10,1345,1346,1347,1349,1350,1284],{},"After deployment, Wrangler prints the Worker URL. Your MCP endpoint is the Worker URL followed by ",[25,1348,1279],{},", for example ",[25,1351,1352],{},"https:\u002F\u002Four-mcp.\u003Cyour-subdomain>.workers.dev\u002Fmcp",[10,1354,1355],{},"To deploy the AI application, run:",[42,1357,1359],{"className":44,"code":1358,"filename":46,"language":47,"meta":48,"style":48},"SERVER_PRESET=cloudflare_pages pnpm run build && npx wrangler --cwd dist pages deploy\n",[25,1360,1361],{"__ignoreMap":48},[52,1362,1363,1366,1369,1372,1375,1377,1380,1383,1386,1388,1391,1394,1397],{"class":54,"line":55},[52,1364,1365],{"class":92},"SERVER_PRESET",[52,1367,1368],{"class":702},"=",[52,1370,1371],{"class":62},"cloudflare_pages",[52,1373,1374],{"class":58}," pnpm",[52,1376,652],{"class":62},[52,1378,1379],{"class":62}," build",[52,1381,1382],{"class":92}," && ",[52,1384,1385],{"class":58},"npx",[52,1387,70],{"class":62},[52,1389,1390],{"class":66}," --cwd",[52,1392,1393],{"class":62}," dist",[52,1395,1396],{"class":62}," pages",[52,1398,1399],{"class":62}," deploy\n",[10,1401,1402,1403,1406,1407,1409],{},"The last step is to set up environment variables in your Cloudflare Pages project. Add ",[25,1404,1405],{},"NUXT_OPEN_AI_API_KEY"," as a secret and ",[25,1408,1313],{}," as plain text, using the deployed Worker MCP endpoint URL.",[1411,1412,1413,1418],"figure",{},[1414,1415],"img",{"alt":1416,"src":1417},"Cloudflare Pages settings","\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare\u002Fpages-settings.webp",[1419,1420,1416],"figcaption",{},[10,1422,1423],{},"Your AI application is now deployed and can use the MCP server running on Cloudflare.",[1411,1425,1426,1427,1426,1436],{},"\n  ",[1428,1429,1430,1431,1426],"video",{"autoPlay":741,"loop":741,"muted":741,"playsInline":741},"\n    ",[1432,1433],"source",{"src":1434,"type":1435},"https:\u002F\u002Fimages.soubiran.dev\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare\u002Four-ai-agent.mp4","video\u002Fmp4",[1419,1437,1438],{},"Our AI Agent, deployed to everyone.",[10,1440,1441],{},"The series is complete: we built an agent, moved its capability behind MCP, connected it to a chat interface, and deployed both pieces.",[1443,1444,1445],"style",{},"html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}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 .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 .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sP4rz, html code.shiki .sP4rz{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":48,"searchDepth":96,"depth":96,"links":1447},[1448,1449,1450],{"id":36,"depth":96,"text":37},{"id":672,"depth":96,"text":673},{"id":1325,"depth":96,"text":1326},"d06af237-adf9-480b-9fd6-51624834efdd","2025-10-07","Deploy the AI application and its MCP server on Cloudflare so people can use its capabilities online from any agent.","md",{"branch":1456},"05.deploying-our-ai-agent-to-the-world-using-cloudflare",null,{},"\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare","---\ncontentId: d06af237-adf9-480b-9fd6-51624834efdd\npart: 5\ntitle: Deploying Our AI Agent to the World Using Cloudflare\ndescription: Deploy the AI application and its MCP server on Cloudflare so people can use its capabilities online from any agent.\ngithub:\n  branch: 05.deploying-our-ai-agent-to-the-world-using-cloudflare\ndate: 2025-10-07\nseriesSlug: ai-agents-and-mcp-server-teaming-up-for-the-agentic-web\n---\n\nThis final part is optional: you can deploy the application and MCP server wherever you prefer. I chose Cloudflare because it is my daily platform for deploying JavaScript projects. We will make a small refactor to run the MCP server as a Cloudflare Worker, while leaving the agent and its Nuxt interface as a separate application.\n\nCloudflare provides several primitives for [AI Agents and MCP servers](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fagents\u002F). Our addition tool is stateless, so we can host it in a plain Worker. The MCP SDK's Web Standards transport works directly with the Worker's `Request` and `Response` APIs, so we do not need a Durable Object. A stateful MCP server would need persistent session management instead.\n\n## Setting up tooling\n\nFirst, install the dependencies:\n\n```bash [terminal]\npnpm add -D wrangler @types\u002Fnode\n```\n\nThen add the following scripts to `package.json`:\n\n```json [package.json]\n{\n  \"scripts\": {\n    \"dev:wrangler\": \"wrangler --config .\u002Fworker\u002Fwrangler.jsonc dev\",\n    \"deploy:wrangler\": \"wrangler --config .\u002Fworker\u002Fwrangler.jsonc deploy\",\n    \"cf-typegen\": \"wrangler --config .\u002Fworker\u002Fwrangler.jsonc types worker\u002Fworker-configuration.d.ts\"\n  }\n}\n```\n\nWe also need a `wrangler.jsonc` to configure our Cloudflare Worker. Create `worker\u002Fwrangler.jsonc` with the following content:\n\n```jsonc [Example]\n{\n  \"$schema\": \"node_modules\u002Fwrangler\u002Fconfig-schema.json\",\n  \"name\": \"our-mcp\",\n  \"main\": \"index.ts\",\n  \"compatibility_date\": \"2025-03-10\",\n  \"compatibility_flags\": [\n    \"nodejs_compat\"\n  ],\n  \"observability\": {\n    \"enabled\": true,\n    \"head_sampling_rate\": 0.1\n  }\n}\n```\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nThe `wrangler.jsonc` file is not stored in the root directory to avoid conflicts when we will deploy the Nuxt application.\n::\n\nWith this file, Wrangler will look for `index.ts` relative to the `worker` directory, which resolves to `worker\u002Findex.ts`. The configuration lives in the `worker` directory so it does not conflict with the Nuxt application's Cloudflare Pages deployment.\n\nTo finish the tooling setup, create a `tsconfig.worker.json` file to configure TypeScript for the Worker:\n\n```json [tsconfig.worker.json]\n{\n  \"compilerOptions\": {\n    \"target\": \"es2021\",\n    \"jsx\": \"react-jsx\",\n    \"lib\": [\n      \"es2021\"\n    ],\n    \"module\": \"es2022\",\n    \"moduleResolution\": \"bundler\",\n    \"resolveJsonModule\": true,\n    \"allowJs\": true,\n    \"checkJs\": false,\n    \"strict\": true,\n    \"noEmit\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"isolatedModules\": true,\n    \"skipLibCheck\": true\n  },\n  \"include\": [\n    \"worker\u002Fworker-configuration.d.ts\",\n    \"worker\u002F**\u002F*.ts\"\n  ]\n}\n```\n\nAdd this file to the existing `tsconfig.json` in the `references` section:\n\n```json [tsconfig.json] {17}\n{\n  \"files\": [],\n  \"references\": [\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.app.json\"\n    },\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.server.json\"\n    },\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.shared.json\"\n    },\n    {\n      \"path\": \".\u002F.nuxt\u002Ftsconfig.node.json\"\n    },\n    {\n      \"path\": \".\u002Ftsconfig.worker.json\"\n    }\n  ]\n}\n```\n\nNow generate types:\n\n```bash [terminal]\npnpm run cf-typegen\n```\n\nThis generates types for the Worker bindings and enables correct autocomplete in the worker files.\n\nDon't forget to add the `.wrangler` folder to `.gitignore` to avoid committing it by mistake.\n\n## Moving the MCP Server to a Worker\n\nNow that the tooling is ready, move the MCP server into a Cloudflare Worker. A Worker is an exported object with a `fetch` method. For our stateless addition tool, `WebStandardStreamableHTTPServerTransport` provides the Streamable HTTP transport directly through the Worker's standard APIs, without requiring a Durable Object.\n\nReplace the old Nitro route with this complete `worker\u002Findex.ts` file:\n\n```ts [worker\u002Findex.ts]\nimport { McpServer } from '@modelcontextprotocol\u002Fsdk\u002Fserver\u002Fmcp.js'\nimport { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol\u002Fsdk\u002Fserver\u002FwebStandardStreamableHttp.js'\nimport { z } from 'zod'\n\nfunction createServer() {\n  const server = new McpServer({\n    name: 'ai-agent',\n    version: '1.0.0',\n  })\n\n  server.tool(\n    'addition',\n    'Adds two numbers',\n    {\n      a: z.number().describe('The first number'),\n      b: z.number().describe('The second number'),\n    },\n    async (params) => {\n      return {\n        content: [\n          {\n            type: 'text',\n            text: String(params.a + params.b),\n          },\n        ],\n      }\n    },\n  )\n\n  return server\n}\n\nexport default {\n  async fetch(request: Request) {\n    if (new URL(request.url).pathname !== '\u002Fmcp') {\n      return new Response('Not found', { status: 404 })\n    }\n\n    const server = createServer()\n    const transport = new WebStandardStreamableHTTPServerTransport({\n      sessionIdGenerator: undefined,\n      enableJsonResponse: true,\n    })\n\n    await server.connect(transport)\n\n    try {\n      return await transport.handleRequest(request)\n    }\n    finally {\n      await transport.close()\n      await server.close()\n    }\n  },\n} satisfies ExportedHandler\u003CEnv>\n```\n\n`createServer` creates a fresh MCP server for each request, and `sessionIdGenerator: undefined` disables MCP sessions. This prevents request state from being shared between clients. `enableJsonResponse: true` is appropriate for this request-response tool and lets us close the server and transport after the response has been created. The route check exposes the MCP server only at `\u002Fmcp`. You can now delete `server\u002Froutes\u002Fmcp.ts`.\n\nWe can start the development server to test our changes.\n\n```bash [server\u002Froutes\u002Fmcp.ts]\npnpm run dev:wrangler\n```\n\nYou can test using either the AI application or the MCP Inspector.\n\n::callout{icon=\"i-ph-info-duotone\" color=\"primary\"}\nChange `NUXT_MCP_ENDPOINT` in your `.env` file to the local MCP endpoint: `http:\u002F\u002Flocalhost:8787\u002Fmcp`. Use the exact URL printed by Wrangler if it selects a different port.\n::\n\n## Deploying to Cloudflare\n\nRun:\n\n```bash [terminal]\npnpm run deploy:wrangler\n```\n\nAfter deployment, Wrangler prints the Worker URL. Your MCP endpoint is the Worker URL followed by `\u002Fmcp`, for example `https:\u002F\u002Four-mcp.\u003Cyour-subdomain>.workers.dev\u002Fmcp`.\n\nTo deploy the AI application, run:\n\n```bash [terminal]\nSERVER_PRESET=cloudflare_pages pnpm run build && npx wrangler --cwd dist pages deploy\n```\n\nThe last step is to set up environment variables in your Cloudflare Pages project. Add `NUXT_OPEN_AI_API_KEY` as a secret and `NUXT_MCP_ENDPOINT` as plain text, using the deployed Worker MCP endpoint URL.\n\n![Cloudflare Pages settings](\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare\u002Fpages-settings.webp)\n\nYour AI application is now deployed and can use the MCP server running on Cloudflare.\n\n\u003Cfigure>\n  \u003Cvideo autoplay loop muted playsinline>\n    \u003Csource src=\"https:\u002F\u002Fimages.soubiran.dev\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare\u002Four-ai-agent.mp4\" type=\"video\u002Fmp4\">\n  \u003C\u002Fvideo>\n  \u003Cfigcaption>Our AI Agent, deployed to everyone.\u003C\u002Ffigcaption>\n\u003C\u002Ffigure>\n\nThe series is complete: we built an agent, moved its capability behind MCP, connected it to a chat interface, and deployed both pieces.\n",{"title":5,"description":1453},"ai-agents-and-mcp-server-teaming-up-for-the-agentic-web",{"loc":1459,"images":1464},[1465],{"loc":1417},"series\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare","AVR_d7PcZA2mmMJezZXx42zKSpsJYlRCCwA41kJcI-0",{"overview":1469,"chapters":1578},{"id":1470,"title":1471,"body":1472,"contentId":1557,"date":1452,"description":1558,"extension":1454,"github":1559,"meetTheInstructor":1562,"meta":1563,"navigation":741,"part":1457,"path":1564,"rawbody":1565,"robots":1457,"schemaOrg":1457,"seo":1566,"seriesSlug":1462,"sitemap":1567,"stem":1568,"subtitle":1569,"topics":1570,"__hash__":1577},"series\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web.md","AI Agents and MCP Server: Teaming Up for the Agentic Web",{"type":7,"value":1473,"toc":1554},[1474,1477,1480,1488,1491,1494,1497,1531,1534,1544,1548],[10,1475,1476],{},"Hey 👋,",[10,1478,1479],{},"For months, I've been exploring AI and the latest innovations. I've been fascinated by the idea of chatting with my website, literally chatting with it through an interface like the one you use to talk to a friend on your phone. That idea led me to create AI Agents that can interact with my website and provide users with high-quality, up-to-date, context-aware information.",[10,1481,1482,1483,1487],{},"This series is not about the exact implementation details of my AI Agent. I have already written two articles about that. The first covers ",[17,1484,1486],{"href":1485},"\u002Fposts\u002Fai-agents-will-deeply-transform-our-experience-with-the-web","the rise of AI Agents"," and their potential impact on the web. The second covers the technical implementation of my AI Agent.",[10,1489,1490],{},"Instead, this series focuses on the foundational concepts you need to get started with your own AI Agent and connect it to an MCP server for additional capabilities.",[10,1492,1493],{},"We will not build anything particularly elaborate because the agentic web is still at an early stage. As I mentioned in my article about the rise of AI Agents, everything remains to be built. There are no established patterns or definitive ways of working yet. For now, the best approach is to build, experiment, evaluate, and iterate.",[10,1495,1496],{},"Throughout this series, we will:",[1498,1499,1500,1508,1514,1520,1526],"ol",{},[1501,1502,1503,1507],"li",{},[1504,1505,1506],"strong",{},"Building an AI Agent Made Easy Thanks to the AI SDK",": Using the AI SDK, we'll build our first AI Agent and understand what makes it different from a traditional AI.",[1501,1509,1510,1513],{},[1504,1511,1512],{},"MCP to Provide Additional Capabilities to the AI Agent",": With the official MCP SDK, we'll create an MCP server with a simple tool and interact with it.",[1501,1515,1516,1519],{},[1504,1517,1518],{},"Pairing AI Agents with MCP to Make the Outside World Accessible",": An AI Agent needs tools, so we'll connect the Agent to the MCP server and let it interact with the outside world.",[1501,1521,1522,1525],{},[1504,1523,1524],{},"A Powerful AI Application Made with Nitro and Nuxt UI",": We'll build a user interface that makes it easy to interact with our AI Agent.",[1501,1527,1528,1530],{},[1504,1529,5],{},": Finally, we'll deploy the AI application and MCP server on Cloudflare. I chose this platform, but you can deploy them wherever you prefer.",[10,1532,1533],{},"By the end, you will have a complete chat interface for talking to your AI Agent, along with all the pieces you need to keep experimenting.",[1411,1535,1426,1536,1426,1541],{},[1428,1537,1430,1538,1426],{"autoPlay":741,"loop":741,"muted":741,"playsInline":741},[1432,1539],{"src":1540,"type":1435},"https:\u002F\u002Fimages.soubiran.dev\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fai-application.mp4",[1419,1542,1543],{},"Our final AI application.",[34,1545,1547],{"id":1546},"chapters","Chapters",[1549,1550],"series-chapters-list",{"className":1551},[1552,1553],"mx-auto","max-w-5xl",{"title":48,"searchDepth":96,"depth":96,"links":1555},[1556],{"id":1546,"depth":96,"text":1547},"76bfa6ec-7e25-4813-a0ae-f4e956e510df","Build an AI application, understand how AI Agents work, and discover how pairing them with an MCP server expands what they can do.",{"name":1560,"repository":1561},"AI Agents and MCP","barbapapazes\u002Fai-agent","For months, I've been fascinated by AI and its potential. I struggled to find the right resources to understand how AI Agents work. After researching and experimenting, I started to grasp the core concepts and I'm excited to share what I learned with you.",{},"\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web","---\ncontentId: 76bfa6ec-7e25-4813-a0ae-f4e956e510df\ntitle: \"AI Agents and MCP Server: Teaming Up for the Agentic Web\"\nsubtitle: Explore the future of the web by building an AI application\ndescription: Build an AI application, understand how AI Agents work, and discover how pairing them with an MCP server expands what they can do.\ndate: 2025-10-07\ntopics:\n  - ai-agents\n  - ai\n  - mcp\n  - agentic-web\n  - nuxt\n  - nuxt-ui\ngithub:\n  name: AI Agents and MCP\n  repository: barbapapazes\u002Fai-agent\nmeetTheInstructor: For months, I've been fascinated by AI and its potential. I struggled to find the right resources to understand how AI Agents work. After researching and experimenting, I started to grasp the core concepts and I'm excited to share what I learned with you.\nseriesSlug: ai-agents-and-mcp-server-teaming-up-for-the-agentic-web\n---\n\nHey 👋,\n\nFor months, I've been exploring AI and the latest innovations. I've been fascinated by the idea of chatting with my website, literally chatting with it through an interface like the one you use to talk to a friend on your phone. That idea led me to create AI Agents that can interact with my website and provide users with high-quality, up-to-date, context-aware information.\n\nThis series is not about the exact implementation details of my AI Agent. I have already written two articles about that. The first covers [the rise of AI Agents](\u002Fposts\u002Fai-agents-will-deeply-transform-our-experience-with-the-web) and their potential impact on the web. The second covers the technical implementation of my AI Agent.\n\nInstead, this series focuses on the foundational concepts you need to get started with your own AI Agent and connect it to an MCP server for additional capabilities.\n\nWe will not build anything particularly elaborate because the agentic web is still at an early stage. As I mentioned in my article about the rise of AI Agents, everything remains to be built. There are no established patterns or definitive ways of working yet. For now, the best approach is to build, experiment, evaluate, and iterate.\n\nThroughout this series, we will:\n\n1. **Building an AI Agent Made Easy Thanks to the AI SDK**: Using the AI SDK, we'll build our first AI Agent and understand what makes it different from a traditional AI.\n2. **MCP to Provide Additional Capabilities to the AI Agent**: With the official MCP SDK, we'll create an MCP server with a simple tool and interact with it.\n3. **Pairing AI Agents with MCP to Make the Outside World Accessible**: An AI Agent needs tools, so we'll connect the Agent to the MCP server and let it interact with the outside world.\n4. **A Powerful AI Application Made with Nitro and Nuxt UI**: We'll build a user interface that makes it easy to interact with our AI Agent.\n5. **Deploying Our AI Agent to the World Using Cloudflare**: Finally, we'll deploy the AI application and MCP server on Cloudflare. I chose this platform, but you can deploy them wherever you prefer.\n\nBy the end, you will have a complete chat interface for talking to your AI Agent, along with all the pieces you need to keep experimenting.\n\n\u003Cfigure>\n  \u003Cvideo autoplay loop muted playsinline>\n    \u003Csource src=\"https:\u002F\u002Fimages.soubiran.dev\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fai-application.mp4\" type=\"video\u002Fmp4\">\n  \u003C\u002Fvideo>\n  \u003Cfigcaption>Our final AI application.\u003C\u002Ffigcaption>\n\u003C\u002Ffigure>\n\n## Chapters\n\n::series-chapters-list\n---\nclass: mx-auto max-w-5xl\n---\n::\n",{"title":1471,"description":1558},{"loc":1564},"series\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web","Explore the future of the web by building an AI application",[1571,1572,1573,1574,1575,1576],"ai-agents","ai","mcp","agentic-web","nuxt","nuxt-ui","3fbdjQUyeN3fzx5NIJ-SVb3udixzleWLpFXsAeV6Tkw",[1579,1585,1591,1598,1604],{"contentId":1580,"title":1506,"description":1581,"path":1582,"part":55,"github":1583,"topics":1457},"9ffbf543-f6d5-45d3-ae35-eb1bfb26843e","AI agents can be mysterious, but they are not as complicated as they seem. Let's prove it with in-depth explanations and examples.","\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fbuilding-an-ai-agent-made-easy-thanks-to-the-ai-sdk",{"branch":1584},"01.building-an-ai-agent-made-easy-thanks-to-the-ai-sdk",{"contentId":1586,"title":1512,"description":1587,"path":1588,"part":96,"github":1589,"topics":1457},"b5dafecc-480c-4954-ac35-836d4e71c7a3","MCP servers are popping up everywhere. Understanding them is key to unlocking the full potential of AI agents.","\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fmcp-to-provide-additional-capabilities-to-the-ai-agent",{"branch":1590},"02.mcp-to-provide-additional-capabilities-to-the-ai-agent",{"contentId":1592,"title":1593,"description":1594,"path":1595,"part":105,"github":1596,"topics":1457},"4c18ff8d-db49-4197-96f9-7ec16756e9cd","Pair AI Agents with MCP to Access the Outside World","AI agents with custom tools are powerful. Connecting an MCP server to an agent unlocks another level of capability.","\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fpair-ai-agents-with-mcp-to-access-the-outside-world",{"branch":1597},"03.pairing-ai-agents-with-mcp-to-make-outside-world-accessible",{"contentId":1599,"title":1524,"description":1600,"path":1601,"part":120,"github":1602,"topics":1457},"19f0acd2-037f-4538-9d69-cbb86a0bea64","Having an AI agent is a good start, but integrating it into an application makes all the difference. Nuxt UI makes that easy.","\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fa-powerful-ai-application-made-with-nitro-and-nuxt-ui",{"branch":1603},"04.a-powerful-ai-application-made-with-nitro-and-nuxt-ui",{"contentId":1451,"title":5,"description":1453,"path":1459,"part":133,"github":1605,"topics":1457},{"branch":1456},1795016695429]