Vercel shipped AI SDK 6 in May 2026 with stable MCP support, and for TypeScript teams it's the shortest path from an MCP server to a working agent. The SDK's MCP client converts any server's tools into native AI SDK tools, so they slot straight into generateText, streamText or the new ToolLoopAgent. Here's the setup and the pattern that ships to production.
Create an MCP client
createMCPClient opens a lightweight client against a server and auto-converts its tools. Install the SDK, then use the Streamable HTTP transport for remote servers:
npm i ai
import { createMCPClient } from 'ai';
const mcp = await createMCPClient({
transport: { type: 'http', url: 'https://api.githubcopilot.com/mcp/' },
});
const tools = await mcp.tools();
Run a tool loop
Pass the tools to ToolLoopAgent, SDK 6's default production agent. It calls the model, executes requested tools, feeds results back into the conversation, and stops when the model finishes or your stopWhen condition trips:
import { ToolLoopAgent } from 'ai';
const agent = new ToolLoopAgent({ model: 'anthropic/claude-opus-4-8', tools });
const { text } = await agent.generate({ prompt: 'Open a PR for the failing test' });
Close the client
createMCPClient is deliberately minimal — no reconnection logic — so wrap runs in try/finally and call await mcp.close() when done. For a long-lived server, keep one client per request scope rather than one global, so a slow server can't wedge every request behind it.
Where it shines
Because the SDK runs the same on the edge and in Node, an MCP-backed agent deploys to a Vercel function without extra plumbing. Human-in-the-loop tool approval, added in SDK 6, lets you gate destructive calls before they run — the safety rail you want the moment an agent can write, not just read.
Which servers to start with
Give a build agent GitHub; a research agent Exa or Firecrawl; your own app the Vercel server. All attach through the same client.
Going further
Deploying the servers too? See deploy MCP servers to Docker & Cloudflare. Compare transports in Streamable HTTP vs SSE vs stdio, gate access with MCP security best practices, and build a front-end stack from the React loadout.