Skip to content

registerTool with zod raw shape: refine/superRefine/transform are silently dropped from validation #2705

Description

@qiyueqiu

Problem

registerTool(name, { inputSchema: <zod object> }) validates against the raw shape only; refine / superRefine / transform constraints never run. A payload rejected by schema.safeParse passes the server gate — a fail-open validation gap for tools whose security-critical constraints are expressed via refine/superRefine.

Suggestion

  1. Run the full ZodObject parse (the authoritative safeParse) in the tool wrapper, or
  2. Document the limitation loudly in the registerTool signature so integrators know refine-level constraints require their own wrapper.

Context

Observed on @modelcontextprotocol/sdk 1.30.0. Our mitigation: the tool wrapper runs an authoritative safeParse itself before delegating (regression-tested).

Metadata

Metadata

Assignees

No one assigned

    Labels

    v1Issues / PRs related to v1.xv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions