Unable to authenticate with MCP server when running in remote environment
Open 💬 4 comments Opened Jan 7, 2026 by WhammyLeaf
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
0.79.0
What subscription do you have?
Own API key
Which model were you using?
gpt-5.1
What platform is your computer?
Linux 5.15.0-305.176.4.el8uek.x86_64 x86_64 x86_64
What issue are you seeing?
We are running the codex CLI tool in a remote codeserver/WebIDE environment. It is impossible to access OAuth protected MCP servers in this environment due to Codex using localhost as callback URI: the localhost will point to the machine that the user is on, not the machine that codex is running on.
What steps can reproduce the bug?
- Setup a codeserver/WebIDE environment.
- Define config for an OAuth protected MCP server in
config.toml - try to authenticate with codex mcp login [NAME]
- new tab opens in browser window
- but OH NO: "This site can’t be reached"
What is the expected behavior?
New tab in browser should indicate successful authentication and when going back to codeserver tab, the MCP server authentication process in the terminal should be completed.
Additional information
_No response_
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I guess a similar solution as what was used to support https://github.com/openai/codex/issues/2798 could be applied here. This would also be very useful for running in other headless environments, such as containers.
@janEbert @eric-oai What exactly is the solution? Actually, the current functionality almost supports authenticating with oauth protected mcp servers in a webide. There is just one technicality which needs to be handled. I explain it here: https://github.com/openai/codex/issues/24058
Hey, quoting from the linked issue, because it summarizes the solution well:
As another option, Claude Code, for example, also redirects to a local server, but you can just paste the redirect URL into Claude Code to finish authentication. So even if you can't reach the local exchange server the URL points to, as long as you got correctly redirected to the URL (again, from an external auth provider), you can still authenticate.