diff --git a/.changeset/validators-subpath-only.md b/.changeset/validators-subpath-only.md new file mode 100644 index 000000000..d175a9e87 --- /dev/null +++ b/.changeset/validators-subpath-only.md @@ -0,0 +1,6 @@ +--- +'@modelcontextprotocol/server': patch +'@modelcontextprotocol/client': patch +--- + +`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. diff --git a/packages/client/README.md b/packages/client/README.md index e9ce66f51..3248ec985 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -16,6 +16,8 @@ The MCP (Model Context Protocol) TypeScript client SDK. Build MCP clients that c npm install @modelcontextprotocol/client@alpha ``` +TypeScript ≥6.0 no longer auto-includes `@types/*` — add `"types": ["node"]` to your `tsconfig.json` `compilerOptions` (the published `.d.mts` references `Buffer`). + ## Documentation - **[Repository README](https://github.com/modelcontextprotocol/typescript-sdk#readme)** — overview, package layout, examples diff --git a/packages/client/tsdown.config.ts b/packages/client/tsdown.config.ts index 773e07c92..70d5d7af4 100644 --- a/packages/client/tsdown.config.ts +++ b/packages/client/tsdown.config.ts @@ -20,10 +20,11 @@ export default defineConfig({ shims: true, dts: { resolver: 'tsc', - resolve: ['ajv', 'ajv-formats'], + resolve: ['ajv', 'ajv-formats', 'json-schema-typed'], compilerOptions: { baseUrl: '.', paths: { + 'fast-uri': ['../core/src/validators/fastUriShim.d.ts'], '@modelcontextprotocol/core': ['../core/src/index.ts'], '@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts'], '@modelcontextprotocol/core/validators/ajv': ['../core/src/validators/ajvProvider.ts'], diff --git a/packages/core/src/exports/public/index.ts b/packages/core/src/exports/public/index.ts index c7cc53e0c..b6feba9f1 100644 --- a/packages/core/src/exports/public/index.ts +++ b/packages/core/src/exports/public/index.ts @@ -129,10 +129,10 @@ export { export type { SpecTypeName, SpecTypes } from '../../types/specTypeSchema.js'; export { isSpecType, specTypeSchemas } from '../../types/specTypeSchema.js'; export type { StandardSchemaV1, StandardSchemaV1Sync, StandardSchemaWithJSON } from '../../util/standardSchema.js'; -// Validator providers are type-only here — import the runtime classes from the explicit -// `@modelcontextprotocol/{client,server}/validators/{ajv,cf-worker}` subpaths to customise. -export type { AjvJsonSchemaValidator } from '../../validators/ajvProvider.js'; -export type { CfWorkerJsonSchemaValidator, CfWorkerSchemaDraft } from '../../validators/cfWorkerProvider.js'; +// Validator provider classes (`AjvJsonSchemaValidator`, `CfWorkerJsonSchemaValidator`) are +// intentionally NOT re-exported here — import them from the explicit +// `@modelcontextprotocol/{client,server}/validators/{ajv,cf-worker}` subpaths so the +// root entrypoint's bundled `.d.mts` doesn't pull the inlined ajv/cfworker type chunks. // fromJsonSchema is intentionally NOT exported here — the server and client packages // provide runtime-aware wrappers that default to the appropriate validator via _shims. export type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator, JsonSchemaValidatorResult } from '../../validators/types.js'; diff --git a/packages/core/src/validators/fastUriShim.d.ts b/packages/core/src/validators/fastUriShim.d.ts new file mode 100644 index 000000000..e2f5e2150 --- /dev/null +++ b/packages/core/src/validators/fastUriShim.d.ts @@ -0,0 +1,24 @@ +/** + * dts-bundling shim for `fast-uri`. + * + * ajv@8.18.0's published .d.ts does `import { URIComponent } from "fast-uri"`, + * but fast-uri ships its types as `export = namespace`, which rolldown's dts + * bundler can't destructure into a named import — it drops the import and + * leaves a dangling `URIComponent` reference in the bundled .d.mts (TS2304 for + * downstream consumers with `skipLibCheck: false`). + * + * The server/client tsdown configs map `fast-uri` to this file via + * `dts.compilerOptions.paths` so the type is inlined as a plain named export. + * Runtime code is unaffected (this is a `.d.ts`; the path mapping is dts-only). + */ +export interface URIComponent { + scheme?: string; + userinfo?: string; + host?: string; + port?: number | string; + path?: string; + query?: string; + fragment?: string; + reference?: string; + error?: string; +} diff --git a/packages/middleware/node/package.json b/packages/middleware/node/package.json index 30fa7ed66..9b12fa1fc 100644 --- a/packages/middleware/node/package.json +++ b/packages/middleware/node/package.json @@ -27,13 +27,6 @@ } }, "types": "./dist/index.d.mts", - "typesVersions": { - "*": { - "sse": [ - "dist/sse.d.mts" - ] - } - }, "files": [ "dist" ], diff --git a/packages/server/README.md b/packages/server/README.md index 0dfe93820..7f46a411d 100644 --- a/packages/server/README.md +++ b/packages/server/README.md @@ -16,6 +16,8 @@ The MCP (Model Context Protocol) TypeScript server SDK. Build MCP servers that e npm install @modelcontextprotocol/server@alpha ``` +TypeScript ≥6.0 no longer auto-includes `@types/*` — add `"types": ["node"]` to your `tsconfig.json` `compilerOptions` (the published `.d.mts` references `Buffer`). + Optional framework adapters: [`@modelcontextprotocol/express`](https://www.npmjs.com/package/@modelcontextprotocol/express), [`@modelcontextprotocol/hono`](https://www.npmjs.com/package/@modelcontextprotocol/hono), [`@modelcontextprotocol/node`](https://www.npmjs.com/package/@modelcontextprotocol/node). diff --git a/packages/server/tsdown.config.ts b/packages/server/tsdown.config.ts index 891ce4964..ae48c7945 100644 --- a/packages/server/tsdown.config.ts +++ b/packages/server/tsdown.config.ts @@ -19,10 +19,11 @@ export default defineConfig({ shims: true, dts: { resolver: 'tsc', - resolve: ['ajv', 'ajv-formats'], + resolve: ['ajv', 'ajv-formats', 'json-schema-typed'], compilerOptions: { baseUrl: '.', paths: { + 'fast-uri': ['../core/src/validators/fastUriShim.d.ts'], '@modelcontextprotocol/core': ['../core/src/index.ts'], '@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts'], '@modelcontextprotocol/core/validators/ajv': ['../core/src/validators/ajvProvider.ts'],