Skip to content

Conversation

@cliffhall
Copy link
Member

@cliffhall cliffhall commented Dec 3, 2025

Summary

Allows the DynamicJsonForm to render the various enum types supported by the new version of the spec (SEP-1330).

Changes Made

In DynamicJsonForm.tsx,

  • Support all five enum shapes used by MCP SDK:
    • Titled single-select via oneOf/anyOf with { const, title }
    • Untitled single-select via enum
    • Titled legacy single-select with optional enumNames for labels
    • Titled multi-select via items.anyOf/oneOf
    • Untitled multi-select via items.enum
  • Show field descriptions for string select fields and boolean checkboxes (consistent help text above inputs).
  • Prefer schema property title for object field labels; fall back to the JSON key when missing.
  • Allow top‑level form rendering for objects with properties, arrays with items, and primitive types (was overly strict before).
  • Multi-select UI: sensible list size and minItems/maxItems helper text when present.
  • JSON editor fallback, copy/format controls, and debounced parsing preserved.
  • apply defaults for optional fields during form init

In schemaUtils.ts

  • generateDefaultValue now includes optional properties that declare a default, ensuring fields like strings show their defaults on first render.

In jsonUtils.ts

  • Add legacy enumNames?: string[] and array constraints minItems?/maxItems?.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates
  • Build/CI improvements

Related Issues

#933

Testing

  • Tested in UI mode
  • Tested in CLI mode
  • Tested with STDIO transport
  • Tested with SSE transport
  • Tested with Streamable HTTP transport
  • Added/updated automated tests
  • Manual testing performed

Test Results and/or Instructions

Used this PR for the Everything server which updates it Elicitation Request to have all the fields.

Elicitation Form Elicitation Result

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

Nope.

Additional Context

For more on the various enum types now supported by the protocol, see SEP-1330

In DynamicJsonForm.tsx,
  - Support all five enum shapes used by MCP SDK:
    - Titled single-select via `oneOf`/`anyOf` with `{ const, title }`
    - Untitled single-select via `enum`
    - Titled legacy single-select with optional `enumNames` for labels
    - Titled multi-select via `items.anyOf`/`oneOf`
    - Untitled multi-select via `items.enum`
  - Show field descriptions for string select fields and boolean checkboxes (consistent help text above inputs).
  - Prefer schema property `title` for object field labels; fall back to the JSON key when missing.
  - Allow top‑level form rendering for objects with properties, arrays with items, and primitive types (was overly strict before).
  - Multi-select UI: sensible list size and `minItems`/`maxItems` helper text when present.
  - JSON editor fallback, copy/format controls, and debounced parsing preserved.
  - apply defaults for optional fields during form init

In schemaUtils.ts
  - `generateDefaultValue` now includes optional properties that declare a `default`, ensuring fields like strings show their defaults on first render.

In jsonUtils.ts
  - Add legacy `enumNames?: string[]` and array constraints `minItems?`/`maxItems?`.
- Align tests with new form-first rendering and UI behavior:
  - Labels prefer schema `title` over property key.
  - Descriptions shown for boolean checkboxes and select fields.
  - Explicit mode switching between Form/JSON when needed.
- Add comprehensive coverage for enum schema variants:
  - Titled single-select via `oneOf`/`anyOf` with `{ const, title }`.
  - Untitled single-select via `enum` (with legacy `enumNames` labels).
  - Untitled multi-select via `items.enum` with `minItems`/`maxItems` helper text.
  - Titled multi-select via `items.anyOf`/`oneOf` with `{ const, title }`.
- Adjust complex/JSON-mode tests to click “Switch to JSON” before asserting textarea and clipboard interactions.
- Fix debounced JSON update expectations to assert parsed objects rather than raw text.

Files updated:
- `client/src/components/__tests__/DynamicJsonForm.test.tsx`
- `client/src/components/__tests__/DynamicJsonForm.array.test.tsx`
@cliffhall cliffhall changed the title DynamicJsonForm improvements and full enum schema support Add support for SEP-1330 Dec 4, 2025
@cliffhall cliffhall changed the title Add support for SEP-1330 Add support for SEP-1330 Elicitation Enums Dec 4, 2025
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.

1 participant