Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fix-root-export-missing-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modelcontextprotocol/sdk': patch
---

Fix the root package export: add `src/index.ts` so the advertised `dist/{esm,cjs}/index.js` and `dist/esm/index.d.ts` are actually emitted and published. The root entry re-exports the shared protocol types/schemas and the in-memory transport; `Client` and `Server` remain on their
`./client` and `./server` subpaths.
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Root entry for `@modelcontextprotocol/sdk`.
//
// package.json exposes this file via the `.` export. Without a source file
// here, tsc emits nothing for the advertised dist/{esm,cjs}/index.{js,d.ts}
// paths and the root import of the published package fails to resolve
// (issue #2273).
//
// Re-export the shared protocol schemas/types and the in-memory transport.
// `Client` and `Server` intentionally stay on their `./client` and `./server`
// subpath exports: re-exporting both here would collide on identically named
// symbols (TS2308).
export * from './types.js';
export * from './inMemory.js';
28 changes: 28 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { describe, it, expect } from 'vitest';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import * as rootExport from '../src/index.js';

// Regression tests for #2273: package.json advertises a root `.` export, so a
// root source entry must exist and re-export the shared protocol surface.
describe('root package export', () => {
it('exposes the shared protocol types and schemas', () => {
expect(rootExport.LATEST_PROTOCOL_VERSION).toBeDefined();
expect(rootExport.CallToolResultSchema).toBeDefined();
expect(rootExport.JSONRPCMessageSchema).toBeDefined();
});

it('exposes the in-memory transport', () => {
expect(rootExport.InMemoryTransport).toBeTypeOf('function');
});

it('matches the paths advertised in the package.json exports map', () => {
const pkg = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
const root = pkg.exports['.'];
// The `.` export must keep pointing at the root index build outputs
// that src/index.ts produces.
expect(root.import).toBe('./dist/esm/index.js');
expect(root.require).toBe('./dist/cjs/index.js');
expect(root.types).toBe('./dist/esm/index.d.ts');
});
});
Loading