How to Add a Web Search Tool to the Vercel AI SDK (Free, No API Key) A developer demonstrated a roughly fifteen-line TypeScript setup that gives a Vercel AI SDK agent live web search by connecting the SDK's MCP client to a stdio search server, using the free `@agentsearchhq/agentsearch-mcp` package with no API key. The walkthrough passes the `agentsearch_web_search` tool to `generateText` or `ToolLoopAgent`, caps model tool calls with `isStepCount(5)`, and was typechecked with TypeScript 7.0.2 and run on Node.js 22.23.3 against AI SDK 7.0.154 and `@ai-sdk/mcp` 2.0.85, with real search calls but a mock model. The free tier allows up to 25 searches per day per IP on shared capacity. An AI SDK agent can only answer from training data until it has a way to look things up. This guide adds a Vercel AI SDK web search tool in about fifteen lines of TypeScript, with no API key, signup, or extra SDK. We connect the AI SDK's MCP client to a stdio search server, pass the tool to generateText or ToolLoopAgent , cap how often the model can call it, and test the whole loop without a model key. We'll use AgentSearch https://agentsearchhq.com/?utm source=devto&utm medium=referral&utm campaign=add-web-search-to-vercel-ai-sdk , which ships as the @agentsearchhq/agentsearch-mcp package on npm. Out of the box it gives your agent a free agentsearch web search tool: Free tier: up to 25 searches/day per IP, no key needed shared daily capacity; paid calls have no cap . What we tested: every snippet below was typechecked with TypeScript 7.0.2 and run on Linux with Node.js 22.23.3, using ai 7.0.154, @ai-sdk/mcp 2.0.85 and @agentsearchhq/agentsearch-mcp 1.3.5. The search calls were real. The model was the AI SDK's own mock model, so we didn't call a hosted LLM. The provider line openai "gpt-5-mini" typechecks against @ai-sdk/openai 4.0.103, and you can swap in any provider the AI SDK supports. Prefer LangChain? See add web search to a LangChain.js agent https://agentsearchhq.com/blog/add-web-search-to-langchain-js-agent?utm source=devto&utm medium=referral&utm campaign=add-web-search-to-vercel-ai-sdk . New to MCP itself? Start with MCP web search for AI agents https://agentsearchhq.com/blog/mcp-web-search-for-ai-agents?utm source=devto&utm medium=referral&utm campaign=add-web-search-to-vercel-ai-sdk . "node": " =22" . On Node 20, npm install ai gave us AI SDK 6 instead, and some names below differ in v6. npx on your PATH. @ai-sdk/openai , if you want to run the agent against a real model. The offline test in Step 5 needs none. npm install ai @ai-sdk/mcp zod npm install @ai-sdk/openai or any other AI SDK provider You don't need to install the search server. npx downloads and caches it on first run. Create src/agentsearch.ts : js import { createMCPClient } from "@ai-sdk/mcp"; import { Experimental StdioMCPTransport } from "@ai-sdk/mcp/mcp-stdio"; export async function connectAgentSearch env: Record