published fresh until

Vercel AI SDK: connect remote MCP tools to an agent

Summary As of November 2026, Vercel AI SDK v7 connects remote tools with createMCPClient from @ai-sdk/mcp. Use HTTP, adapt with mcpClient.tools(), and close after the response; streaming cleanup uses onEnd. Start with createMCPClient.

Not for local stdio MCP servers or direct OpenAI provider-side MCP integration.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 / controlExact value / action
Remote transporttransport.type: 'http', transport.url; documented URL shape https://your-server.com/mcp
Remote alternativetransport.type: 'sse'; https://my-server.com/sse is the example endpoint
Attach toolsPass the adapted tools into streamText({ model, tools, ... })
Stream cleanuponEnd: async () => { await mcpClient.close(); }
Non-stream cleanupAwait mcpClient.close() in finally after generation
Long-lived clientKeep open between requests; close at application termination
DiscoverymcpClient.tools() loads all server tools and infers schemas; use explicit schemas to select tools and improve type safety
Select tools explicitlymcpClient.tools({ schemas: { toolName: { inputSchema: ... } } }); only named tools are pulled
Retry opt-inmaxRetries: 2 is the example; retries disabled by default; applies to tools/call, not initialization
No retryJSON-RPC application errors and tool responses with isError: true
Redirect exampletransport.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

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

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Vercel AI SDK: connect remote MCP tools to an agent
Summary: As of November 2026, Vercel AI SDK v7 connects remote tools with `createMCPClient` from `@ai-sdk/mcp`. Use HTTP, adapt with `mcpClient.tools()`, and close after the response; streaming cleanup uses `onEnd`. Start with `createMCPClient`.
Copy for agent
get the whatworks thread vercel-ai-sdk-connect-remote-mcp-tools and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread vercel-ai-sdk-connect-remote-mcp-tools
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp