PostHog / PostHog/posthog

MCP: tool input_schema uses top-level anyOf/oneOf/allOf — breaks Anthropic API clients (Claude Code subagents)

Open
#61,359 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
6h 51m
Merged PRs (30d)
232

Description

Summary

At least one tool exported by the PostHog MCP server (services/mcp) declares its inputSchema with a top-level anyOf/oneOf/allOf (a bare union) instead of {"type": "object", "properties": {...}}. The Anthropic Messages API rejects any tool whose input_schema uses these keywords at the top level, so MCP clients backed by the Anthropic API fail as soon as the full PostHog toolset is sent.

Symptom

With the PostHog MCP server connected to Claude Code, spawning a sub-agent fails immediately with:

400 tools.<N>.custom.input_schema: input_schema does not support oneOf, allOf, or anyOf at the top level

In my session <N> was 279, and the index fell within the PostHog tool block (~369 tools exposed).

Why it's easy to miss

Clients that lazily/deferred-load tool schemas don't hit this until the offending tool is materialized. But clients that send the full toolset up front — notably Claude Code when it spawns a sub-agent — include the bad schema and the entire request 400s, so no sub-agent can start while the PostHog MCP server is connected. Disconnecting the PostHog server immediately resolved it for me.

Root cause

Anthropic's tool schema validation requires each tool's input_schema top level to be an object schema. A top-level anyOf/oneOf/allOf is invalid. (Nested composition inside a property is fine — only the top level is the problem.) The likely area is the polymorphic query-* family (insight/query inputs modeled as a union).

How to find the offender

Grep the generated tool definitions for any tool whose top-level inputSchema is anyOf/oneOf/allOf (not nested under a property).

Suggested fix

Ensure every exported tool's top-level inputSchema is {"type": "object", ...}. Wrap the union under a property (e.g. a single query object whose value is the union) or use a discriminated object with a kind/type field — don't expose the union at the root.

Environment

  • PostHog MCP server (services/mcp), ~369 tools exposed
  • Client: Claude Code (Anthropic Messages API)
  • Failure point: sub-agent creation

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in services/mcp and inspect the generated tool definitions, focusing on the polymorphic query-* family. Grep for exported tools whose top-level inputSchema is anyOf, oneOf, or allOf rather than an object schema. Confirm that every exported tool has an object at the root and that the full toolset is accepted by the affected Anthropic client.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.