modelcontextprotocol / modelcontextprotocol/typescript-sdk

zod v4: "additionalProperties: false" missing

Open
#2,636 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

We upgraded zod from v3 to v4. After the upgrade, all input schemas are missing additionalProperties: false in the tools/list response.

With zod@v3 the additionalProperties: false is returned correctly in the inputSchema.

zod: v3 and v4
@modelcontextprotocol/sdk: v1 and v2

Reproduction

Use the following example with zod@v3 and zod@v4:

const server = new McpServer({ name: "test-server", version: "1.0.0" });
server.registerTool(
  "test",
  {
    description: "Breaking input schema",
    inputSchema: { testInput: z.string() },
    outputSchema: { testOutput: z.string() },
  },
  async () => ({ content: [], structuredContent: { testOutput: "abc" } })
);

With zod@v4 we have this generated input schema

inputSchema: {
  type: "object"
  properties: { ... } 1 item
  required: [ ... ] 1 item
  $schema: "https://json-schema.org/draft/2020-12/schema"
}

But with zod@v3 we have this generated input schema

inputSchema: {
  type: "object"
  properties: { ... } 1 item
  required: [ ... ] 1 item
  $schema: "https://json-schema.org/draft/2020-12/schema"
  additionalProperties: false
}

Is this expected behavior or a bug?

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 McpServer.registerTool entry point and trace how its inputSchema is converted for the tools/list response, comparing the zod v3 and v4 reproductions shown here. Confirm the expected behavior with the project’s existing schema-generation tests or add a focused regression test; done means the zod v4 schema includes additionalProperties: false when appropriate.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.