Skip to content

fix(codemod): update workspace member manifests on v1-to-v2 migration - #3231

Closed
adlanehzx wants to merge 1 commit into
modelcontextprotocol:mainfrom
adlanehzx:fix/codemod-monorepo-member-manifests
Closed

adlanehzx wants to merge 1 commit into
modelcontextprotocol:mainfrom
adlanehzx:fix/codemod-monorepo-member-manifests

Conversation

@adlanehzx

Copy link
Copy Markdown

Fixes #3230

Summary

When running the v1-to-v2 codemod at a monorepo root (npx @modelcontextprotocol/codemod v1-to-v2 .), source files inside workspace members are rewritten to import v2 packages, but their owning package.json was left unmodified and only reported under "Manifests that declare @modelcontextprotocol/sdk but are not modified by the codemod". This left workspace members in a half-migrated state requiring manual edits.

Solution

  • Track which manifests had source files rewritten during the run (rewrittenManifestPaths collected from fileResults where fileResult.changes > 0).
  • Pass rewrittenManifestPaths to updatePackageJson(), applying manifest dependency swaps (applied: true and write to disk unless dryRun or single-file mode) for:
    1. The nearest manifest (single project or monorepo root), and
    2. Any workspace member whose source files were actually rewritten by this run.
  • Workspace members whose files were NOT modified by the codemod remain report-only, preserving the guarantee that members outside the migration scope never receive unintended writes.

Verification

  • Added reproducing unit and integration tests in packages/codemod/test/v1-to-v2/packageJsonUpdater.test.ts:
    • applies manifest changes to workspace members whose source files were rewritten by the run
    • writes a member manifest when included in writableManifestPaths
  • Full codemod test suite passes: 19 test files, 647 tests passed.
  • Full workspace typecheck and build:all succeed cleanly.
  • Added patch changeset for @modelcontextprotocol/codemod.

@adlanehzx
adlanehzx requested a review from a team as a code owner November 23, 2026 23:13
@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4dfeb2a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/server Patch
@modelcontextprotocol/core-internal Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3231

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3231

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3231

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3231

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3231

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3231

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3231

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3231

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3231

commit: 4dfeb2a

@adlanehzx adlanehzx closed this Nov 23, 2026
@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codemod v1-to-v2: run at a monorepo root, it rewrites workspace members' source files but not their package.json

1 participant