Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .changeset/compat-zod-schemas-subpath.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@modelcontextprotocol/server': patch
---

Add `@modelcontextprotocol/server/zod-schemas` subpath for v1 compatibility

Re-exports the `*Schema` Zod constants (e.g. `CallToolRequestSchema`, `JSONRPCMessageSchema`) so v1 code that imported them from `@modelcontextprotocol/sdk/types.js` can be pointed at a single subpath. These are Zod schemas; their TS type may change with internal Zod upgrades.
4 changes: 4 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"./public": {
"types": "./src/exports/public/index.ts",
"import": "./src/exports/public/index.ts"
},
"./schemas": {
"types": "./src/types/schemas.ts",
"import": "./src/types/schemas.ts"
}
},
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs"
},
"./zod-schemas": {
"types": "./dist/zodSchemas.d.mts",
"import": "./dist/zodSchemas.mjs"
},
"./validators/cf-worker": {
"types": "./dist/validators/cfWorker.d.mts",
"import": "./dist/validators/cfWorker.mjs"
Expand Down
25 changes: 25 additions & 0 deletions packages/server/src/zodSchemas.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* These are Zod schemas; their TS type may change with internal Zod upgrades.
* For runtime validation use them as `Schema.parse(value)`.
*/
export {
IdJagTokenExchangeResponseSchema,
OAuthClientInformationFullSchema,
OAuthClientInformationSchema,
OAuthClientMetadataSchema,
OAuthClientRegistrationErrorSchema,
OAuthErrorResponseSchema,
OAuthMetadataSchema,
OAuthProtectedResourceMetadataSchema,
OAuthTokenRevocationRequestSchema,
OAuthTokensSchema,
OpenIdProviderDiscoveryMetadataSchema,
OpenIdProviderMetadataSchema,
OptionalSafeUrlSchema,
SafeUrlSchema
} from '@modelcontextprotocol/core';
export * from '@modelcontextprotocol/core/schemas';
export {
/** @deprecated Use {@linkcode JSONRPCErrorResponseSchema}. */
JSONRPCErrorResponseSchema as JSONRPCErrorSchema
} from '@modelcontextprotocol/core/schemas';
23 changes: 23 additions & 0 deletions packages/server/test/zod-schemas.compat.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as z from 'zod/v4';

// Compat: the deprecated `/zod-schemas` subpath re-exports the internal Zod
// schema constants for v1 source compatibility. This test asserts the import
// resolves and the values are usable Zod schemas at runtime.
import { CallToolRequestSchema, JSONRPCMessageSchema, ListToolsResultSchema } from '@modelcontextprotocol/server/zod-schemas';

describe('@modelcontextprotocol/server/zod-schemas (compat subpath)', () => {
it('re-exports Zod schema constants from core', () => {
expect(CallToolRequestSchema).toBeInstanceOf(z.ZodType);
expect(JSONRPCMessageSchema).toBeInstanceOf(z.ZodType);
expect(ListToolsResultSchema).toBeInstanceOf(z.ZodType);
});

it('schemas parse valid spec values', () => {
const parsed = CallToolRequestSchema.parse({
method: 'tools/call',
params: { name: 'echo', arguments: {} }
});
expect(parsed.method).toBe('tools/call');
expect(parsed.params.name).toBe('echo');
});
});
4 changes: 3 additions & 1 deletion packages/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
"*": ["./*"],
"@modelcontextprotocol/core": ["./node_modules/@modelcontextprotocol/core/src/index.ts"],
"@modelcontextprotocol/core/public": ["./node_modules/@modelcontextprotocol/core/src/exports/public/index.ts"],
"@modelcontextprotocol/core/schemas": ["./node_modules/@modelcontextprotocol/core/src/types/schemas.ts"],
"@modelcontextprotocol/test-helpers": ["./node_modules/@modelcontextprotocol/test-helpers/src/index.ts"],
"@modelcontextprotocol/server/_shims": ["./src/shimsNode.ts"]
"@modelcontextprotocol/server/_shims": ["./src/shimsNode.ts"],
"@modelcontextprotocol/server/zod-schemas": ["./src/zodSchemas.ts"]
}
}
}
5 changes: 3 additions & 2 deletions packages/server/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default defineConfig({
failOnWarn: 'ci-only',
// 1. Entry Points
// Directly matches package.json include/exclude globs
entry: ['src/index.ts', 'src/shimsNode.ts', 'src/shimsWorkerd.ts', 'src/validators/cfWorker.ts'],
entry: ['src/index.ts', 'src/zodSchemas.ts', 'src/shimsNode.ts', 'src/shimsWorkerd.ts', 'src/validators/cfWorker.ts'],

// 2. Output Configuration
format: ['esm'],
Expand All @@ -26,7 +26,8 @@ export default defineConfig({
baseUrl: '.',
paths: {
'@modelcontextprotocol/core': ['../core/src/index.ts'],
'@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts']
'@modelcontextprotocol/core/public': ['../core/src/exports/public/index.ts'],
'@modelcontextprotocol/core/schemas': ['../core/src/types/schemas.ts']
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/server/typedoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://typedoc.org/schema.json",
"entryPoints": ["src"],
"entryPointStrategy": "expand",
"exclude": ["**/*.test.ts", "**/__*__/**"],
"exclude": ["**/*.test.ts", "**/__*__/**", "**/zodSchemas.ts"],
"navigation": {
"includeGroups": true,
"includeCategories": true
Expand Down
Loading