Skip to content

Commit f489a78

Browse files
fix(packaging): inline json-schema-typed in dist .d.mts; move validator provider types to subpath-only
The bundled server/client dist .d.mts files leaked two type references that break downstream consumers with skipLibCheck:false (the TS default): - types-*.d.mts imported 'json-schema-typed', which is not a dependency of server/client (only of core, which is bundled). Fixed by adding 'json-schema-typed' to dts.resolve so the JSONSchema type is inlined. - ajvProvider-*.d.mts referenced URIComponent without a declaration. ajv@8.18.0's .d.ts does `import { URIComponent } from "fast-uri"`, but fast-uri ships its types as `export = namespace`, which the dts bundler cannot destructure — it drops the import and leaves the bare reference. Fixed by removing the type-only re-exports of AjvJsonSchemaValidator / CfWorkerJsonSchemaValidator / CfWorkerSchemaDraft from the public root barrel: those classes/types are still exported from the dedicated /validators/ajv and /validators/cf-worker subpaths (and the runtime _shims conditional), so the inlined ajv type chunk is no longer reachable from index.d.mts. The codemod already routes v1 imports to the subpaths. Also: - @modelcontextprotocol/node package.json: remove typesVersions.sse entry pointing at nonexistent dist/sse.d.mts. - server/client READMEs: note that TS >=6.0 needs "types": ["node"] in tsconfig (TS 6 dropped implicit @types inclusion; the published .d.mts references Buffer). Verified: pnpm build:all + typecheck:all + docs:check green; fresh npm install of packed tarballs + `npx tsc --noEmit` (NodeNext + bundler, strict, skipLibCheck:false) is clean.
1 parent 92b185d commit f489a78

7 files changed

Lines changed: 16 additions & 13 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@modelcontextprotocol/server': patch
3+
'@modelcontextprotocol/client': patch
4+
---
5+
6+
`AjvJsonSchemaValidator`, `CfWorkerJsonSchemaValidator` and `CfWorkerSchemaDraft` types are now only exported from the `/validators/ajv` and `/validators/cf-worker` subpaths, not the package root. The codemod already routes v1 imports there.

packages/client/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ The MCP (Model Context Protocol) TypeScript client SDK. Build MCP clients that c
1616
npm install @modelcontextprotocol/client@alpha
1717
```
1818

19+
TypeScript ≥6.0 no longer auto-includes `@types/*` — add `"types": ["node"]` to your `tsconfig.json` `compilerOptions` (the published `.d.mts` references `Buffer`).
20+
1921
## Documentation
2022

2123
- **[Repository README](https://github.com/modelcontextprotocol/typescript-sdk#readme)** — overview, package layout, examples

packages/client/tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default defineConfig({
2020
shims: true,
2121
dts: {
2222
resolver: 'tsc',
23-
resolve: ['ajv', 'ajv-formats'],
23+
resolve: ['ajv', 'ajv-formats', 'json-schema-typed'],
2424
compilerOptions: {
2525
baseUrl: '.',
2626
paths: {

packages/core/src/exports/public/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ export {
129129
export type { SpecTypeName, SpecTypes } from '../../types/specTypeSchema.js';
130130
export { isSpecType, specTypeSchemas } from '../../types/specTypeSchema.js';
131131
export type { StandardSchemaV1, StandardSchemaV1Sync, StandardSchemaWithJSON } from '../../util/standardSchema.js';
132-
// Validator providers are type-only here — import the runtime classes from the explicit
133-
// `@modelcontextprotocol/{client,server}/validators/{ajv,cf-worker}` subpaths to customise.
134-
export type { AjvJsonSchemaValidator } from '../../validators/ajvProvider.js';
135-
export type { CfWorkerJsonSchemaValidator, CfWorkerSchemaDraft } from '../../validators/cfWorkerProvider.js';
132+
// Validator provider classes (`AjvJsonSchemaValidator`, `CfWorkerJsonSchemaValidator`) are
133+
// intentionally NOT re-exported here — import them from the explicit
134+
// `@modelcontextprotocol/{client,server}/validators/{ajv,cf-worker}` subpaths so the
135+
// root entrypoint's bundled `.d.mts` doesn't pull the inlined ajv/cfworker type chunks.
136136
// fromJsonSchema is intentionally NOT exported here — the server and client packages
137137
// provide runtime-aware wrappers that default to the appropriate validator via _shims.
138138
export type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator, JsonSchemaValidatorResult } from '../../validators/types.js';

packages/middleware/node/package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
}
2828
},
2929
"types": "./dist/index.d.mts",
30-
"typesVersions": {
31-
"*": {
32-
"sse": [
33-
"dist/sse.d.mts"
34-
]
35-
}
36-
},
3730
"files": [
3831
"dist"
3932
],

packages/server/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ The MCP (Model Context Protocol) TypeScript server SDK. Build MCP servers that e
1616
npm install @modelcontextprotocol/server@alpha
1717
```
1818

19+
TypeScript ≥6.0 no longer auto-includes `@types/*` — add `"types": ["node"]` to your `tsconfig.json` `compilerOptions` (the published `.d.mts` references `Buffer`).
20+
1921
Optional framework adapters: [`@modelcontextprotocol/express`](https://www.npmjs.com/package/@modelcontextprotocol/express), [`@modelcontextprotocol/hono`](https://www.npmjs.com/package/@modelcontextprotocol/hono),
2022
[`@modelcontextprotocol/node`](https://www.npmjs.com/package/@modelcontextprotocol/node).
2123

packages/server/tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default defineConfig({
1919
shims: true,
2020
dts: {
2121
resolver: 'tsc',
22-
resolve: ['ajv', 'ajv-formats'],
22+
resolve: ['ajv', 'ajv-formats', 'json-schema-typed'],
2323
compilerOptions: {
2424
baseUrl: '.',
2525
paths: {

0 commit comments

Comments
 (0)