Skip to content

JSON editor corrupts null values with cascading escape characters on nullable parameters #1885

Description

@gaoharimran29-glitch

Describe the bug
When a tool exposes an optional nullable parameter (e.g. int | None = None in Python), the Inspector's JSON argument editor mishandles edits to the default null value. Instead of allowing normal deletion or replacement, each keystroke (e.g. Backspace) progressively re-escapes the value, corrupting it into invalid JSON. This appears to be a JSON editor/state-handling issue in the Inspector UI itself, not an issue with the underlying MCP server or tool schema.

To Reproduce
Steps to reproduce the behavior:

  1. Create a tool with an optional nullable parameter:

    from fastmcp import FastMCP
    
    mcp = FastMCP(name="Demo")
    
    @mcp.tool
    def add_numbers(a: int, b: int | None = None) -> int:
         """
         Add two numbers and return the result
         """
         return a + b
    
    if __name__ == "__main__":
        mcp.run()
  2. Launch the Inspector via fastmcp dev inspector file_name.py

  3. Open the add_numbers tool in the Inspector UI

  4. Observe the auto-generated JSON input:

    {
      "b": null
    }
  5. Click into the null value field

  6. Press Backspace repeatedly

  7. Observe the value progressively accumulate escape characters instead of deleting cleanly:

    null → "nul" →  \"nul" → \\\"nul ...
    

    (see attached screen recording for the live progression)

Screen.Recording.2026-08-01.120224.mp4

Expected behavior
One of the following:

  • Backspace/Delete should remove characters normally without introducing escape sequences.
  • Clicking into a null value should allow direct replacement by typing a new value (e.g. an integer).
  • Optional/nullable fields should be rendered with a more editor-friendly representation (e.g. an empty input with a placeholder of null, or a toggle for "no value") rather than as a literal, in-place-edited null token.

Logs

fastmcp dev inspector file_name.py
Starting MCP inspector...
MCP Inspector Web is up and running at:
   http://localhost:6274?MCP_INSPECTOR_API_TOKEN=<token>
   Sandbox (MCP Apps): http://localhost:29822/sandbox
   Auth token: <token>
Opening browser...

Additional context

  • Changing the parameter to a non-nullable field with a non-null default (e.g. b: int = 30) reproduces normal, expected editor behavior — no escaping issue occurs. This suggests the bug is specific to how the editor handles/serializes null as the initial or current value, rather than an issue with numeric fields in general.
  • This makes it difficult to test or interact with any tool that has optional nullable parameters through the Inspector's JSON editor, which is a common and idiomatic pattern in typed Python (and TypeScript) tool definitions.
  • Screen recording attached showing the live escaping progression as Backspace is pressed repeatedly on the null value.
  • Reproduction code (shown above) attached/included for convenience.

Environments:

  • @modelcontextprotocol/inspector version: 2.0.0
  • FastMCP Version : 3.4.5
  • Python Version: 3.14.6
  • Node Version: 22.19.0
  • npm version: 10.9.3
  • OS: Windows 11 Home Single Language, Version 10.0.26200 (Build 26200).
  • Browser: Chrome Version 146.0.7680.80

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv2Issues and PRs for v2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions