Skip to content

Commit df2e7d2

Browse files
feat(compat): add ResourceReferenceSchema alias; point deprecation to specTypeSchemas/isSpecType
1 parent bfa7068 commit df2e7d2

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

.changeset/compat-zod-schemas-subpath.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

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

7-
Re-exports the `*Schema` Zod constants (e.g. `CallToolRequestSchema`, `JSONRPCMessageSchema`) and the `getRequestSchema(method)` / `getResultSchema(method)` / `getNotificationSchema(method)` lookup helpers, so v1 code that imported schemas 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. Prefer `specTypeSchema()` for runtime validation.
7+
Re-exports the `*Schema` Zod constants (e.g. `CallToolRequestSchema`, `JSONRPCMessageSchema`) and the `getRequestSchema(method)` / `getResultSchema(method)` / `getNotificationSchema(method)` lookup helpers, so v1 code that imported schemas 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. Prefer `specTypeSchemas` / `isSpecType` (#1887) for runtime validation.
88

9-
The `@modelcontextprotocol/sdk` meta-package (#1913 in this series) re-exports this subpath at `sdk/types.js`, so v1 imports work unchanged once both PRs land.
9+
The `@modelcontextprotocol/sdk` meta-package (#1913 in this series) re-exports this subpath at `sdk/types.js`, so v1 imports work unchanged once both PRs land. The `specTypeSchemas` / `isSpecType` references in the deprecation guidance are added by #1887.

docs/migration-SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Notes:
9898
| `StreamableHTTPError` | REMOVED (use `SdkError` with `SdkErrorCode.ClientHttp*`) |
9999
| `WebSocketClientTransport` | REMOVED (use `StreamableHTTPClientTransport` or `StdioClientTransport`) |
100100

101-
All other **type** symbols from `@modelcontextprotocol/sdk/types.js` retain their original names. **Zod schemas** (e.g., `CallToolResultSchema`, `ListToolsResultSchema`) are not exported from the package root; for runtime validation prefer type guard functions like `isCallToolResult` or `specTypeSchema()`. For v1 compatibility the schemas are available from the `@modelcontextprotocol/server/zod-schemas` subpath.
101+
All other **type** symbols from `@modelcontextprotocol/sdk/types.js` retain their original names. **Zod schemas** (e.g., `CallToolResultSchema`, `ListToolsResultSchema`) are not exported from the package root; for runtime validation prefer type guard functions like `isCallToolResult`, or the `isSpecType` / `specTypeSchemas` Records. For v1 compatibility the schemas are available from the `@modelcontextprotocol/server/zod-schemas` subpath.
102102

103103
### Error class changes
104104

docs/migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ The following deprecated type aliases have been removed from `@modelcontextproto
544544
| `IsomorphicHeaders` | Use Web Standard `Headers` |
545545
| `AuthInfo` (from `server/auth/types.js`) | `AuthInfo` (now re-exported by `@modelcontextprotocol/client` and `@modelcontextprotocol/server`) |
546546

547-
All other **type** symbols from `@modelcontextprotocol/sdk/types.js` retain their original names — import them from `@modelcontextprotocol/client` or `@modelcontextprotocol/server`. **Zod schemas** (e.g., `CallToolRequestSchema`) are not re-exported from the package roots; for runtime validation prefer `specTypeSchema()` or, for v1 source compatibility, import them from `@modelcontextprotocol/server/zod-schemas`.
547+
All other **type** symbols from `@modelcontextprotocol/sdk/types.js` retain their original names — import them from `@modelcontextprotocol/client` or `@modelcontextprotocol/server`. **Zod schemas** (e.g., `CallToolRequestSchema`) are not re-exported from the package roots; for runtime validation prefer the `isSpecType` / `specTypeSchemas` Records, or for v1 source compatibility import them from `@modelcontextprotocol/server/zod-schemas`.
548548

549549
> **Note on `isJSONRPCResponse`:** v1's `isJSONRPCResponse` was a deprecated alias that only checked for *result* responses (it was equivalent to `isJSONRPCResultResponse`). v2 removes the deprecated alias and introduces a **new** `isJSONRPCResponse` with corrected semantics — it checks for *any* response (either result or error). If you are migrating v1 code that used `isJSONRPCResponse`, rename it to `isJSONRPCResultResponse` to preserve the original behavior. Use the new `isJSONRPCResponse` only when you want to match both result and error responses.
550550

packages/server/src/zodSchemas.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/**
22
* v1-compat re-export of all protocol Zod schemas.
33
*
4-
* Prefer {@linkcode specTypeSchema} for runtime validation. These are Zod
5-
* schemas; their TS type may change with internal Zod upgrades.
4+
* Prefer `specTypeSchemas` / `isSpecType` (from `@modelcontextprotocol/server`)
5+
* for runtime validation. These are Zod schemas; their TS type may change with
6+
* internal Zod upgrades.
67
*
7-
* @deprecated Use `specTypeSchema()` for runtime validation.
8+
* @deprecated Use `specTypeSchemas` / `isSpecType` for runtime validation.
89
* @packageDocumentation
910
*/
1011

11-
/** @deprecated Use `specTypeSchema()` for runtime validation. */
12+
/** @deprecated Use `specTypeSchemas` / `isSpecType` for runtime validation. */
1213
export * from '@modelcontextprotocol/core/schemas';
1314

14-
/** @deprecated Use `specTypeSchema()` for runtime validation. */
15+
/** @deprecated Use `specTypeSchemas` / `isSpecType` for runtime validation. */
1516
export {
1617
IdJagTokenExchangeResponseSchema,
1718
OAuthClientInformationFullSchema,
@@ -30,5 +31,7 @@ export {
3031
} from '@modelcontextprotocol/core';
3132
export {
3233
/** @deprecated Use {@linkcode JSONRPCErrorResponseSchema}. */
33-
JSONRPCErrorResponseSchema as JSONRPCErrorSchema
34+
JSONRPCErrorResponseSchema as JSONRPCErrorSchema,
35+
/** @deprecated Use {@linkcode ResourceTemplateReferenceSchema}. */
36+
ResourceTemplateReferenceSchema as ResourceReferenceSchema
3437
} from '@modelcontextprotocol/core/schemas';

0 commit comments

Comments
 (0)