Skip to content

SchemaForm crashes with Mantine "Duplicate options … value """ when array items use anyOf of object schemas #2007

Description

@lneveu

Which version line?

v2 — current (@modelcontextprotocol/inspector@latest)

Which client?

Web

Inspector version

2.2.0

Node version

v22.22.2

Operating system (and browser, for the web client)

No response

Transport

Streamable HTTP

MCP server under inspection

Custom MCP server

  • Transport: Streamable HTTP
  • SDK: @modelcontextprotocol/sdk ^1.29.0
  • Input schemas defined with Zod 4
  • Trigger: any tool whose inputSchema has an array property whose items are an anyOf of object schemas (no top-level scalar const on each branch), e.g. Zod z.array(z.union([z.object(...), z.object(...)]))

Steps to reproduce

  1. Connect Inspector (Web) to an MCP server that exposes a tool with an inputSchema shaped like:
{
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "type": { "type": "string", "const": "A" },
              "payload": { "type": "object" }
            },
            "required": ["type", "payload"]
          },
          {
            "type": "object",
            "properties": {
              "type": { "type": "string", "const": "B" },
              "payload": { "type": "object" }
            },
            "required": ["type", "payload"]
          }
        ]
      }
    }
  },
  "required": ["items"]
}

Equivalent Zod shape:

   z.object({
     items: z.array(
       z.union([
         z.object({ type: z.literal("A"), payload: z.object({}) }),
         z.object({ type: z.literal("B"), payload: z.object({}) }),
       ])
     ),
   })
  1. Open the Tools tab and select that tool.

  2. Observe the tool detail / parameter form render.

Expected behavior

The form should render without crashing. For an array of object unions (anyOf branches without a top-level scalar const), SchemaForm should fall back to the JSON editor (JsonInput), same as other unsupported/complex schemas — not treat the field as a string MultiSelect.

Actual behavior

The UI greys out / the tool panel crashes. The browser console throws:

Uncaught Error: [@mantine/core] Duplicate options are not supported. Option with value "" was provided more than once

Root cause in clients/web/src/components/groups/SchemaForm/SchemaForm.tsx:

// array with items having anyOf
if (fieldSchema.type === "array" && fieldSchema.items?.anyOf) {
const data = fieldSchema.items.anyOf.map((item) => ({
value: String(item.const ?? ""),
label: item.title ?? String(item.const ?? ""),
}));
return <MultiSelect ... data={data} />;
}

For object-union branches there is no top-level const, so every option becomes value "". Mantine Select/MultiSelect requires unique values and throws.

Logs, errors, or screenshots

Console:

Uncaught Error: [@mantine/core] Duplicate options are not supported. Option with value "" was provided more than once
at ... (@mantine/core Select/MultiSelect option validation)
at SchemaForm render for the tool parameter form

Already prototyped a fix?

No response

Before you submit

  • I searched existing issues and this is not a duplicate.
  • This is not a security vulnerability report (those go through the private advisory process).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv2Issues and PRs for v2

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions