modelcontextprotocol / modelcontextprotocol/typescript-sdk

Root package export points to missing dist index files

Open
#2,273 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

The published @modelcontextprotocol/sdk@1.29.0 package declares a root package export, but the files referenced by that root export are not included in the npm tarball.

package.json advertises:

"exports": {
  ".": {
    "types": "./dist/esm/index.d.ts",
    "import": "./dist/esm/index.js",
    "require": "./dist/cjs/index.js"
  }
}

The published package contains many subpath entrypoints such as dist/esm/client/index.js and dist/esm/server/index.js, but it does not contain:

dist/esm/index.js
dist/esm/index.d.ts
dist/cjs/index.js
Reproduction
tmp="$(mktemp -d)"
cd "$tmp"
npm init -y >/dev/null
npm install @modelcontextprotocol/sdk@1.29.0 --ignore-scripts --no-audit --no-fund
node --input-type=module -e "await import('@modelcontextprotocol/sdk')"
node -e "require('@modelcontextprotocol/sdk')"

Package inspection also shows the missing root files:

npm pack @modelcontextprotocol/sdk@1.29.0 --dry-run --json --ignore-scripts
Actual behavior

The ESM root import fails before consumer code runs:

ERR_MODULE_NOT_FOUND: Cannot find module '.../node_modules/@modelcontextprotocol/sdk/dist/esm/index.js'

The CommonJS root require resolves to the same missing root entrypoint contract.

Expected behavior

The package root should either resolve to published files, or the root export should be removed. Since the package currently advertises the root entrypoint, importing @modelcontextprotocol/sdk should not fail with a missing dist/*/index.* file.

Root cause

On the v1.x branch there is no src/index.ts, while tsconfig.prod.json and tsconfig.cjs.json compile src/**/* into dist/esm and dist/cjs. That means the declared root export has no source entrypoint to emit.

Local validation of a minimal fix

I tested a minimal local patch that adds a side-effect-free src/index.ts root entrypoint exporting Client, Server, and core protocol constants/types, plus a small test/root-export.test.ts smoke test.

Validation completed locally:

npm test -- root-export.test.ts
# 1 test passed

On Windows the repository's npm run build script fails at the POSIX mkdir -p ... && echo ... shell syntax, so I ran the equivalent build steps manually:

New-Item -ItemType Directory -Force -Path dist\esm,dist\cjs | Out-Null
Set-Content -Path dist\esm\package.json -Value '{"type": "module"}' -NoNewline -Encoding ascii
Set-Content -Path dist\cjs\package.json -Value '{"type": "commonjs"}' -NoNewline -Encoding ascii
npx tsc -p tsconfig.prod.json
npx tsc -p tsconfig.cjs.json

Then I packed and installed the local tarball into a clean consumer project. The packed package included both dist/esm/index.js and dist/cjs/index.js, and both root loads succeeded:

esm function function 2025-11-25
cjs function function 2025-11-25
Environment
  • Package: @modelcontextprotocol/sdk@1.29.0
  • Branch inspected for source root cause: v1.x
  • Node/npm: local npm install and clean package import test
  • No credentials, private data, paid services, or external MCP servers are required to reproduce this.

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

Start with package.json, src/index.ts, tsconfig.prod.json, and tsconfig.cjs.json, then read test/root-export.test.ts. Run the root-export test and production/CommonJS builds, followed by npm pack and clean ESM/CommonJS imports. Done means the advertised root files are present in the tarball and both root loads succeed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system, developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.