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:
Olivier Chafik 2026-09-07 15:26:00 +01:00
commit 040942b3af

View file

@ -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()`)
*