Skip to content

feat: emit additionalProperties: false for strict Zod schemas (closes #176) - #197

Open
huysonmind wants to merge 1 commit into
QuantGeekDev:mainfrom
huysonmind:feat/strict-additional-properties
Open

huysonmind wants to merge 1 commit into
QuantGeekDev:mainfrom
huysonmind:feat/strict-additional-properties

Conversation

@huysonmind

Copy link
Copy Markdown

Closes #176.

Tools whose schema is z.object(...).strict() already reject unknown arguments at runtime, but the generated inputSchema didn't say so. This emits additionalProperties: false for strict objects (top-level and nested), so clients and models know extra arguments aren't allowed (see SEP-1613). Default (strip) and .passthrough() objects are unchanged, so existing tools produce the same schema.

schema = z.object({
  city: z.string().describe("City name"),
}).strict();
// inputSchema: { type: "object", properties: {...}, required: ["city"], additionalProperties: false }

Tests

  • New tests/tools/strict-schema.test.ts: top-level, nested, passthrough, runtime rejection, and tools/list over handleRequest().
  • Full suite on Node 22: 855/855 tests pass; the 5 packages/docs suites that fail to compile on main are unchanged.

Docs: new "Rejecting Unknown Arguments" section in the README.

Independent of #196.

🤖 Generated with Claude Code

Tools whose schema is `z.object(...).strict()` already reject unknown
arguments at runtime, but the generated JSON Schema did not say so.
Emit `additionalProperties: false` for strict top-level and nested
objects; default (strip) and passthrough objects are unchanged.

Closes QuantGeekDev#176

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

additionalProperties in JSON InputSchema

1 participant