modelcontextprotocol / modelcontextprotocol/typescript-sdk
registerTool with zod raw shape: refine/superRefine/transform are silently dropped from validation
Nobody has claimed this yet.
- 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
- Run the full ZodObject parse (the authoritative
safeParse) in the tool wrapper, or - Document the limitation loudly in the
registerToolsignature 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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