The MCP TypeScript SDK is migrating from a single v1 package (@modelcontextprotocol/sdk) to a multi-package v2 architecture (@modelcontextprotocol/client, /server, /core, /node, /express). This involves renamed APIs, restructured context objects, removed modules, and
new import paths.
The @modelcontextprotocol/codemod package automates the mechanical parts of this migration. It runs 9 ordered AST transforms via ts-morph: import path rewrites, symbol renames, McpServer API restructuring, handler registration changes, context property remapping, and more. It
also updates package.json to swap v1 deps for v2.
The batch test runs this codemod against a curated list of real-world repos that use the v1 SDK. For each repo it:
- Clones and installs
- Runs baseline checks (typecheck, build, test, lint) to confirm the repo is healthy before migration
- Runs the codemod
- Re-installs (package.json was updated with v2 deps)
- Re-runs the same checks
The goal is to find issues in the codemod itself — incorrect transforms, missing transforms, or gaps — so we can fix them.
-
Build the codemod:
pnpm --filter @modelcontextprotocol/codemod build -
Run the batch test:
pnpm --filter @modelcontextprotocol/codemod batch-test -
Read
packages/codemod/batch-test/results/summary.jsonfor the overview. Note which repos havepostCodemodClean: falseand which check types have new errors. -
For each repo with new errors, read its
packages/codemod/batch-test/results/<repo-slug>/report.json. ComparebaselinevspostCodemodfor each check — only errors that appear inpostCodemodbut not inbaselineare codemod-introduced. -
Also review the
codemod.diagnosticsarray in each report — these are warnings the codemod itself emitted about patterns it couldn't fully handle. -
For each codemod-introduced error, look at the actual source file in the cloned repo (
packages/codemod/batch-test/repos/<repo-slug>/...) to understand what the codemod produced and what it should have produced. -
Categorize each finding using the categories below, then produce the output described in the Output Format section.
| Category | Meaning | What to do |
|---|---|---|
codemod-bug |
A transform produced incorrect output — the code it generated is wrong | Identify which transform is responsible and what the correct output should be. This is a bug to fix in the codemod. |
missing-transform |
The codemod left v1 code untouched that it should have migrated | Identify the v1 pattern and which existing transform should handle it, or whether a new transform is needed. |
manual-migration |
The error is expected — the migration guide documents this as requiring human judgment (e.g., removed APIs, architectural changes) | Verify the codemod emitted a diagnostic for it. If not, add one. |
repo-specific |
An unusual pattern unique to this repo that isn't worth handling in the codemod | Note it briefly but don't suggest codemod changes. |
- Repos tested: X
- Repos clean after codemod: Y
- Repos with new errors: Z
- Total codemod-introduced errors: N
| Repo | File:Line | Error | Transform | Root Cause | Correct Output |
|---|
| Repo | File:Line | Error | v1 Pattern | Suggested Fix |
|---|
| Repo | File:Line | Error | Has Diagnostic? | Migration Guide Reference |
|---|
| Repo | File:Line | Error | Why Not Worth Handling |
|---|
List the top 3-5 codemod improvements that would fix the most repos, ordered by impact (number of repos affected). For each, state: what to change, in which transform, and how many repos it would fix.