How to give Codex access to a remote server with MCP
Let Codex work on a headless VPS, a home server or a lab machine: no Codex and no API key on that machine, and no open ports.
Why put Codex on a real server, not only the local folder
Codex is good at the code in front of it. Sometimes the answer is on another machine: the log of a service, the state of a deploy, a failing test that only fails on that box. With MCP Desk, Codex gets MCP tools on that machine, so it can look and act there while it stays on your computer.
- No Codex, no sign-in and no API key on the server. Nothing of yours is installed there but one small agent.
- No open ports and no SSH key to hand over: the agent dials out.
- Examples: “Is the web service running? Show the last errors.” “Deploy with my playbook.”
What you need
- Codex on your own computer, with MCP support.
- The server or machine to reach: Linux (x86_64 or aarch64), Windows, macOS or experimental Android.
- An MCP Desk sign-in (Google or Microsoft). MCP Desk is free.
Step 1. Run the agent on the server (including as a service)
Linux (x86_64 and aarch64)
curl -fL -o mcpdeskagent "https://mcpdesk.ai/downloads/latest/mcpdeskagent-linux-$(uname -m)"
chmod +x mcpdeskagent
./mcpdeskagentThe agent goes Online and shows a 9-digit desk code and a one-time code that changes every 10 minutes. Leave it running. Check a download against SHA256SUMS if you want to be sure.
To keep the agent running after a reboot, install it as a systemd service from the same file. It keeps the desk code and mode of the agent you ran:
sudo ./mcpdeskagent install-service
sudo ./mcpdeskagent install-service --mode readonly # choose the mode
sudo ./mcpdeskagent info # desk code, one-time code, linked account The service is named servermcp. Details and the service flags are in the docs.
Step 2. Add MCP Desk to Codex
On your own computer, one line adds the server and signs in:
codex mcp add mcpdesk --url https://mcp.mcpdesk.ai/oauth/mcp && codex mcp login mcpdesk It opens your browser: sign in to MCP Desk and press Allow. The sign-in URL is https://mcp.mcpdesk.ai/oauth/mcp.
Step 3. Link the desk from the chat
Tell Codex “link desk 123 456 789” with your server’s own code. The server then needs an Allow.
Approve on the desk. A prompt shows who wants to link. On a headless server, run mcpdeskagent link approve --wait 120 (add --installed if the agent runs as a service).
The link is permanent until you unlink it: list_desks shows your desks and connect_device needs no codes after that.
Readonly first, then playbooks or full
--mode readonly: Codex only gets the tools that inspect. A good place to start on production.--mode playbooks: inspection plus vetted scripts you wrote.--mode full: everything, including a real command shell. This is the default for an agent you start directly.
--allowed-root limits the file tools to folders you choose; it does not confine shell commands.
Use the MCP Bridge with Codex
Codex is a local client, so the MCP Bridge works with it, and it is the recommended way to connect. It runs in a container on the computer Codex runs on, never on the server. If you have run the bridge line there, Codex already uses the bridge instead of the cloud address.
| Connection | What you install | Who can read the data | connection.mode |
|---|---|---|---|
| Standard MCP | Nothing. Add the sign-in URL to your AI client. The traffic goes through the MCP Desk gateway, encrypted in transit with TLS. | The gateway reads each request to route it, so MCP Desk could, in theory, see the data. Commands and file contents are not stored or logged. | standard |
| MCP Bridge via tunnel | One line on the computer your AI client runs on, never on the remote desk. It runs in a container. | Only your two computers hold the keys. The traffic passes through an MCP Desk tunnel as sealed bytes, and MCP Desk cannot read it. | tunnel |
| MCP Bridge, direct | The same container and the same line. Nothing more to set up. | Only your two computers. The path goes straight between them when the network allows, with no MCP Desk server on it: direct, encrypted end to end. | direct |
To see which one you are on, ask your AI to run sysinfo (the same tool as system_info) and read connection.mode. The bridge starts on the tunnel and moves to the direct connection by itself when the network allows it.
curl -fsSL https://mcpdesk.ai/install.sh | sh irm https://mcpdesk.ai/install.ps1 | iex Restart Codex afterwards. How the bridge works and its limits.
FAQ
Do I need to install Codex on the server?
No. The server runs only the small MCP Desk agent. Codex, your Codex sign-in and any API keys stay on your own computer.
How do I approve a link on a machine with no screen?
Run mcpdeskagent link approve --wait 120 on the server, and add --installed if the agent runs as a service. That is the same Allow that a desktop shows as a prompt.
Can I keep Codex read-only on production?
Yes. Start the agent with --mode readonly and Codex only gets the tools that inspect: system info, files, processes, services and logs. The tools that change the machine are not listed. Use playbooks or full when you trust the plan.
Does Codex work with the MCP Bridge?
Yes. Codex is a local client, so the bridge is recommended. One line on the computer Codex runs on sets it up in a container, never on the server. Neither bridge path lets MCP Desk read the data.
How do I unlink the server later?
Ask Codex to unlink the desk, or run mcpdeskagent link revoke on the server. It returns to code-based access. Stopping the agent ends all access, and uninstall-service removes the service.
Last updated 30 November 2026. Features change; the docs are the reference.