Skip to content

fix: unblock @modelcontextprotocol/sdk upgrades past 1.26.0 (nodenext)#44

Merged
evilmachina merged 1 commit into
mainfrom
fix/unblock-mcp-sdk-upgrade
Jun 24, 2026
Merged

fix: unblock @modelcontextprotocol/sdk upgrades past 1.26.0 (nodenext)#44
evilmachina merged 1 commit into
mainfrom
fix/unblock-mcp-sdk-upgrade

Conversation

@evilmachina

@evilmachina evilmachina commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #42. The build was stuck on @modelcontextprotocol/sdk@1.26.0 because newer versions tripped tsc with TS1479 under the Node16 module resolution. This bumps the SDK to 1.29.0 and migrates module resolution to nodenext.

Root cause

The SDK's ./server export entry advertises an unconditional "types": "./dist/esm/server/index.d.ts" (ESM declaration). Under moduleResolution: "Node16", tsc read that ESM .d.ts, classified the bare subpath as ESM, and refused to emit a require() for it from this CommonJS package:

src/mcp_server.ts(30,31): error TS1479: The current file is a CommonJS module whose imports
will produce 'require' calls; however, the referenced file is an ECMAScript module ...

Fix: migrate to nodenext

tsconfig module/moduleResolutionnodenext. The newer algorithm correctly applies the package's CommonJS require condition for the bare subpath, so the import resolves without error.

  • The package stays CommonJSnodenext keys module format off package.json "type" (absent → CommonJS). Emit is still require(...); no entrypoint, __dirname, or readFileSync plumbing changes were needed.
  • nodenext floats to current Node resolution semantics, so this also future-proofs against later SDK subpath changes (unlike Node16, pinned to Node 16-era behavior).
  • ServerOptions is tightened to import type (used only as a type annotation), so it erases at compile time.

Why nodenext over the one-line import type workaround

A surgical alternative existed (keep Node16, import ServerOptions from the explicit /server/index.js wildcard subpath). We chose nodenext deliberately: it's the forward-looking resolution mode, fixes the bare public import without relying on the ./* exports wildcard, and unblocks future SDK subpath changes generally rather than patching one import site. A full ESM migration (type: module) was not needed — nodenext solves it while the package stays CommonJS.

Verification

  • npm run build passes on SDK 1.29.0 under nodenext
  • npm test passes (236/236)
  • Emitted JS still uses require() (package remains CommonJS); the type import is erased
  • Server starts over stdio, responds to initialize, lists all 12 tools

Acceptance criteria

  • SDK upgradable to >= 1.29.0
  • npm run build passes
  • npm test passes (236 tests)
  • MCP server starts over stdio and tools respond
  • Decision documented (changeset + this PR): migrate to nodenext, package stays CommonJS

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: aae70da4-2d6c-486c-96f1-1ed6c8d2f6e2

📥 Commits

Reviewing files that changed from the base of the PR and between 21010f7 and 394bb0e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json, !package-lock.json
📒 Files selected for processing (4)
  • .changeset/unblock-mcp-sdk-upgrade.md
  • package.json
  • src/mcp_server.ts
  • tsconfig.json
✅ Files skipped from review due to trivial changes (2)
  • .changeset/unblock-mcp-sdk-upgrade.md
  • src/mcp_server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

📝 Walkthrough

Walkthrough

@modelcontextprotocol/sdk is bumped from ^1.26.0 to ^1.29.0 in package.json. tsconfig.json switches module and moduleResolution to nodenext. src/mcp_server.ts changes ServerOptions to a type-only import from @modelcontextprotocol/sdk/server/index.js. A new changeset file records the patch release and the TypeScript/module-resolution change.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: unblocking SDK upgrades via nodenext.
Description check ✅ Passed The description is directly about the SDK upgrade, TS1479 fix, and module-resolution change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands.

Migrate tsconfig module/moduleResolution from Node16 to nodenext. Newer
SDK versions expose the bare @modelcontextprotocol/sdk/server subpath with
an unconditional ESM `types` entry; Node16 resolution misread it as ESM and
rejected the import with TS1479. nodenext correctly applies the package's
CommonJS `require` condition, so the import resolves cleanly. The package
stays CommonJS (no `type: module`) — nodenext keys format off package.json
`type`, so emit is still require() and no entrypoint/__dirname changes are
needed. nodenext also future-proofs against later SDK subpath changes.

ServerOptions is tightened to `import type` (used only as a type annotation).

Closes #42

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@evilmachina
evilmachina force-pushed the fix/unblock-mcp-sdk-upgrade branch from 21010f7 to 394bb0e Compare June 24, 2026 16:48
@evilmachina evilmachina changed the title fix: unblock @modelcontextprotocol/sdk upgrades past 1.26.0 fix: unblock @modelcontextprotocol/sdk upgrades past 1.26.0 (nodenext) Jun 24, 2026
@evilmachina
evilmachina merged commit 9941b2a into main Jun 24, 2026
7 checks passed
@evilmachina
evilmachina deleted the fix/unblock-mcp-sdk-upgrade branch June 24, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unblock @modelcontextprotocol/sdk upgrades past 1.26.0 (ESM / CommonJS conflict)

1 participant