Skip to content

Flatten MCP namespace tools for non-OpenAI Responses API providers (Ollama, LM Studio, OpenRouter) #26234

@LucaCappelletti94

Description

@LucaCappelletti94

When Codex runs against a non-OpenAI Responses API endpoint such as a local server (Ollama, LM Studio), a gateway (OpenRouter), or AWS Bedrock Mantle, tools provided by MCP servers are never callable by the model. Codex serializes each MCP server's tools inside a proprietary {"type": "namespace", "name": "mcp__<server>", "tools": [...]} wrapper, which is not part of the standard OpenAI Responses API. OpenAI and Azure expand the wrapper and reach the nested tools, but other Responses API backends pass it through unchanged or reject any tool whose type is not function, so the model only ever sees a single non-callable mcp__<server> tool and the MCP tools are unusable.

I have a fix implemented and tested on this branch: https://github.com/LucaCappelletti94/codex/tree/flatten-mcp-tools-for-non-namespace-providers

The fix gives providers a namespace_tools capability. An explicit namespace_tools in [model_providers.<id>] config wins, otherwise it defaults to requires_openai_auth, so OpenAI and Azure keep namespaces while other Responses API providers get flattened tools. When the capability is off, each namespace is flattened into plain function tools named mcp__<server>__<tool> instead of being dropped, and the tool registry resolves a flat call name back to its namespaced runtime so the call dispatches correctly. The resolution side also covers tool names that a proxy flattens on its own. Bedrock keeps namespaces on by default but can opt out for Mantle with namespace_tools = false.

Unit tests cover the capability resolution (auto and explicit override), namespace flattening into canonical function specs rather than dropping them, and flat-name resolution to the namespaced runtime. I also verified the change end to end against Ollama with both gpt-oss:20b and gpt-oss:120b plus a real MCP server: the request now carries the MCP tool as a flat function named mcp__<server>__<tool> with no namespace wrapper, the model calls it, and the tool executes.

Related to #23186, #19871, #20652, and #25034 (Mantle can opt out with namespace_tools = false).

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIIssues related to the Codex CLIbugSomething isn't workingcustom-modelIssues related to custom model providers (including local models)mcpIssues related to the use of model context protocol (MCP) servers

    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