[{"data":1,"prerenderedAt":825},["ShallowReactive",2],{"series-\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fpair-ai-agents-with-mcp-to-access-the-outside-world":3,"series-context-\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web":686},{"id":4,"title":5,"body":6,"contentId":671,"date":672,"description":673,"extension":674,"github":675,"meetTheInstructor":677,"meta":678,"navigation":66,"part":70,"path":679,"rawbody":680,"robots":677,"schemaOrg":677,"seo":681,"seriesSlug":682,"sitemap":683,"stem":684,"subtitle":677,"topics":677,"__hash__":685},"series\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fpair-ai-agents-with-mcp-to-access-the-outside-world.md","Pair AI Agents with MCP to Access the Outside World",{"type":7,"value":8,"toc":669},"minimark",[9,13,26,29,132,143,154,157,609,626,642,645,662,665],[10,11,12],"p",{},"Our MCP server is ready, but the agent still does not know it exists. The next step is to give the agent an MCP client that can discover the server's tools and make them available to the model.",[10,14,15,16,20,21,25],{},"When we tested the server manually, the MCP Inspector used ",[17,18,19],"strong",{},"List Tools"," to retrieve its available tools. The AI SDK can do the same programmatically: it connects to the server, lists the tools, and adapts them to the interface used by ",[22,23,24],"code",{},"streamText",".",[10,27,28],{},"Before doing so, we need to add a Nitro runtime config to indicate the URL of the MCP.",[30,31,39],"pre",{"className":32,"code":33,"filename":34,"highlights":35,"language":37,"meta":38,"style":38},"language-ts shiki shiki-themes github-light github-light github-dark","import { defineNitroConfig } from 'nitropack\u002Fconfig'\n\nexport default defineNitroConfig({\n  runtimeConfig: {\n    openAiApiKey: '',\n    mcpEndpoint: '',\n  },\n  \u002F\u002F ...\n})\n","Example",[36],6,"ts","",[22,40,41,61,68,84,90,102,113,119,126],{"__ignoreMap":38},[42,43,46,50,54,57],"span",{"class":44,"line":45},"line",1,[42,47,49],{"class":48},"s8jYJ","import",[42,51,53],{"class":52},"sxrX7"," { defineNitroConfig } ",[42,55,56],{"class":48},"from",[42,58,60],{"class":59},"sIIMD"," 'nitropack\u002Fconfig'\n",[42,62,64],{"class":44,"line":63},2,[42,65,67],{"emptyLinePlaceholder":66},true,"\n",[42,69,71,74,77,81],{"class":44,"line":70},3,[42,72,73],{"class":48},"export",[42,75,76],{"class":48}," default",[42,78,80],{"class":79},"snPdu"," defineNitroConfig",[42,82,83],{"class":52},"({\n",[42,85,87],{"class":44,"line":86},4,[42,88,89],{"class":52},"  runtimeConfig: {\n",[42,91,93,96,99],{"class":44,"line":92},5,[42,94,95],{"class":52},"    openAiApiKey: ",[42,97,98],{"class":59},"''",[42,100,101],{"class":52},",\n",[42,103,106,109,111],{"class":104,"line":36},[44,105],"highlight",[42,107,108],{"class":52},"    mcpEndpoint: ",[42,110,98],{"class":59},[42,112,101],{"class":52},[42,114,116],{"class":44,"line":115},7,[42,117,118],{"class":52},"  },\n",[42,120,122],{"class":44,"line":121},8,[42,123,125],{"class":124},"sCsY4","  \u002F\u002F ...\n",[42,127,129],{"class":44,"line":128},9,[42,130,131],{"class":52},"})\n",[10,133,134,135,138,139,142],{},"In your ",[22,136,137],{},".env"," file, set the ",[22,140,141],{},"MCP_ENDPOINT"," variable to the MCP URL:",[30,144,148],{"className":145,"code":146,"filename":34,"language":147,"meta":38,"style":38},"language-ini shiki shiki-themes github-light github-light github-dark","MCP_ENDPOINT=http:\u002F\u002Flocalhost:3000\u002Fmcp\n","ini",[22,149,150],{"__ignoreMap":38},[42,151,152],{"class":44,"line":45},[42,153,146],{},[10,155,156],{},"Then, we can connect our agent to the MCP server. The client is created for the request, retrieves the available tools, and remains open until the streamed response finishes.",[30,158,172],{"className":32,"code":159,"filename":34,"highlights":160,"language":37,"meta":38,"style":38},"import { createOpenAI } from '@ai-sdk\u002Fopenai'\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol\u002Fsdk\u002Fclient\u002FstreamableHttp.js'\nimport { convertToModelMessages, experimental_createMCPClient, stepCountIs, streamText } from 'ai'\nimport { defineEventHandler, defineLazyEventHandler, readBody } from 'h3'\nimport { useRuntimeConfig } from 'nitropack\u002Fruntime'\n\nexport default defineLazyEventHandler(() => {\n  const runtimeConfig = useRuntimeConfig()\n\n  const model = createOpenAI({\n    apiKey: runtimeConfig.openAiApiKey,\n  })\n\n  return defineEventHandler(async (event) => {\n    const { messages } = await readBody(event)\n\n    const httpTransport = new StreamableHTTPClientTransport(\n      new URL(runtimeConfig.mcpEndpoint)\n    )\n    const httpClient = await experimental_createMCPClient({\n      transport: httpTransport\n    })\n    const tools = await httpClient.tools()\n\n    const result = streamText({\n      model: model('gpt-5-nano'),\n      system: `You are a helpful assistant. You can use the tool to add two numbers together.`,\n      stopWhen: stepCountIs(2),\n      tools,\n      messages: convertToModelMessages(messages),\n      onFinish: () => httpClient.close(),\n      onAbort: () => httpClient.close(),\n    })\n\n    return result.toUIMessageStreamResponse()\n  })\n})\n",[63,161,162,163,164,165,166,167,168,169,170,171],17,18,19,20,21,22,23,30,31,32,33,[22,173,174,186,199,211,223,235,239,257,275,279,294,300,306,311,340,367,372,391,403,409,426,432,438,458,463,478,495,506,522,528,540,559,575,580,585,599,604],{"__ignoreMap":38},[42,175,176,178,181,183],{"class":44,"line":45},[42,177,49],{"class":48},[42,179,180],{"class":52}," { createOpenAI } ",[42,182,56],{"class":48},[42,184,185],{"class":59}," '@ai-sdk\u002Fopenai'\n",[42,187,189,191,194,196],{"class":188,"line":63},[44,105],[42,190,49],{"class":48},[42,192,193],{"class":52}," { StreamableHTTPClientTransport } ",[42,195,56],{"class":48},[42,197,198],{"class":59}," '@modelcontextprotocol\u002Fsdk\u002Fclient\u002FstreamableHttp.js'\n",[42,200,201,203,206,208],{"class":44,"line":70},[42,202,49],{"class":48},[42,204,205],{"class":52}," { convertToModelMessages, experimental_createMCPClient, stepCountIs, streamText } ",[42,207,56],{"class":48},[42,209,210],{"class":59}," 'ai'\n",[42,212,213,215,218,220],{"class":44,"line":86},[42,214,49],{"class":48},[42,216,217],{"class":52}," { defineEventHandler, defineLazyEventHandler, readBody } ",[42,219,56],{"class":48},[42,221,222],{"class":59}," 'h3'\n",[42,224,225,227,230,232],{"class":44,"line":92},[42,226,49],{"class":48},[42,228,229],{"class":52}," { useRuntimeConfig } ",[42,231,56],{"class":48},[42,233,234],{"class":59}," 'nitropack\u002Fruntime'\n",[42,236,237],{"class":44,"line":36},[42,238,67],{"emptyLinePlaceholder":66},[42,240,241,243,245,248,251,254],{"class":44,"line":115},[42,242,73],{"class":48},[42,244,76],{"class":48},[42,246,247],{"class":79}," defineLazyEventHandler",[42,249,250],{"class":52},"(() ",[42,252,253],{"class":48},"=>",[42,255,256],{"class":52}," {\n",[42,258,259,262,266,269,272],{"class":44,"line":121},[42,260,261],{"class":48},"  const",[42,263,265],{"class":264},"sBjJW"," runtimeConfig",[42,267,268],{"class":48}," =",[42,270,271],{"class":79}," useRuntimeConfig",[42,273,274],{"class":52},"()\n",[42,276,277],{"class":44,"line":128},[42,278,67],{"emptyLinePlaceholder":66},[42,280,282,284,287,289,292],{"class":44,"line":281},10,[42,283,261],{"class":48},[42,285,286],{"class":264}," model",[42,288,268],{"class":48},[42,290,291],{"class":79}," createOpenAI",[42,293,83],{"class":52},[42,295,297],{"class":44,"line":296},11,[42,298,299],{"class":52},"    apiKey: runtimeConfig.openAiApiKey,\n",[42,301,303],{"class":44,"line":302},12,[42,304,305],{"class":52},"  })\n",[42,307,309],{"class":44,"line":308},13,[42,310,67],{"emptyLinePlaceholder":66},[42,312,314,317,320,323,326,329,333,336,338],{"class":44,"line":313},14,[42,315,316],{"class":48},"  return",[42,318,319],{"class":79}," defineEventHandler",[42,321,322],{"class":52},"(",[42,324,325],{"class":48},"async",[42,327,328],{"class":52}," (",[42,330,332],{"class":331},"sP4rz","event",[42,334,335],{"class":52},") ",[42,337,253],{"class":48},[42,339,256],{"class":52},[42,341,343,346,349,352,355,358,361,364],{"class":44,"line":342},15,[42,344,345],{"class":48},"    const",[42,347,348],{"class":52}," { ",[42,350,351],{"class":264},"messages",[42,353,354],{"class":52}," } ",[42,356,357],{"class":48},"=",[42,359,360],{"class":48}," await",[42,362,363],{"class":79}," readBody",[42,365,366],{"class":52},"(event)\n",[42,368,370],{"class":44,"line":369},16,[42,371,67],{"emptyLinePlaceholder":66},[42,373,375,377,380,382,385,388],{"class":374,"line":161},[44,105],[42,376,345],{"class":48},[42,378,379],{"class":264}," httpTransport",[42,381,268],{"class":48},[42,383,384],{"class":48}," new",[42,386,387],{"class":79}," StreamableHTTPClientTransport",[42,389,390],{"class":52},"(\n",[42,392,394,397,400],{"class":393,"line":162},[44,105],[42,395,396],{"class":48},"      new",[42,398,399],{"class":79}," URL",[42,401,402],{"class":52},"(runtimeConfig.mcpEndpoint)\n",[42,404,406],{"class":405,"line":163},[44,105],[42,407,408],{"class":52},"    )\n",[42,410,412,414,417,419,421,424],{"class":411,"line":164},[44,105],[42,413,345],{"class":48},[42,415,416],{"class":264}," httpClient",[42,418,268],{"class":48},[42,420,360],{"class":48},[42,422,423],{"class":79}," experimental_createMCPClient",[42,425,83],{"class":52},[42,427,429],{"class":428,"line":165},[44,105],[42,430,431],{"class":52},"      transport: httpTransport\n",[42,433,435],{"class":434,"line":166},[44,105],[42,436,437],{"class":52},"    })\n",[42,439,441,443,446,448,450,453,456],{"class":440,"line":167},[44,105],[42,442,345],{"class":48},[42,444,445],{"class":264}," tools",[42,447,268],{"class":48},[42,449,360],{"class":48},[42,451,452],{"class":52}," httpClient.",[42,454,455],{"class":79},"tools",[42,457,274],{"class":52},[42,459,461],{"class":44,"line":460},24,[42,462,67],{"emptyLinePlaceholder":66},[42,464,466,468,471,473,476],{"class":44,"line":465},25,[42,467,345],{"class":48},[42,469,470],{"class":264}," result",[42,472,268],{"class":48},[42,474,475],{"class":79}," streamText",[42,477,83],{"class":52},[42,479,481,484,487,489,492],{"class":44,"line":480},26,[42,482,483],{"class":52},"      model: ",[42,485,486],{"class":79},"model",[42,488,322],{"class":52},[42,490,491],{"class":59},"'gpt-5-nano'",[42,493,494],{"class":52},"),\n",[42,496,498,501,504],{"class":44,"line":497},27,[42,499,500],{"class":52},"      system: ",[42,502,503],{"class":59},"`You are a helpful assistant. You can use the tool to add two numbers together.`",[42,505,101],{"class":52},[42,507,509,512,515,517,520],{"class":44,"line":508},28,[42,510,511],{"class":52},"      stopWhen: ",[42,513,514],{"class":79},"stepCountIs",[42,516,322],{"class":52},[42,518,519],{"class":264},"2",[42,521,494],{"class":52},[42,523,525],{"class":44,"line":524},29,[42,526,527],{"class":52},"      tools,\n",[42,529,531,534,537],{"class":530,"line":168},[44,105],[42,532,533],{"class":52},"      messages: ",[42,535,536],{"class":79},"convertToModelMessages",[42,538,539],{"class":52},"(messages),\n",[42,541,543,546,549,551,553,556],{"class":542,"line":169},[44,105],[42,544,545],{"class":79},"      onFinish",[42,547,548],{"class":52},": () ",[42,550,253],{"class":48},[42,552,452],{"class":52},[42,554,555],{"class":79},"close",[42,557,558],{"class":52},"(),\n",[42,560,562,565,567,569,571,573],{"class":561,"line":170},[44,105],[42,563,564],{"class":79},"      onAbort",[42,566,548],{"class":52},[42,568,253],{"class":48},[42,570,452],{"class":52},[42,572,555],{"class":79},[42,574,558],{"class":52},[42,576,578],{"class":577,"line":171},[44,105],[42,579,437],{"class":52},[42,581,583],{"class":44,"line":582},34,[42,584,67],{"emptyLinePlaceholder":66},[42,586,588,591,594,597],{"class":44,"line":587},35,[42,589,590],{"class":48},"    return",[42,592,593],{"class":52}," result.",[42,595,596],{"class":79},"toUIMessageStreamResponse",[42,598,274],{"class":52},[42,600,602],{"class":44,"line":601},36,[42,603,305],{"class":52},[42,605,607],{"class":44,"line":606},37,[42,608,131],{"class":52},[10,610,611,612,615,616,618,619,621,622,625],{},"The most important line is ",[22,613,614],{},"const tools = await httpClient.tools()",". Like the Inspector's ",[17,617,19],{}," action, it retrieves the tools exposed by the MCP server. Passing them to ",[22,620,24],{}," makes those tools available to the model. When the model requests one, ",[22,623,624],{},"experimental_createMCPClient"," uses the HTTP transport to call the MCP server on the agent's behalf.",[627,628,631],"callout",{"color":629,"icon":630},"info","i-ph-info-duotone",[10,632,633,634,637,638,641],{},"The MCP client uses the Streamable HTTP transport to exchange protocol messages with the MCP server. Closing the client in ",[22,635,636],{},"onFinish"," or ",[22,639,640],{},"onAbort"," keeps it available while the response is streaming and releases its resources afterward.",[10,643,644],{},"From the user's perspective, the agent behaves just as it did with a direct tool. But from the architectural perspective, the agent now consumes a standardized capability provided by a separate server.",[646,647,648,649,648,658],"figure",{},"\n  ",[650,651,652,653,648],"video",{"autoPlay":66,"loop":66,"muted":66,"playsInline":66},"\n    ",[654,655],"source",{"src":656,"type":657},"https:\u002F\u002Fimages.soubiran.dev\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fmcp-to-provide-additional-capabilities-to-the-ai-agent\u002Fai-agent-paired-with-mcp.mp4","video\u002Fmp4",[659,660,661],"figcaption",{},"The AI Agent using a tool and generating a response.",[10,663,664],{},"The agent can now use a tool without knowing how it is implemented. We can evolve the MCP server independently, let compatible clients use it, or connect the agent to another MCP server when it needs additional capabilities. Next, we will add a chat interface so people can use the agent directly.",[666,667,668],"style",{},"html pre.shiki code .s8jYJ, html code.shiki .s8jYJ{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sxrX7, html code.shiki .sxrX7{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sIIMD, html code.shiki .sIIMD{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .snPdu, html code.shiki .snPdu{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBjJW, html code.shiki .sBjJW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP4rz, html code.shiki .sP4rz{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":38,"searchDepth":63,"depth":63,"links":670},[],"4c18ff8d-db49-4197-96f9-7ec16756e9cd","2025-10-07","AI agents with custom tools are powerful. Connecting an MCP server to an agent unlocks another level of capability.","md",{"branch":676},"03.pairing-ai-agents-with-mcp-to-make-outside-world-accessible",null,{},"\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fpair-ai-agents-with-mcp-to-access-the-outside-world","---\ncontentId: 4c18ff8d-db49-4197-96f9-7ec16756e9cd\npart: 3\ntitle: Pair AI Agents with MCP to Access the Outside World\ndescription: AI agents with custom tools are powerful. Connecting an MCP server to an agent unlocks another level of capability.\ngithub:\n  branch: 03.pairing-ai-agents-with-mcp-to-make-outside-world-accessible\ndate: 2025-10-07\nseriesSlug: ai-agents-and-mcp-server-teaming-up-for-the-agentic-web\n---\n\nOur MCP server is ready, but the agent still does not know it exists. The next step is to give the agent an MCP client that can discover the server's tools and make them available to the model.\n\nWhen we tested the server manually, the MCP Inspector used **List Tools** to retrieve its available tools. The AI SDK can do the same programmatically: it connects to the server, lists the tools, and adapts them to the interface used by `streamText`.\n\nBefore doing so, we need to add a Nitro runtime config to indicate the URL of the MCP.\n\n```ts [Example] {6}\nimport { defineNitroConfig } from 'nitropack\u002Fconfig'\n\nexport default defineNitroConfig({\n  runtimeConfig: {\n    openAiApiKey: '',\n    mcpEndpoint: '',\n  },\n  \u002F\u002F ...\n})\n```\n\nIn your `.env` file, set the `MCP_ENDPOINT` variable to the MCP URL:\n\n```ini [Example]\nMCP_ENDPOINT=http:\u002F\u002Flocalhost:3000\u002Fmcp\n```\n\nThen, we can connect our agent to the MCP server. The client is created for the request, retrieves the available tools, and remains open until the streamed response finishes.\n\n```ts [Example] {2,17-23,30-33}\nimport { createOpenAI } from '@ai-sdk\u002Fopenai'\nimport { StreamableHTTPClientTransport } from '@modelcontextprotocol\u002Fsdk\u002Fclient\u002FstreamableHttp.js'\nimport { convertToModelMessages, experimental_createMCPClient, stepCountIs, streamText } from 'ai'\nimport { defineEventHandler, defineLazyEventHandler, readBody } from 'h3'\nimport { useRuntimeConfig } from 'nitropack\u002Fruntime'\n\nexport default defineLazyEventHandler(() => {\n  const runtimeConfig = useRuntimeConfig()\n\n  const model = createOpenAI({\n    apiKey: runtimeConfig.openAiApiKey,\n  })\n\n  return defineEventHandler(async (event) => {\n    const { messages } = await readBody(event)\n\n    const httpTransport = new StreamableHTTPClientTransport(\n      new URL(runtimeConfig.mcpEndpoint)\n    )\n    const httpClient = await experimental_createMCPClient({\n      transport: httpTransport\n    })\n    const tools = await httpClient.tools()\n\n    const result = streamText({\n      model: model('gpt-5-nano'),\n      system: `You are a helpful assistant. You can use the tool to add two numbers together.`,\n      stopWhen: stepCountIs(2),\n      tools,\n      messages: convertToModelMessages(messages),\n      onFinish: () => httpClient.close(),\n      onAbort: () => httpClient.close(),\n    })\n\n    return result.toUIMessageStreamResponse()\n  })\n})\n```\n\nThe most important line is `const tools = await httpClient.tools()`. Like the Inspector's **List Tools** action, it retrieves the tools exposed by the MCP server. Passing them to `streamText` makes those tools available to the model. When the model requests one, `experimental_createMCPClient` uses the HTTP transport to call the MCP server on the agent's behalf.\n\n::callout{icon=\"i-ph-info-duotone\" color=\"info\"}\nThe MCP client uses the Streamable HTTP transport to exchange protocol messages with the MCP server. Closing the client in `onFinish` or `onAbort` keeps it available while the response is streaming and releases its resources afterward.\n::\n\nFrom the user's perspective, the agent behaves just as it did with a direct tool. But from the architectural perspective, the agent now consumes a standardized capability provided by a separate server.\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\u002Fmcp-to-provide-additional-capabilities-to-the-ai-agent\u002Fai-agent-paired-with-mcp.mp4\" type=\"video\u002Fmp4\">\n  \u003C\u002Fvideo>\n  \u003Cfigcaption>The AI Agent using a tool and generating a response.\u003C\u002Ffigcaption>\n\u003C\u002Ffigure>\n\nThe agent can now use a tool without knowing how it is implemented. We can evolve the MCP server independently, let compatible clients use it, or connect the agent to another MCP server when it needs additional capabilities. Next, we will add a chat interface so people can use the agent directly.\n",{"title":5,"description":673},"ai-agents-and-mcp-server-teaming-up-for-the-agentic-web",{"loc":679},"series\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fpair-ai-agents-with-mcp-to-access-the-outside-world","8lav6xyB7Qa9ROPAH4p8q_d1olw6SA-HlgeU7NhRT_I",{"overview":687,"chapters":798},{"id":688,"title":689,"body":690,"contentId":777,"date":672,"description":778,"extension":674,"github":779,"meetTheInstructor":782,"meta":783,"navigation":66,"part":677,"path":784,"rawbody":785,"robots":677,"schemaOrg":677,"seo":786,"seriesSlug":682,"sitemap":787,"stem":788,"subtitle":789,"topics":790,"__hash__":797},"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":691,"toc":774},[692,695,698,707,710,713,716,750,753,763,768],[10,693,694],{},"Hey 👋,",[10,696,697],{},"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,699,700,701,706],{},"This series is not about the exact implementation details of my AI Agent. I have already written two articles about that. The first covers ",[702,703,705],"a",{"href":704},"\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,708,709],{},"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,711,712],{},"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,714,715],{},"Throughout this series, we will:",[717,718,719,726,732,738,744],"ol",{},[720,721,722,725],"li",{},[17,723,724],{},"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.",[720,727,728,731],{},[17,729,730],{},"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.",[720,733,734,737],{},[17,735,736],{},"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.",[720,739,740,743],{},[17,741,742],{},"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.",[720,745,746,749],{},[17,747,748],{},"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.",[10,751,752],{},"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.",[646,754,648,755,648,760],{},[650,756,652,757,648],{"autoPlay":66,"loop":66,"muted":66,"playsInline":66},[654,758],{"src":759,"type":657},"https:\u002F\u002Fimages.soubiran.dev\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fai-application.mp4",[659,761,762],{},"Our final AI application.",[764,765,767],"h2",{"id":766},"chapters","Chapters",[769,770],"series-chapters-list",{"className":771},[772,773],"mx-auto","max-w-5xl",{"title":38,"searchDepth":63,"depth":63,"links":775},[776],{"id":766,"depth":63,"text":767},"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":780,"repository":781},"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":689,"description":778},{"loc":784},"series\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web","Explore the future of the web by building an AI application",[791,792,793,794,795,796],"ai-agents","ai","mcp","agentic-web","nuxt","nuxt-ui","3fbdjQUyeN3fzx5NIJ-SVb3udixzleWLpFXsAeV6Tkw",[799,805,811,813,819],{"contentId":800,"title":724,"description":801,"path":802,"part":45,"github":803,"topics":677},"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":804},"01.building-an-ai-agent-made-easy-thanks-to-the-ai-sdk",{"contentId":806,"title":730,"description":807,"path":808,"part":63,"github":809,"topics":677},"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":810},"02.mcp-to-provide-additional-capabilities-to-the-ai-agent",{"contentId":671,"title":5,"description":673,"path":679,"part":70,"github":812,"topics":677},{"branch":676},{"contentId":814,"title":742,"description":815,"path":816,"part":86,"github":817,"topics":677},"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":818},"04.a-powerful-ai-application-made-with-nitro-and-nuxt-ui",{"contentId":820,"title":748,"description":821,"path":822,"part":92,"github":823,"topics":677},"d06af237-adf9-480b-9fd6-51624834efdd","Deploy the AI application and its MCP server on Cloudflare so people can use its capabilities online from any agent.","\u002Fseries\u002Fai-agents-and-mcp-server-teaming-up-for-the-agentic-web\u002Fdeploying-our-ai-agent-to-the-world-using-cloudflare",{"branch":824},"05.deploying-our-ai-agent-to-the-world-using-cloudflare",1795016695354]