Skip to content

zod v4: "additionalProperties: false" missing #2636

Description

@FelixBaum

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions