Skip to content

Commit af0ef55

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

3 files changed

Lines changed: 12 additions & 9 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.md

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

559-
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`.
559+
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`.
560560

561561
> **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
562562
> 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.

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)