Skip to content

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

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.)

Activity

  1. imagekitio commented on Jul 3, 2026

    @imagekitio
    Collaborator

    Thanks @usernamesergei for reporting this. We have updated the hosted MCP server and created a plugin for easy installation of skills + MCP servers.

    Please follow the latest docs - https://imagekit.io/docs/build-with-ai

    All of these issues are fixed now. The new MCP server is built on the "Code Mode" tool scheme and uses far less tokens and can finish complex tasks better.

  2. imagekitio commented on Sep 15, 2026

    @imagekitio
    Collaborator

    @usernamesergei even better, now use https://imagekit.io/mcp/dam and it works within user boundary using oAuth instead of API keys.
    https://imagekit.io/docs/build-with-ai#mcp-servers

    Everything remote, nothing local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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