Skip to content

fix: support allOf and oneOf in tool input forms - #1602

Closed
pablopupo wants to merge 1 commit into
modelcontextprotocol:mainfrom
pablopupo:fix/496-allof-oneof-forms
Closed

fix: support allOf and oneOf in tool input forms#1602
pablopupo wants to merge 1 commit into
modelcontextprotocol:mainfrom
pablopupo:fix/496-allof-oneof-forms

Conversation

@pablopupo

Copy link
Copy Markdown

Summary

Tool input schemas that compose their properties with allOf rendered an empty form, because both ToolsTab and DynamicJsonForm only look at top-level properties. oneOf unions of full schemas rendered nothing at all. This makes both work.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • client/src/utils/schemaUtils.ts adds mergeAllOf(), which flattens allOf branches before a form renders. Properties are merged, required arrays are unioned, $ref branches resolve against the root schema, and circular ref chains terminate.
  • client/src/components/ToolsTab.tsx merges the input schema before iterating its properties, passes required and oneOf through to nested forms (both were dropped when the schema object was rebuilt), and keys per-property form state by tool name so state cannot leak between tools that share a property name.
  • client/src/components/DynamicJsonForm.tsx merges allOf at the top level and per property, and renders a variant selector for oneOf members that are full schemas. The selector infers the initial variant from the current value, keeps nested selectors independent, and treats properties-without-type members as objects. Options carrying const keep the existing titled enum select from Add support for SEP-1330 Elicitation Enums #952 untouched.
  • client/src/utils/jsonUtils.ts adds allOf to JsonSchemaType.

Related Issues

Fixes #496

Testing

  • Added/updated automated tests

Test Results and/or Instructions

22 new tests across schemaUtils.test.ts, DynamicJsonForm.test.tsx, and ToolsTab.test.tsx, including the exact schema shape from the issue. Full client suite passes (557 tests, 32 suites) and the Playwright e2e suite passes.

To see the original bug, point the inspector at a server whose tool wraps properties in a top-level allOf (the schema in #496). On main the tool form renders no fields; on this branch the fields render with their required markers.

Checklist

  • Code follows the style guidelines (ran npm run prettier-fix)
  • Self-review completed
  • Code is commented where necessary
  • Documentation updated (README, comments, etc.)

Breaking Changes

None.

Additional Context

resolveRef still only recurses into anyOf, so $ref support inside oneOf branches beyond what the variant selector resolves stays with #445.

Tool schemas that compose properties with allOf rendered an empty form
because ToolsTab and DynamicJsonForm only looked at top level
properties. Merge allOf branches (properties, required, refs) before
rendering, and render oneOf variant unions with a selector while
keeping the existing const and title enum selects untouched.

Fixes modelcontextprotocol#496
@cliffhall

cliffhall commented Jul 2, 2026

Copy link
Copy Markdown
Member

Hi @pablopupo. As mentioned in the PR template, we are not accepting issues for anything but security and bug fixes for the v1 Inspector.

In the new SDK, full JSON Schema will be supported, including allOf/oneOf. We are hard at work on V2 of the Inspector, which should be available very soon, and this will be supported.

@cliffhall cliffhall closed this Jul 2, 2026
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.

Support JSON Schema allOf, oneOf, etc.

2 participants