Skip to content

docs: explain v1 empty inputSchema / _def crash from z.object() raw-shape misuse - #2727

Open
FenjuFu wants to merge 1 commit into
modelcontextprotocol:mainfrom
FenjuFu:docs/v1-empty-inputschema-troubleshooting
Open

docs: explain v1 empty inputSchema / _def crash from z.object() raw-shape misuse#2727
FenjuFu wants to merge 1 commit into
modelcontextprotocol:mainfrom
FenjuFu:docs/v1-empty-inputschema-troubleshooting

Conversation

@FenjuFu

@FenjuFu FenjuFu commented Aug 27, 2026

Copy link
Copy Markdown

Motivation

Closes #2627. On v1 (server.tool() positional API), passing a complete z.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/list looks fine, but clients drop every argument.
  • The same complete schema passed to registerTool() on v1.12.0–1.21.0 crashes tools/list with Cannot 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 (empty inputSchema; reading '_def'), with the raw-shape vs z.object() distinction, the affected version ranges, a diff fix, 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).

…-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>
@FenjuFu
FenjuFu requested a review from a team as a code owner August 27, 2026 02:01
@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 18c761b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Aug 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2727

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@2727

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@2727

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2727

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@2727

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2727

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2727

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2727

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2727

commit: 18c761b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant