How To - Add MCP Nest to OpenAI Codex CLI
Learn how to configure OpenAI Codex CLI to use your MCP Nest tools.
Add MCP Nest to OpenAI Codex CLI
You can easily use your deployed MCP Nest tools directly within the OpenAI Codex CLI. This requires adding a server configuration to your Codex config file.
Locate your Connection URLs
First, navigate to your configuration dashboard (e.g., https://mcpnest.dev/<YOUR_CONFIG_ID>/dashboard). You will find the connection URLs at the top of the page.
Configuration
-
Open or create your Codex configuration file at
~/.codex/config.toml. -
Add the following configuration block:
[mcp_servers.mcpnest]
command = "npx"
args = ["-y", "mcp-remote", "https://mcp.mcpnest.dev/mcp/<YOUR_CONFIG_ID>"]
Replace <YOUR_CONFIG_ID> with your actual deployment ID from the MCP Nest dashboard.
Authentication Options
Standard OAuth (Interactive)
The configuration above uses the standard URL. When you first run Codex with this configuration, it may prompt you to authenticate via your browser if the client supports the MCP OAuth flow.
Pre-authenticated URLs (Non-interactive)
If you prefer to skip the OAuth flow or need to run in a non-interactive environment, you can use a pre-authenticated URL instead.
To do this, simply append your access token to the URL in the args list:
args = ["-y", "mcp-remote", "https://mcp.mcpnest.dev/mcp/<YOUR_CONFIG_ID>?token=xxx"]
For more details on finding your authenticated URL and why you might want to use it, check out our guide on Using MCPNest without OAuth (pre-authenticated URLs).