Skip to content

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

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

MustafaKemal0146 wants to merge 2 commits 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

🦋 Changeset detected

Latest commit: 953708d

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 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 953708d

@claude claude Bot added the v1 Issues / PRs related to v1.x label Aug 18, 2026
@MustafaKemal0146
MustafaKemal0146 force-pushed the fix/exclude-packaged-examples-817 branch from ba4a280 to 953708d Compare September 28, 2026 08:13
@MustafaKemal0146

Copy link
Copy Markdown
Author

Rebased on the latest v1.x branch and added the changeset for @modelcontextprotocol/sdk. All CI checks and package artifact tests are passing and ready for review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Issues / PRs related to v1.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant