docs: explain v1 empty inputSchema / _def crash from z.object() raw-shape misuse - #2727
Open
FenjuFu wants to merge 1 commit into
Open
Conversation
…-shape misuse Passing a complete z.object() into the v1 positional server.tool() slot (which expects a raw Zod shape) silently publishes an empty inputSchema on v1.12.0-1.26.0, or crashes tools/list with "reading '_def'" via registerTool() on v1.12.0-1.21.0. Neither symptom pointed at the cause. Add a troubleshooting entry keyed on both searchable symptoms and a warning in the v1->v2 migration guide. Closes modelcontextprotocol#2627 Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
|
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #2627. On v1 (
server.tool()positional API), passing a completez.object({...})where a raw Zod shape ({ name: z.string() }) is expected fails in ways that never name the cause:server.tool()on v1.12.0–1.26.0 publishes{"type":"object"}with no properties and raises nothing —tools/listlooks fine, but clients drop every argument.registerTool()on v1.12.0–1.21.0 crashestools/listwithCannot read properties of null (reading '_def').Neither the troubleshooting page nor the v1→v2 migration guide mentioned these symptoms, and the issue reporter (and others) lost real debugging time to them.
Changes
docs/troubleshooting.md— a new entry keyed on both searchable symptoms (emptyinputSchema;reading '_def'), with the raw-shape vsz.object()distinction, the affected version ranges, adifffix, and the v2 contrast. Plus one recap bullet, consistent with the page's "every heading is the message you searched for" convention.docs/migration/upgrade-to-v2.md— a short warning in the Standard Schema objects section that doing the v2 shape backwards on v1 fails quietly, linking to the troubleshooting page.Docs-only; no code or package version change (no changeset needed).