Skip to content

Fix JSON parameter editor escaping while typing #1853

Description

@krubenok

Problem

Complex tool parameters rendered with the Inspector JSON editor publish invalid intermediate JSON to the parent form as a string. The controlled field then serializes that string on the next render, escaping quotes and replacing the text the user is actively typing.

This affects any free-form array or object parameter that uses the JSON fallback editor.

Example tool signature

{
  "name": "batch_process_items",
  "inputSchema": {
    "type": "object",
    "properties": {
      "itemIds": {
        "type": "array",
        "items": { "type": "string" },
        "description": "IDs to process"
      }
    },
    "required": ["itemIds"]
  }
}

Reproduction

  1. Connect the Inspector to a server exposing the tool above.
  2. Open the Tools tab and select batch_process_items.
  3. Type ["item-1","item-2"] into itemIds character by character.
  4. Before the JSON is complete, observe the editor replacing the draft with a quoted/escaped JSON string and moving the caret.

Expected behavior

The editor should preserve raw draft text while JSON is incomplete, publish only successfully parsed JSON values to the tool form state, and prevent a stale previously-valid value from being submitted during an invalid replacement edit.

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