Skip to content

Commit c2b85db

Browse files
test(server): assert StdioServerTransport absent from root barrel; clarify subpath comment
Server stdio uses only type-level node:stream imports (erased), so the NODE_ONLY regex cannot detect re-export regressions. Add an explicit symbol-absence check and correct the misleading comment in src/stdio.ts.
1 parent dc84940 commit c2b85db

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

packages/server/src/stdio.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Subpath entry for the stdio server transport.
22
//
3-
// Exported separately from the root entry so that bundling `@modelcontextprotocol/server` for browser or
4-
// Cloudflare Workers targets does not pull in `node:stream`. Import from `@modelcontextprotocol/server/stdio`
5-
// only in process-stdio runtimes (Node.js, Bun, Deno).
3+
// Exported separately from the root entry to keep `StdioServerTransport` out of the default bundle
4+
// surface — server stdio has only type-level Node imports, but matching the client's `./stdio`
5+
// subpath gives consumers a consistent shape across packages. Import from
6+
// `@modelcontextprotocol/server/stdio` only in process-stdio runtimes (Node.js, Bun, Deno).
67

78
export { StdioServerTransport } from './server/stdio.js';

packages/server/test/server/barrelClean.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ describe('@modelcontextprotocol/server root entry is browser-safe', () => {
3232
}
3333
}, 60_000);
3434

35-
test('dist/index.mjs contains no process-stdio runtime imports', () => {
36-
const entry = join(distDir, 'index.mjs');
37-
expect(readFileSync(entry, 'utf8')).not.toMatch(NODE_ONLY);
35+
test('dist/index.mjs does not export StdioServerTransport and has no process-stdio runtime imports', () => {
36+
const entry = readFileSync(join(distDir, 'index.mjs'), 'utf8');
37+
// Server stdio has only type-level node:stream imports (erased at compile time), so the
38+
// meaningful regression check is that the symbol itself is absent from the root barrel.
39+
expect(entry).not.toMatch(/\bexport\s*\{[^}]*\bStdioServerTransport\b/);
40+
expect(entry).not.toMatch(NODE_ONLY);
3841
});
3942

4043
test('chunks transitively imported by dist/index.mjs contain no process-stdio runtime imports', () => {

0 commit comments

Comments
 (0)