Skip to content

Commit bf3af27

Browse files
feat(sdk): re-export Protocol/ProtocolSpec from shared/protocol; add server/zod-compat subpath
1 parent 4c2565f commit bf3af27

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

packages/sdk/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@
5252
"types": "./dist/server/mcp.d.ts",
5353
"import": "./dist/server/mcp.mjs"
5454
},
55+
"./server/zod-compat.js": {
56+
"types": "./dist/server/zod-compat.d.ts",
57+
"import": "./dist/server/zod-compat.mjs"
58+
},
59+
"./server/zod-compat": {
60+
"types": "./dist/server/zod-compat.d.ts",
61+
"import": "./dist/server/zod-compat.mjs"
62+
},
5563
"./server/stdio.js": {
5664
"types": "./dist/server/stdio.d.ts",
5765
"import": "./dist/server/stdio.mjs"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// v1 compat: `@modelcontextprotocol/sdk/server/zod-compat.js`
2+
// v1 unified Zod v3 + v4 types. v2 is Zod v4-only, so these collapse to the
3+
// v4 types. Prefer `StandardSchemaV1` / `StandardSchemaWithJSON` for new code.
4+
5+
import type * as z from 'zod';
6+
7+
/** @deprecated Use `StandardSchemaV1` (any Standard Schema) or a Zod type directly in v2. */
8+
export type AnySchema = z.core.$ZodType;
9+
10+
/** @deprecated Use `Record<string, z.ZodType>` directly in v2. */
11+
export type ZodRawShapeCompat = Record<string, AnySchema>;
12+
13+
/** @deprecated */
14+
export type AnyObjectSchema = z.core.$ZodObject | AnySchema;
15+
16+
export type { StandardSchemaV1, StandardSchemaWithJSON } from '@modelcontextprotocol/server';

packages/sdk/src/shared/protocol.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
// v1 compat: `@modelcontextprotocol/sdk/shared/protocol.js`
2-
// Protocol class is no longer public in v2; subclass Client or Server instead.
3-
// Re-exporting the option types and context types that v1 callers commonly
4-
// imported from this path.
52

63
export type {
74
BaseContext,
85
ClientContext,
96
NotificationOptions,
107
ProtocolOptions,
8+
ProtocolSpec,
119
RequestOptions,
1210
ServerContext
1311
} from '@modelcontextprotocol/server';
12+
export { DEFAULT_REQUEST_TIMEOUT_MSEC, Protocol } from '@modelcontextprotocol/server';
1413

1514
/** @deprecated Use {@link ServerContext} (server handlers) or {@link ClientContext} (client handlers) in v2. */
1615
// eslint-disable-next-line @typescript-eslint/no-unused-vars

packages/sdk/tsdown.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default defineConfig({
1010
'src/experimental/tasks.ts',
1111
'src/server/index.ts',
1212
'src/server/mcp.ts',
13+
'src/server/zod-compat.ts',
1314
'src/server/completable.ts',
1415
'src/server/sse.ts',
1516
'src/server/stdio.ts',

0 commit comments

Comments
 (0)