Import shared wire types from @modelcontextprotocol/client
spec.types.ts previously inferred CallToolResult, ContentBlock and friends from core's Zod schemas via a local core-types module so that the type surface stayed free of a client package edge. Now that client is a required peer, take the types from it directly and delete the indirection. Generated schemas are unchanged.
This commit is contained in:
parent
50eb30ec8d
commit
040942b3af
3 changed files with 6 additions and 24 deletions
|
|
@ -22,10 +22,12 @@
|
|||
*
|
||||
* **Problem**: ts-to-zod cannot resolve types imported from external packages.
|
||||
* When it encounters types like `ContentBlock`, `CallToolResult`, `Implementation`,
|
||||
* `RequestId`, and `Tool` from `@modelcontextprotocol/core`, it generates `z.any()`
|
||||
* as a placeholder.
|
||||
* `RequestId`, and `Tool` (imported by spec.types.ts from
|
||||
* `@modelcontextprotocol/client`), it generates `z.any()` as a placeholder.
|
||||
*
|
||||
* **Solution**: Import the schemas from MCP SDK and remove the z.any() placeholders.
|
||||
* **Solution**: Import the corresponding Zod schemas from
|
||||
* `@modelcontextprotocol/core` (the role-neutral package both client and
|
||||
* server re-export) and remove the z.any() placeholders.
|
||||
*
|
||||
* ### 3. Index Signatures (`z.record().and()` → `z.object().passthrough()`)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
import {
|
||||
CallToolResultSchema,
|
||||
ContentBlockSchema,
|
||||
EmbeddedResourceSchema,
|
||||
ImplementationSchema,
|
||||
RequestIdSchema,
|
||||
ResourceLinkSchema,
|
||||
ToolSchema,
|
||||
} from "@modelcontextprotocol/core";
|
||||
import type { z } from "zod/v4";
|
||||
|
||||
// Infer shared wire types from the public role-neutral schemas so declarations
|
||||
// used by every entrypoint do not acquire a client or server package edge.
|
||||
export type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
||||
export type ContentBlock = z.infer<typeof ContentBlockSchema>;
|
||||
export type EmbeddedResource = z.infer<typeof EmbeddedResourceSchema>;
|
||||
export type Implementation = z.infer<typeof ImplementationSchema>;
|
||||
export type RequestId = z.infer<typeof RequestIdSchema>;
|
||||
export type ResourceLink = z.infer<typeof ResourceLinkSchema>;
|
||||
export type Tool = z.infer<typeof ToolSchema>;
|
||||
|
|
@ -18,7 +18,7 @@ import type {
|
|||
RequestId,
|
||||
ResourceLink,
|
||||
Tool,
|
||||
} from "./core-types";
|
||||
} from "@modelcontextprotocol/client";
|
||||
|
||||
/**
|
||||
* Current protocol version supported by this SDK.
|
||||
|
|
|
|||
Loading…
Reference in a new issue