Skip to content

[mcp-server] 3 tools have a top-level anyOf in inputSchema → rejected by OpenAI & Anthropic (bricks the whole session) #150

@usernamesergei

Description

@usernamesergei

Summary

The hosted ImageKit MCP server (https://api-mcp.imagekit.in/sse, package @imagekit/api-mcp)
advertises 3 tools whose JSON inputSchema has a union (anyOf) at the top level:

  • create_accounts_origins
  • update_accounts_origins
  • update_files

Their schema looks like {"type": "object", "anyOf": [ {…}, {…} ]} (a discriminated union of
origin types / update variants).

Both the OpenAI and the Anthropic function-calling APIs forbid anyOf/oneOf/allOf at the
top level of a tool's parameter schema
. Because these servers send the full tool list on every
request, a single offending tool makes every request return HTTP 400 — the entire client
session is unusable, not just that one tool.

Exact errors

  • OpenAI (Codex CLI):
    Invalid schema for function 'create_accounts_origins': schema must have type 'object' and not have 'oneOf'/'anyOf'/'allOf'/'enum'/'not' at the top level.
  • Anthropic (Claude Code):
    API Error: 400 ...input_schema: input_schema does not support oneOf, allOf, or anyOf at the top level

Environment

  • MCP server: hosted https://api-mcp.imagekit.in/sse, reached via mcp-remote
  • Clients reproduced on: Claude Code (Anthropic API) and Codex CLI 0.134.0 (OpenAI API)
  • The tools are flagged beta ("This API is currently in beta").

Impact

Any MCP client backed by OpenAI or Anthropic that connects to this server is fully broken as long
as these tools are present — there's no per-tool workaround on the client side short of dropping
the whole server.

Suggested fix

Generate the parameter schema so the root is always {"type": "object", ...} with no
top-level anyOf/oneOf/allOf. Options: move the discriminated union under a property,
flatten the variants into one object with an optional discriminator + conditionally-required
fields, or post-process generated tool schemas to lift unions off the root. (This likely affects
all endpoints whose request body is a oneOf/anyOf in the OpenAPI spec.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions