Repository navigation
Description
What issue are you seeing?
mcp_oauth_callback_url is documented and configurable as an optional redirect URI override for MCP OAuth login, but Codex still appends a server-derived callback id to the configured URL before sending it as redirect_uri.
For example, with config overrides equivalent to:
mcp_oauth_callback_port = 10230
mcp_oauth_callback_url = "http://localhost:10230/callback"Codex builds an authorization URL whose redirect_uri is effectively:
http://localhost:10230/callback/<callback_id>
This breaks OAuth providers that require exact redirect URI matching, such as enterprise OIDC/Keycloak clients registered with a fixed localhost callback URL. The provider rejects the request before the authorization-code exchange with an error like:
invalid_request: The requested redirect_uri is missing in the client configuration.
The configured callback URL is valid for the provider, but the mutated URL with the extra path segment is not.
What steps can reproduce the bug?
- Configure a streamable HTTP MCP server that uses OAuth with an OIDC provider whose client has only this redirect URI registered:
http://localhost:10230/callback
- Run MCP login with explicit callback settings:
codex mcp login <server> \
-c mcp_oauth_callback_port=10230 \
-c 'mcp_oauth_callback_url="http://localhost:10230/callback"'- Inspect or open the authorization URL emitted by Codex.
Actual result: the redirect_uri includes an additional server-derived path segment after /callback, so strict OIDC clients reject it.
A small branch that demonstrates the proposed behavior is available here:
Commit:
3560426d05 Respect configured MCP OAuth callback URL
What is the expected behavior?
When mcp_oauth_callback_url is explicitly configured, Codex should use it exactly as the OAuth redirect_uri.
The existing callback-id behavior can remain for generated local redirect URIs, where Codex chooses the listener address and callback path itself. The surprising part is mutating an explicit redirect URI override.
Additional information
This appears to be in codex-rs/rmcp-client/src/perform_oauth_login.rs: resolve_redirect_uri(...) returns the configured callback URL, and then append_callback_id_to_redirect_uri(...) is applied unconditionally.
Suggested high-level fix:
- if
callback_url/mcp_oauth_callback_urlis set, use it as-is; - otherwise keep appending the server-derived callback id to generated local callback URLs.
Local validation of the proposed patch:
cargo fmt -p codex-rmcp-client
cargo test -p codex-rmcp-client callbackEnvironment used while diagnosing:
Codex CLI: codex-cli 0.0.0 local build
Platform: Darwin 25.5.0 arm64 arm
Terminal: Apple Terminal
I read docs/contributing.md and understand unsolicited PRs are not accepted. I am opening this issue first with root-cause analysis and a high-level fix outline; the branch is provided only as a concrete reference if maintainers want it.
Palantir context — October 15, 2026
Related Palantir request: per-plugin fixed callback ports are implemented in merged PR #38448, including oauth.callbackPort in compatibility .mcp.json packages. This is distinct from this ticket’s callback-URL fidelity defect; the PR is not evidence that this ticket is fixed. Palantir’s installed version and authentication retest remain unverified.
Activity
sshishigin commentedon Jun 29, 2026
Related public MCP OAuth reports I found while debugging this:
Dynamic client registration not supported#13200 tracks Slack official MCP / pre-registered OAuth client support. A recent comment there also notes that Codex appends a callback id to configured callback URLs, requiring wildcard redirects.This issue is narrower: even when the OAuth client id and callback port/url are already configurable, is not treated as an exact redirect URI. Fixing that should help the static/pre-registered-client cases where providers require exact redirect URI matching.
sshishigin commentedon Jun 29, 2026
Small correction to my previous comment: the omitted config key in the last paragraph is
mcp_oauth_callback_url.wgu9 commentedon Jun 29, 2026
I checked current
main(80f54d1) and this looks like a precise path-construction mismatch in the MCP OAuth helper.Relevant owner path:
codex-rs/rmcp-client/src/perform_oauth_login.rs.The code currently does both:
resolve_redirect_uri(server, callback_url)returns the configured callback URL as the redirect URIappend_callback_id_to_redirect_uri(redirect_uri, callback_id)appends a server-derived path segment before query paramsThere are tests for appending the callback id and for preserving query placement, but the reported issue is about wanting the configured callback URL to be used as an exact registered redirect URI. If an OAuth provider has strict redirect URI matching, appending
/{callback_id}turns a valid configured URL into a different URI.A conservative fix shape would be to split the concepts:
callback_idRegression test: configure
callback_url = "https://callbacks.example.com/oauth/callback", assert the authorize request uses exactly that URI, and separately assert callback validation still binds the response to the intended MCP server.Poent commentedon Aug 14, 2026
Adding a concrete reproduction against a public hosted MCP server: ElevenLabs Hosted MCP.
Environment
0.147.0-alpha.6.6https://api.us.elevenlabs.io/v1/mcpdee9ba45-a592-4730-a321-a7b90a00c436Configuration:
Login command:
Observed progression
Without the explicit client ID, Codex attempts dynamic client registration and fails because ElevenLabs does not support DCR:
Adding the published client ID correctly bypasses DCR and opens the authorization URL.
Codex sends a loopback redirect shaped like:
The
6MFBM1In3Ey-suffix is exactly the deterministic callback ID Codex derives fromhttps://api.us.elevenlabs.io/v1/mcp.ElevenLabs rejects the request before consent with:
Codex subsequently times out waiting for a callback that the provider never sends.
Working control case
The same ElevenLabs account, endpoint, published client ID, and scopes authenticate successfully through Claude. Claude sends its registered hosted callback:
The ElevenLabs consent screen then opens normally and identifies the OAuth application as “Claude — Official ElevenLabs connector for Claude.”
This confirms the ElevenLabs OAuth service and account are working; the interoperability failure is specific to the redirect URI produced by Codex.
Relevant provider documentation:
Why this issue blocks the integration
ElevenLabs provides a fixed/pre-registered client and no DCR endpoint. Codex can now accept that static client ID, but it unconditionally appends the server-specific callback ID to both generated and explicitly configured callback URLs. Therefore, there is no native Codex configuration that can send an exact pre-registered redirect URI for this integration.
A compatible fix could preserve the callback-ID behavior by default while providing an explicit exact-redirect mode for static/pre-registered OAuth clients, or provide a Codex-hosted callback flow.
This reproduces on a current Codex build, and current
mainstill appears to append the callback ID unconditionally.iKondratiy commentedon Sep 2, 2026
I can confirm a current real-world interoperability case with Codex CLI 0.152.1 and Higgsfield's Blender Bridge (
https://bridge.higgsfield.ai/mcp).Environment:
The latest Higgsfield add-on hard-codes
http://localhost:56444/callback, while Codex uses the server-specific callbackhttp://127.0.0.1:56444/callback/sqXrK_ZgopWE. Higgsfield's upstream Clerk authorization endpoint rejects the latter with:The provider's DCR endpoint accepts and echoes both callback forms, but authorization still rejects them. Its authorization-server metadata does not advertise
authorization_response_iss_parameter_supported: true.The current Codex documentation now explicitly says that Codex appends a server-specific callback ID when issuer-bound responses are not advertised, and that a configured callback without the correct ID is ignored:
https://learn.chatgpt.com/docs/extend/mcp#oauth-client-registration-and-callbacks
So the immediate server-side defect is Higgsfield's DCR/Clerk registration mismatch. However, Codex could make this failure much easier to diagnose. Suggested diagnostic improvement:
/callbackrequiresauthorization_response_iss_parameter_supported: trueplus a matchingissresponse.This preserves Codex's mix-up protection while making provider-side misconfiguration obvious. I am filing the provider-specific issue with Higgsfield separately.
prabhuavula7 commentedon Sep 3, 2026
Hit this exact behavior integrating a production MCP server (Auth0-backed, exact-match callback allowlisting, DCR/CIMD both intentionally disabled) with Codex CLI 0.146.0 and confirmed unchanged on 0.153.0.
Config:
codex mcp logingeneratesredirect_uri=http://127.0.0.1:33418/callback/<callback_id>instead of the configured URL verbatim, exactly as described here. Our authorization server rejects it with a callback URL mismatch since it requires exact registration.One data point that might help triage: the appended
<callback_id>is deterministic, not random — reproduced locally asbase64url(SHA256(<exact MCP server URL string>)[:9]). It's stable acrossmcp remove/mcp addcycles and across the 0.146.0 → 0.153.0 upgrade. We worked around this by pre-registering the full deterministic URL (callback_url+/+ that hash) on our end, which works but obviously depends on an implementation detail rather than the documented contract. Would much rather havecallback_url, when explicitly set, be used verbatim as this issue requests.Happy to share more repro detail if useful.