fix: add root src/index.ts so the advertised root export resolves#2523
Open
rajanpanth wants to merge 2 commits into
Open
fix: add root src/index.ts so the advertised root export resolves#2523rajanpanth wants to merge 2 commits into
rajanpanth wants to merge 2 commits into
Conversation
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
🦋 Changeset detectedLatest 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 |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2273
Problem
package.jsonmaps the root.export to./dist/esm/index.js,./dist/cjs/index.js, and./dist/esm/index.d.ts, but there is nosrc/index.ts, sotscnever emits those files and they are absent from the published tarball. Bothawait import("@modelcontextprotocol/sdk")andrequire("@modelcontextprotocol/sdk")fail withERR_MODULE_NOT_FOUND/MODULE_NOT_FOUNDbefore consumer code runs. Subpath exports (/client,/server, …) are unaffected.Targets
v1.x—mainis now a monorepo without a root package, so it does not have this bug.Fix
Adds
src/index.tsre-exporting the shared protocol surface, per the direction in the issue triage comment:export * from "./types.js"— protocol types, schemas, and constantsexport * from "./inMemory.js"—InMemoryTransportClientandServerintentionally stay on their./clientand./serversubpath 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 theexportsmap keeps pointing at the emitted paths, plus a patch changeset.Verification
npm run buildnow emits all three previously missing files.LATEST_PROTOCOL_VERSION,CallToolResultSchema, andInMemoryTransport.src/shared/stdio.tssuites reproduce on cleanv1.xand are unrelated.)npm run typecheck,eslint, andprettier --checkall clean.