MCP tool schemas not propagated properly
What version of Codex CLI is running?
0.111.0
What subscription do you have?
ChatGPT Team
Which model were you using?
gpt-5.4 (but this problem is not model-specific)
What platform is your computer?
Darwin 25.3.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
VS Code and Ghostty
What issue are you seeing?
Codex cannot handle MCP tool input schemas containing anyOf (or similar). anyOf fields get sanitised to string before being presented to the LLM.
What steps can reproduce the bug?
I've slop coded a minimal MCP server (attached Python script). Claude Code handles this just fine, and calls the tool correctly on its first attempt. Codex sometimes eventually gets there (by reading the MCP server's implementation).
What is the expected behavior?
Propagate tool input schemas to the LLM without modification.
Additional information
This is barely related, but I've noticed that output schemas aren't presented to the LLM at all. That's probably a separate bug (or maybe even intentional, but a bad decision IMO). I just thought I'd mention that.
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
- #13746
Powered by Codex Action
I reproduced a related schema-fidelity failure locally with Codex CLI 0.155.0 and a credential-free stdio MCP server.
The source MCP schema and Codex app-server mcpServerStatus/list schema remain complete, but the code-mode declaration silently compacts nested fields to unknown. A Hoodie tool with rowGroups, columnGroups, filterset, and sort becomes:
rowGroups: Array<unknown>;
columnGroups?: Array<unknown>;
filterset?: { filterBy: unknown };
sort?: Array<unknown>;
Controls: each property alone, every pair, and every three-property combination remain typed. Four complex properties together degrade. A local synthetic boundary also reproduces this with one extra ordinary filter field. The only advertised MCP tool gives the same result, ruling out total catalog size.
The current Codex source appears to explain the behavior: codex-rs/tools/src/json_schema/compaction.rs defines a 5,000-byte normalized schema budget, strips descriptions, then collapses complex schema objects at depth 3 and may prune composition keywords. That matches the observed silent {} -> unknown fallback:
https://github.com/openai/codex/blob/main/codex-rs/tools/src/json_schema/compaction.rs
This is a sanitized local reproducer; no Hoodie schema, credentials, or customer data are required. Related issue #20604 appears to cover the narrower array.items.oneOf(object) conversion failure. The desired behavior is to preserve discriminators and nested object shape, or emit a diagnostic instead of silently changing the tool contract. Happy to provide the local probe and exact boundary matrix.
I reproduced a related MCP output schema issue on codex-cli 0.171.0, Windows 10.0.26300.0 x64, using a custom MCP server over authenticated Streamable HTTP.
Expected: The agent-facing declaration preserves the array types for data.groups and data.hits.
Observed: Both fields are shown as unknown in the active agent’s tool definition. A fresh agent thread also reported both fields as unknown even though its own app-server catalog retained the array types.
Steps to reproduce
- Start
codex app-server --listen stdio://and use one JSON-RPC client for the entire run. Start a fresh thread withephemeral: true. - Confirm the thread ID via
thread/loaded/list, then callmcpServerStatus/listwith{"detail":"full","serverName":"travel","threadId":"<thread-id>"}. - Send the exact prompt below with
turn/starton that thread. - Repeat
mcpServerStatus/listwith the same parameters and comparesearch_travel.outputSchema.
Scrubbed catalog output
This is a projection of the RPC response for search_travel, with local schema references resolved and unrelated fields omitted.
{
"tool": "search_travel",
"data.groups": {
"type": "array",
"items": { "type": "object" }
},
"data.hits": {
"type": "array",
"itemSchemaVariants": 14
}
}
The complete tool outputSchema had 163 $defs. Its SHA-256 was identical before and after the turn. MCP Inspector independently showed the same array types from the server.
Exact agent prompt
Read-only tool metadata diagnostic. Do not call any MCP tool, run shell commands, or inspect files. Use the agent-facing declaration already made available to you for the direct Travel MCP tool search_travel, not a catalog/schema RPC. If your runtime offers a read-only tool-definition discovery function or declaration viewer, you may use that only to read the agent-facing declaration. Answer only with a JSON object whose groups and hits values are each one of 'unknown', 'array', 'other', or 'not_visible'. Use 'not_visible' if you cannot actually see that field's declared output type. Do not infer types from field names or descriptions.
The fresh thread reported {"groups":"unknown","hits":"unknown"}. No MCP tool calls were observed. The fresh-thread result is the agent’s report of its visible declaration.
Relevant ~/.codex/config.toml excerpt
[mcp_servers.travel]
url = "https://<redacted-private-endpoint>/mcp"
startup_readiness is unset. The endpoint is private, so the redacted URL is a placeholder.