Skip to content

fix: add root src/index.ts so the advertised root export resolves#2523

Open
rajanpanth wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
rajanpanth:fix/2273-root-export
Open

fix: add root src/index.ts so the advertised root export resolves#2523
rajanpanth wants to merge 2 commits into
modelcontextprotocol:v1.xfrom
rajanpanth:fix/2273-root-export

Conversation

@rajanpanth

Copy link
Copy Markdown

Fixes #2273

Problem

package.json maps the root . export to ./dist/esm/index.js, ./dist/cjs/index.js, and ./dist/esm/index.d.ts, but there is no src/index.ts, so tsc never emits those files and they are absent from the published tarball. Both await import("@modelcontextprotocol/sdk") and require("@modelcontextprotocol/sdk") fail with ERR_MODULE_NOT_FOUND / MODULE_NOT_FOUND before consumer code runs. Subpath exports (/client, /server, …) are unaffected.

Targets v1.xmain is now a monorepo without a root package, so it does not have this bug.

Fix

Adds src/index.ts re-exporting the shared protocol surface, per the direction in the issue triage comment:

  • export * from "./types.js" — protocol types, schemas, and constants
  • export * from "./inMemory.js"InMemoryTransport

Client and Server intentionally stay on their ./client and ./server subpath exports: re-exporting both from the root would collide on identically named symbols (TS2308).

Includes a regression test (test/index.test.ts) asserting the root entry exposes the protocol surface and that the exports map keeps pointing at the emitted paths, plus a patch changeset.

Verification

  • npm run build now emits all three previously missing files.
  • Root import resolves in both module systems: ESM and CJS each expose 172 symbols, including LATEST_PROTOCOL_VERSION, CallToolResultSchema, and InMemoryTransport.
  • Full unit suite: 1609 tests pass. (The 2 unhandled errors from src/shared/stdio.ts suites reproduce on clean v1.x and are unrelated.)
  • npm run typecheck, eslint, and prettier --check all clean.

package.json maps the root "." export to dist/{esm,cjs}/index.js and
dist/esm/index.d.ts, but with no src/index.ts the build never emitted
those files, so importing '@modelcontextprotocol/sdk' from the published
package failed with ERR_MODULE_NOT_FOUND.

Add a root entry that re-exports the shared protocol types/schemas and
the in-memory transport. Client and Server stay on their ./client and
./server subpath exports to avoid ambiguous re-export collisions.

Fixes modelcontextprotocol#2273
@rajanpanth
rajanpanth requested a review from a team as a code owner July 20, 2026 15:42
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 422397b

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

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 Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@modelcontextprotocol/sdk@2523

commit: 422397b

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.

1 participant