modelcontextprotocol / modelcontextprotocol/typescript-sdk

Published package omits `src/` but `dist/**/*.js.map` references it, breaking source-map consumers

Open
#2,233 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2 ready for work
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

Describe the bug

The published @modelcontextprotocol/sdk npm tarball ships dist/**/*.js.map source maps whose sources field references ../../../../src/**/*.ts, but the src/ directory is not included in the published package. Any bundler that resolves source maps (e.g. webpack's source-map-loader) fails to read the referenced TypeScript files and emits a warning for every SDK file it touches.

Verified on @modelcontextprotocol/sdk@1.29.0.

To Reproduce

Steps to reproduce the behavior:

  1. Install @modelcontextprotocol/sdk@1.29.0 in a project bundled with webpack and source-map-loader enabled (the default for @nx/webpack Node apps with sourceMap: true).
  2. Import something from @modelcontextprotocol/sdk — e.g. anything that pulls in dist/cjs/experimental/tasks/helpers.js.
  3. Run the build.

Inspecting the shipped map confirms the dangling reference:

// dist/cjs/experimental/tasks/helpers.js.map
{"version":3,"file":"helpers.js","sources":["../../../../src/experimental/tasks/helpers.ts"], ...}

The tarball contents:

package.json   // no "files" field
LICENSE
README.md
dist/          // shipped
src/           // NOT shipped

Every dist/**/*.js.map in the package has the same broken sources path, so any imported file can trigger this — the experimental tasks helpers happened to surface it for us.

Expected behavior

The shipped source maps resolve cleanly. Either the referenced src/ files are included in the tarball, or the sources are inlined into the maps (sourcesContent / --inlineSources), or the maps are not shipped at all.

Logs

WARNING in .../@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/helpers.js
Module Warning (from .../source-map-loader/dist/cjs.js):
Failed to parse source map from '.../@modelcontextprotocol/sdk/src/experimental/tasks/helpers.ts'
file: Error: ENOENT: no such file or directory, open
'.../@modelcontextprotocol/sdk/src/experimental/tasks/helpers.ts'

WARNING in .../@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/interfaces.js
Module Warning (from .../source-map-loader/dist/cjs.js):
Failed to parse source map from '.../@modelcontextprotocol/sdk/src/experimental/tasks/interfaces.ts'
file: Error: ENOENT: no such file or directory, open
'.../@modelcontextprotocol/sdk/src/experimental/tasks/interfaces.ts'

WARNING in .../@modelcontextprotocol/sdk/dist/cjs/experimental/tasks/mcp-server.js
Module Warning (from .../source-map-loader/dist/cjs.js):
Failed to parse source map from '.../@modelcontextprotocol/sdk/src/experimental/tasks/mcp-server.ts'
file: Error: ENOENT: no such file or directory, open
'.../@modelcontextprotocol/sdk/src/experimental/tasks/mcp-server.ts'

Additional context

Possible fixes (any one resolves it):

  1. Add "src" to the files array in package.json so the referenced TypeScript sources ship alongside the maps.
  2. Build with --inlineSources (or post-process the maps to populate sourcesContent) so consumers don't need src/ on disk — typically the cleanest option for a published library.
  3. Strip the //# sourceMappingURL= comments and omit .js.map files if maps aren't intended for downstream consumption.

Happy to open a PR for whichever direction maintainers prefer.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect package.json and a representative dist/**/*.js.map, especially dist/cjs/experimental/tasks/helpers.js.map, to understand how the published tarball and source-map paths are produced. Reproduce the warning with webpack and source-map-loader, then verify that the chosen packaging or source-map change lets the shipped maps resolve without warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.