Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

mcp-sdk.md

48 lines1.6 KB

1---
2title: MCP SDK packages
3id: mcp-sdk
4order: 7
5description: "Move a createMCPClient app from @modelcontextprotocol/sdk to @modelcontextprotocol/client or @modelcontextprotocol/server."
6keywords:
7 - tanstack ai
8 - mcp
9 - migration
10 - createMCPClient
11 - model context protocol
12---
13​
14Your app calls `createMCPClient`. The app still imports `@modelcontextprotocol/sdk`. That import does not resolve. `@tanstack/ai-mcp` does not use that package.
15​
16- A client app imports `@modelcontextprotocol/client`.
17- A server app imports `@modelcontextprotocol/server`.
18​
19```diff
20- import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
21- import type { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js'
22+ import {
23+ StreamableHTTPClientTransport,
24+ type OAuthClientProvider,
25+ } from '@modelcontextprotocol/client'
26​
27- import { Server } from '@modelcontextprotocol/sdk/server/index.js'
28+ import { Server } from '@modelcontextprotocol/server'
29```
30​
31## Codemod
32​
331. If the app imports `@modelcontextprotocol/sdk`, run `npx @modelcontextprotocol/codemod@latest v1-to-v2 .` from the app root.
342. If the app does not import `@modelcontextprotocol/sdk`, remove that dependency.
35​
36```bash
37npx @modelcontextprotocol/codemod@latest v1-to-v2 .
38```
39​
40The codemod rewrites imports from `@modelcontextprotocol/sdk`. The codemod rewrites the `package.json` dependencies.
41​
42This repo does not ship its own codemod.
43​
44## Protocol
45​
46`createMCPClient` tries protocol `2026-07-28` first. If the server does not support that protocol, the client uses the 2025 initialize handshake.
47​
48Call `createMCPClient` with the same transport config. The client connects.