Skip to content

fix(packaging): exclude examples from v1 package artifacts#2506

Draft
MustafaKemal0146 wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
MustafaKemal0146:fix/exclude-packaged-examples-817
Draft

fix(packaging): exclude examples from v1 package artifacts#2506
MustafaKemal0146 wants to merge 1 commit into
modelcontextprotocol:v1.xfrom
MustafaKemal0146:fix/exclude-packaged-examples-817

Conversation

@MustafaKemal0146

Copy link
Copy Markdown

Summary

Exclude src/examples/** from both v1 production TypeScript builds and add package-level regression coverage.

The regression test compiles the ESM and CJS production artifacts into a clean temporary package, inspects the result of npm pack --dry-run, and verifies that:

  • no compiled dist/esm/examples/** or dist/cjs/examples/** entry points are published;
  • every supported explicit package export target remains present;
  • representative wildcard subpaths for client, server, and shared APIs remain available in both module formats.

Root cause

Both tsconfig.prod.json and tsconfig.cjs.json included all of src/**/*, so repository examples were compiled into the production dist directories. Because the package publishes dist and exposes a "./*" wildcard export, those compiled example paths became importable package subpaths.

Some server examples register process signal handlers at module scope. Importing one of those accidentally published example entry points could therefore attach a SIGINT handler as an import side effect.

Fix

Add src/examples/**/* to the exclusion lists in both production TypeScript configurations.

Excluding the examples at the production-build boundary is safer than changing individual examples: examples remain runnable from source, while no current or future example implementation can accidentally become part of the supported package surface.

Compatibility verification

The packed artifact retains all explicit export targets declared by the v1 package manifest. The regression test also checks these wildcard-backed targets in both ESM and CJS output:

  • client/stdio
  • server/stdio
  • shared/protocol

Validation

  • npm ci — passed.
  • npx vitest run test/package-artifacts.test.ts — 1 file passed, 8 tests passed.
  • npx vitest run --exclude "test/e2e/**" --exclude "test/client/stdio.test.ts" — 51 files passed, 1609 tests passed.
  • npm run typecheck — passed.
  • npx eslint src/ test/package-artifacts.test.ts — passed.
  • npx prettier --check test/package-artifacts.test.ts tsconfig.prod.json tsconfig.cjs.json — passed.
  • npm run build with Git Bash configured as npm_config_script_shell on Windows — passed for ESM and CJS.
  • npm pack --dry-run --json --ignore-scripts against the production build — 477 packed files, 0 compiled example paths, 14 verified export targets, 0 missing targets.
  • Full npm test — 52 test files and 1614 assertions passed, but the command exited non-zero because test/client/stdio.test.ts produced two existing Windows-only Unexpected end of JSON input unhandled errors.
  • Full npm run lint — ESLint passed; the repository-wide Prettier check reported 219 unchanged files due to CRLF checkout normalization on Windows. Focused formatting checks for all changed files passed.

Related work

PR #1939 contains the same production configuration exclusion but does not include package-level regression coverage. This draft keeps the configuration change minimal while proving that published examples are removed and supported SDK subpaths remain intact.

Fixes #817

@changeset-bot

changeset-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ba4a280

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: ba4a280

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