Skip to content

Commit 58db423

Browse files
committed
fix(packaging): drop root validator provider declarations
1 parent ddba550 commit 58db423

5 files changed

Lines changed: 24 additions & 6 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+
Remove subpath-only JSON Schema validator provider classes from the root declaration barrels. `AjvJsonSchemaValidator`, `CfWorkerJsonSchemaValidator`, and `CfWorkerSchemaDraft` remain available from the explicit `validators/ajv` and `validators/cf-worker` subpaths, matching the runtime export surface and avoiding CJS declarations that compile and then resolve to `undefined` at runtime.

packages/client/test/client/barrelClean.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const distDir = join(pkgDir, 'dist');
1010
const NODE_ONLY = /\b(child_process|cross-spawn|node:stream|node:child_process)\b/;
1111
// Anchored at start-of-line so JSDoc-example `from 'ajv'` strings in vendored chunks don't match.
1212
const VALIDATOR_BACKEND_IMPORT = /^import[^\n]*?from\s+["'](?:ajv|ajv-formats|@cfworker\/json-schema)["']/m;
13+
const ROOT_VALIDATOR_PROVIDER_EXPORTS = /\b(?:AjvJsonSchemaValidator|CfWorkerJsonSchemaValidator|CfWorkerSchemaDraft)\b/;
1314

1415
function chunkImportsOf(entryPath: string): string[] {
1516
const visited = new Set<string>();
@@ -67,4 +68,10 @@ describe('@modelcontextprotocol/client root entry is browser-safe', () => {
6768
}
6869
}
6970
});
71+
72+
test('root declarations do not advertise subpath-only validator providers', () => {
73+
for (const declaration of ['index.d.mts', 'index.d.cts']) {
74+
expect(readFileSync(join(distDir, declaration), 'utf8')).not.toMatch(ROOT_VALIDATOR_PROVIDER_EXPORTS);
75+
}
76+
});
7077
});

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ export {
131131
export type { SpecTypeName, SpecTypes } from '../../types/specTypeSchema';
132132
export { isSpecType, specTypeSchemas } from '../../types/specTypeSchema';
133133
export type { StandardSchemaV1, StandardSchemaV1Sync, StandardSchemaWithJSON } from '../../util/standardSchema';
134-
// Validator providers are type-only here — import the runtime classes from the explicit
135-
// `@modelcontextprotocol/{client,server}/validators/{ajv,cf-worker}` subpaths to customise.
136-
export type { AjvJsonSchemaValidator } from '../../validators/ajvProvider';
137-
export type { CfWorkerJsonSchemaValidator, CfWorkerSchemaDraft } from '../../validators/cfWorkerProvider';
134+
// Validator provider classes are subpath-only so root entries stay runtime-neutral.
135+
// Import them from `@modelcontextprotocol/{client,server}/validators/{ajv,cf-worker}`.
138136
// fromJsonSchema is intentionally NOT exported here — the server and client packages
139137
// provide runtime-aware wrappers that default to the appropriate validator via _shims.
140138
export type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator, JsonSchemaValidatorResult } from '../../validators/types';

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const distDir = join(pkgDir, 'dist');
1010
const NODE_ONLY = /\b(child_process|cross-spawn|node:stream|node:child_process)\b/;
1111
// Anchored at start-of-line so JSDoc-example `from 'ajv'` strings in vendored chunks don't match.
1212
const VALIDATOR_BACKEND_IMPORT = /^import[^\n]*?from\s+["'](?:ajv|ajv-formats|@cfworker\/json-schema)["']/m;
13+
const ROOT_VALIDATOR_PROVIDER_EXPORTS = /\b(?:AjvJsonSchemaValidator|CfWorkerJsonSchemaValidator|CfWorkerSchemaDraft)\b/;
1314

1415
function chunkImportsOf(entryPath: string): string[] {
1516
const visited = new Set<string>();
@@ -68,4 +69,10 @@ describe('@modelcontextprotocol/server root entry is browser-safe', () => {
6869
}
6970
}
7071
});
72+
73+
test('root declarations do not advertise subpath-only validator providers', () => {
74+
for (const declaration of ['index.d.mts', 'index.d.cts']) {
75+
expect(readFileSync(join(distDir, declaration), 'utf8')).not.toMatch(ROOT_VALIDATOR_PROVIDER_EXPORTS);
76+
}
77+
});
7178
});

scripts/smoke-dist-types.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ try {
1414
path.join(dir, 'consumer.ts'),
1515
[
1616
"import { Client } from '@modelcontextprotocol/client';",
17-
"import type { AjvJsonSchemaValidator as ClientAjv } from '@modelcontextprotocol/client';",
17+
"import type { JsonSchemaValidator as ClientJsonSchemaValidator } from '@modelcontextprotocol/client';",
1818
"import { AjvJsonSchemaValidator } from '@modelcontextprotocol/client/validators/ajv';",
1919
"import { CfWorkerJsonSchemaValidator as ClientCf } from '@modelcontextprotocol/client/validators/cf-worker';",
2020
"import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';",
@@ -24,7 +24,7 @@ try {
2424
"import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';",
2525
"export const c = new Client({ name: 'smoke', version: '1.0.0' });",
2626
"export const s = new McpServer({ name: 'smoke', version: '1.0.0' });",
27-
'export type T = ClientAjv;',
27+
'export type T = ClientJsonSchemaValidator<unknown>;',
2828
'export { AjvJsonSchemaValidator, ServerAjv, ClientCf, ServerCf, StdioClientTransport, StdioServerTransport };',
2929
''
3030
].join('\n')

0 commit comments

Comments
 (0)