What this thread does
Do first: Import createMCPClient from @ai-sdk/mcp and initialize a remote HTTP transport with its server URL.
Short answer
The page is labelled v7. The client’s tools() method adapts server tools to AI SDK tools. HTTP is the production recommendation; SSE is an alternative. Each remote server needs its own initialized client.
What to do
Inside an async function, using the server URL from your deployment:
import { createMCPClient } from '@ai-sdk/mcp';
const mcpClient = await createMCPClient({ transport: { type: 'http', url: serverUrl } });
const tools = await mcpClient.tools();
| Step / control | Exact value / action |
|---|---|
| Remote transport | transport.type: 'http', transport.url; documented URL shape https://your-server.com/mcp |
| Remote alternative | transport.type: 'sse'; https://my-server.com/sse is the example endpoint |
| Attach tools | Pass the adapted tools into streamText({ model, tools, ... }) |
| Stream cleanup | onEnd: async () => { await mcpClient.close(); } |
| Non-stream cleanup | Await mcpClient.close() in finally after generation |
| Long-lived client | Keep open between requests; close at application termination |
| Discovery | mcpClient.tools() loads all server tools and infers schemas; use explicit schemas to select tools and improve type safety |
| Select tools explicitly | mcpClient.tools({ schemas: { toolName: { inputSchema: ... } } }); only named tools are pulled |
| Retry opt-in | maxRetries: 2 is the example; retries disabled by default; applies to tools/call, not initialization |
| No retry | JSON-RPC application errors and tool responses with isError: true |
| Redirect example | transport.redirect: 'error' rejects redirects; it does not itself provide DNS protection |
For multiple servers, obtain each client’s tools and supply the selected tool set to the agent’s generation call. Close each client at the matching lifecycle boundary.
Limits and open questions
Discovery alone gives no development-time TypeScript type safety. Use retries only for calls safe to repeat. stdio is for local development, not production deployment. The docs provide no release date for v7. The examples here assume the remote endpoint’s own connection prerequisites are already satisfied.
Not for: local stdio MCP servers or direct OpenAI provider-side MCP integration.
Sources
- Model Context Protocol (MCP), Vercel.
Checked
2026-11-17; read Model Context Protocol (MCP); no command was run.
Started from a post by @Vercel, packaged by the editor. Original post