Repository navigation
Preserve recursive MCP schemas and explicit object data - #389
Conversation
Eigenwise
left a comment
There was a problem hiding this comment.
Recursive models are a real gap, but this branch predates the JSON Pointer $ref resolution from #335 and has to be rebuilt on top of it.
Leaving this open for an update. Please also keep to the limit in What gets reviewed before opening new pull requests.
cb20328 to
eec314a
Compare
|
Rebased onto current main I have consolidated the overlapping schema fixes from #370 and #393 here, as requested by the contribution guidelines:
Validation: 845 MCP tests passed, including 58 focused cases across the three fixes. Against the current main implementation, the same focused cases produce 43 failures and 15 passes. Coverage includes full/escaped pointers, array-index pointers, same-named definition containers, mutual recursion, transport round trips, and combined recursive typed extensions with reserved keys. Black, Flake8, and #370 and #393 are superseded by this combined patch so the same module no longer needs three overlapping PRs. Cross-PR integration check: I also applied #378 ( |
Eigenwise
left a comment
There was a problem hiding this comment.
Thanks for reworking this, it resolves what I raised: it's built on main's JSON Pointer resolution, a property called schema keeps its name, and additionalProperties: false no longer turns into a hard reject.
Checked on current main with this merged: the 58 new tests pass and 43 of them fail on main's source, and the core suite is otherwise unchanged. I also ran a schema generated from ordinary Pydantic models through it: a recursive model validates its nested children, a model with extra="allow" keeps the extra keys, and a field aliased to _id loads and is sent as _id.
…he map (#492) #389 changed how MCP schemas become models. Checked on main with a schema generated from Pydantic models: a recursive model rejects a bad nested child, an extra='allow' object keeps an undeclared key, a top-level unknown key is ignored, a field aliased to _id is accepted and dumped as _id, and a property named schema stays readable as .schema. Co-authored-by: Kenny Vaneetvelde <kenny@eigenwise.io> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Problem
MCP object schemas currently lose constraints or data in three related paths: recursive children fall back to
Any, Pydantic-reserved property names prevent a tool from loading or disappear, and explicitly permitted object extensions are dropped.Changes
params.schemaunchanged.additionalProperties: falseand unspecified policies.Consolidates #370 and #393 into this PR under the contribution guide's same-module rule.
Validation
git diff --check: passed.Includes input/output schemas, full and escaped pointers, nested/array-index references, same-named definition containers, mutual recursion, actual in-memory MCP transport, and combinations of recursive extras with reserved property names.