Skip to main content
Adapters are thin bridge layers that take the tools exposed by an MCPClient or MultiSessionClient and translate them into the tool format expected by each AI framework. You do not need every adapter — install only the peer dependency for the framework you are using, and import the corresponding adapter class from its dedicated entry point.

Available adapters

Vercel AI SDK

Use MCP tools with streamText, generateText, and useChat from the Vercel AI SDK.

LangChain

Expose MCP tools as DynamicStructuredTool instances for LangChain and LangGraph agents.

Mastra

Supply MCP tools directly to Mastra Agent instances with Zod-validated schemas.

AG-UI

Bridge MCP tools with remote Python agents (LangGraph, AutoGen) using the AG-UI protocol.

Adapter reference

AdapterFrameworkImport pathPeer dependency
AIAdapterVercel AI SDK@mcp-ts/sdk/adapters/aiai
LangChainAdapterLangChain@mcp-ts/sdk/adapters/langchain@langchain/core, zod
MastraAdapterMastra@mcp-ts/sdk/adapters/mastrazod
AguiAdapterAG-UI@mcp-ts/sdk/adapters/agui-adapter@ag-ui/client, rxjs

Common patterns

Single client vs. multi-session

Every adapter accepts either a single MCPClient or a MultiSessionClient. When you pass a MultiSessionClient, the adapter fetches tools from all connected servers and merges them into a single tool set.
import { MCPClient } from '@mcp-ts/sdk/server';
import { MultiSessionClient } from '@mcp-ts/sdk/server';
import { AIAdapter } from '@mcp-ts/sdk/adapters/ai';

// Single server
const single = new MCPClient({
  identity: 'user_123',
  sessionId: 'session_abc',
  serverUrl: 'https://mcp-server.example.com',
  callbackUrl: 'https://myapp.example.com/callback',
});
await single.connect();
const singleTools = await AIAdapter.getTools(single);

// Multiple servers
const multi = new MultiSessionClient('user_123');
await multi.connect();
const multiTools = await AIAdapter.getTools(multi);

Avoiding tool name collisions

When you connect to more than one MCP server, tool names can conflict. Pass a prefix option to namespace every tool from that adapter instance.
import { AIAdapter } from '@mcp-ts/sdk/adapters/ai';

const tools = await AIAdapter.getTools(client, { prefix: 'myapp' });
// Tool names become: tool_myapp_search, tool_myapp_fetch, …
Without an explicit prefix, the adapter uses the server’s ID (truncated and normalized) so names remain unique by default.

Graceful handling of disconnected clients

All adapters return an empty result — an empty object {} or an empty array [] — when the underlying client is not connected. Your application will not throw at the point of tool collection; failures surface only when a tool is actually called.
const adapter = new AIAdapter(client);
const tools = await adapter.getTools();
// {} if the client is disconnected — safe to pass to streamText

Static convenience method

Every adapter exposes a static getTools method so you can retrieve a tool set in a single expression without instantiating the class yourself.
import { LangChainAdapter } from '@mcp-ts/sdk/adapters/langchain';

const tools = await LangChainAdapter.getTools(client, { simplifyErrors: true });