modelcontextprotocol / modelcontextprotocol/typescript-sdk

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

Open
#2,705 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v1 v2
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the registerTool implementation and its tool wrapper, then reproduce the difference between the raw-shape validation and the schema's safeParse using refine, superRefine, or transform. Add a regression test showing that the full constraints run before the server gate accepts a payload, and verify the existing tool validation tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.