Repository navigation
Description
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).
Activity
justaddcoffee commentedon Jun 3, 2026
+1 for this PR!
github-actions commentedon Jun 3, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
LucaCappelletti94 commentedon Jun 3, 2026
No, that is not a related solution (and it does not work as commented by some other person). Also, this is primarily related to open models. My solution works with any open model with tooling supporting the Responses API.
MathieuBo commentedon Jun 3, 2026
+1 for this PR
AO33 commentedon Jun 3, 2026
+1 for this PR
GGBondBlueWhale commentedon Jun 3, 2026
+1 for this PR
SylvainWinning commentedon Jun 3, 2026
blakelai commentedon Jun 4, 2026
+1
madarkadonk commentedon Jun 4, 2026
+1 - this is happening with my vLLM-hosted Qwen 3.6, spent yesterday trying to diagnose what was happening trying to use an MCP tool and this matches it exactly.
LucaCappelletti94 commentedon Jun 4, 2026
@madarkadonk feel free to use my fork in the meantime and do let me know whether any issue come out of it. So far it seems to work on my end.
justaddcoffee commentedon Jun 4, 2026
@madarkadonk also please promote this issue / PR! We feel like this really would improve codex
11 remaining items
xyun1996 commentedon Jul 1, 2026
Also experiencing this with the Xunfei (讯飞) custom provider via --profile xunfei.
Setup:
When using --profile xunfei:
Workaround attempted: using mcp-remote as a stdio proxy — this fails for Figma because Figma's MCP server rejects non-whitelisted
OAuth clients (403 Forbidden). It works for Tavily since Tavily accepts API keys in the URL.
Current workaround: switch back to default OpenAI model when Figma access is needed, then back to xunfei for regular coding. Not
ideal.
This is the same root cause as MCP tool invocation regressed for custom/local providers (Ollama Responses API) in v0.117.0+ #19871 and MCP servers disappear from session when using a custom provider #19363. Has been open since April — any updates on a fix?
philippgille commentedon Jul 11, 2026
I messaged OpenRouter and asked them if they could create a plugin to fix these request issues. They already have a "JSON Response Healer" plugin, and it sounds like it should be possible to have a "Codex Request Healer" plugin that rewrites the Codex request JSON to match the Responses API spec.
madarkadonk commentedon Jul 12, 2026
openai preferred PR 28271, then closed that one in favor of 29602, then closed 29602 with no explanation. Seems like supporting third party models isn't their priority, which I guess isn't too surprising, though disappointing.
oddm643 commentedon Jul 14, 2026
@madarkadonk yes, exactly... this is what I've just seen right now. A bit disappointed honestly...
ajg360 commentedon Jul 30, 2026
+1
I am also trying to use Codex (0.146.0) with a local model, and I cannot make MCP tool calls because of this issue either.
It seems like one of the related PRs fixes this, but it was closed before it was merged in? Is there any explicit reason for this?
#29602
oddm643 commentedon Jul 31, 2026
Still waiting for a response to this
metrofun commentedon Aug 2, 2026
I’m the author of Swobu, a local compatibility gateway.
I reproduced this namespace failure and shipped an intermediary workaround in Swobu v1.0.0-rc.4. Swobu projects namespaced MCP tools into backend-compatible function names, keeps an attempt-scoped reverse mapping, and restores the original
{namespace, name}identity before returning the tool call to Codex.I verified the complete path on August 2, 2026 using:
openai/gpt-4.1-miniCodex successfully executed
microsoft_docs/microsoft_docs_searchand returned a grounded Microsoft Learn URL.Install Swobu:
curl -fsSL https://swobu.com/install.sh | shThen point a Codex profile at the configured Swobu workspace:
The Codex-facing client key can be a placeholder; backend credentials remain configured in Swobu.
[fraktal] correct the upstreaming outlook for the MCP flattening patch
jpvelasco commentedon Aug 4, 2026
Additional sanitized reproduction data:
Expected behavior: third-party Responses providers should be able to declare supported tool kinds, or Codex should filter/flatten unsupported tool definitions before sending the request.
lzp401 commentedon Aug 4, 2026
I reproduced this on the current stable CLI with a GLM custom Responses provider. The failure is not specific to Streamable HTTP or to a private MCP server.
Environment
0.146.0wire_api = "responses"codegraph, configured as an enabled STDIO serverControlled reproduction
To avoid sending private repository data to the provider, I created a temporary synthetic Git repository containing only a marker string,
CODEGRAPH_SYNTHETIC_OK.I then ran
codex --profile <glm-profile> execwith:codegraphenabled and approved for read-only tool useBefore the model run,
codex --profile <glm-profile> mcp get codegraphreported the server as enabled withtransport: stdioand the expected command/arguments.Observed model-facing state:
mcp__codegraph__*toolstool_searchlist_mcp_resources/read_mcp_resourcehelpersmcp_tool_callevent was emittedThe relevant feature state in
0.146.0is:This makes the registered STDIO MCP tools unreachable to this custom provider: they are not exposed directly, and the session has no discovery tool with which to load them.
Transport comparison and control
I observed the same missing-tool behavior with a healthy Streamable HTTP MCP server whose
initializeandtools/listcalls succeed, so the failure is not specific to STDIO versus Streamable HTTP.As a compatibility control, I ran Codex
0.136.0with the same GLM provider through a localhost adapter that only:namespacetools into ordinary functions namedmcp__<server>__<tool>, andThat control produced a real MCP tool call and a successful tool result. This is consistent with the
namespace_tools = false/ flattened-dispatch direction proposed in this issue.Expected behavior
For a custom Responses provider, Codex should either:
tool_searchpath for deferred MCP tools, orThe synthetic repository was deleted after the test. No private repository content, internal endpoint, or credential is included in this report.
mdunphy commentedon Aug 8, 2026
A workaround for this issue is to use a proxy to flatten the request and unflatten the response: https://gist.github.com/mdunphy/6c2cf14aefddeb0d627d79c8e5d366cd
(The rewrite_roles() part is not needed for fixing MCP, that was to fix something else)
thesobercoder commentedon Aug 9, 2026
Additional Codex Desktop reproduction through CLIProxyAPI:
list_threads,read_thread, browser tools, and workspace tools.tool_searchpath.This appears to be the same compatibility boundary addressed by closed PR #29602, whose scope explicitly included flattened namespace tools, deferred
tool_searchresults, standalone extension tools, collision handling, and reverse dispatch. It also manifests in Codex Desktop as described in #30523.Is there a replacement for #29602, or can its provider-capability approach be revived? Custom Responses providers need either:
namespace_tools/ client-tool-search capability, orWithout this, custom providers are nominally supported but cannot use the complete Codex Desktop tool surface.
dhar174 commentedon Aug 11, 2026
TaylorHawkes commentedon Sep 17, 2026
Adding a data point from the provider side, plus a server-side option for people who can't run a patched Codex or a local proxy.
Confirmed with codex-cli 0.154.0 against an OpenAI-compatible Responses endpoint: each MCP server arrives as one
{"type":"namespace","name":"mcp__<server>","tools":[...]}entry, and Codex's own sub-agent tools (multi_agent_v1/collaboration) come wrapped the same way. If the backend drops the wrapper, the model never sees the MCP tools. In my first capture the model found the MCP server's script on disk and piped JSON-RPC into it by hand; the answer was right and the MCP server logged zero calls, which is a nasty way for this to hide.Disclosure: I run inferenceapis.com, so the next part is about my endpoint. I implemented the same translation @mdunphy's proxy does, but in the provider's
/v1/responses, so there's nothing to run locally and streaming is preserved:functiontools named<namespace>__<tool>(names over 64 chars are shortened and mapped back);function_callitems Codex replays in the history are flattened the same way;function_callwithnamespace+namerestored, inresponse.output_item.added/doneevents as well as the final response, so Codex's router dispatches it;X-Namespace-Tools: N flattenedso you can see it happened.Tested with a real stdio MCP server whose data the model can't know: the server logged both tool calls and the answer was correct on DeepSeek V4 Flash / V4.1 Flash / V4 Pro, GLM 5.3 / 5.3 Flash, MiniMax M3, Kimi K2.7 Code, GPT-OSS 120B and Qwen3-VL 235B. Sub-agents (
spawn_agent→wait_agent) work through the same fix, and Multi-Agent V2agent_messagehand-offs (#33551) are converted to user messages too.Config is just the provider block, MCP servers unchanged:
Write-up with the captured request/response shapes and the per-model table: https://inferenceapis.com/reference/errors/codex-mcp-tools-unsupported-call-custom-provider?src=gh26234
None of this replaces the fix proposed in this issue: once Codex flattens for non-OpenAI providers itself, flat tools pass straight through unchanged. Happy to share the capture scripts or the MCP test server if useful.