Skip to main content

Syntax

Description

The mcp command manages external MCP servers that extend Codex’s capabilities. MCP servers can provide additional tools, data sources, and integrations.

Subcommands

  • list - List configured MCP servers
  • get - Show details for a specific server
  • add - Add a new MCP server
  • remove - Remove an MCP server
  • login - Authenticate with an MCP server (OAuth)
  • logout - Remove MCP server credentials

codex mcp list

List all configured MCP servers.
--json
boolean
Output server list as JSON.

Examples

codex mcp get

Show detailed configuration for a specific MCP server.
NAME
string
required
Name of the MCP server to display.
--json
boolean
Output server details as JSON.

Examples

codex mcp add

Add a new MCP server configuration.
NAME
string
required
Name for the MCP server. Must contain only letters, numbers, hyphens, and underscores.

For stdio servers:

COMMAND
string
required
Command to launch the MCP server.
--env
string
Environment variables in KEY=VALUE format (repeatable).

For HTTP servers:

--url
string
required
URL for a streamable HTTP MCP server.
--bearer-token-env-var
string
Environment variable name containing a bearer token for authentication.

Examples

codex mcp remove

Remove an MCP server configuration.
NAME
string
required
Name of the MCP server to remove.

Examples

codex mcp login

Authenticate with an MCP server using OAuth.
NAME
string
required
Name of the MCP server to authenticate with.
--scopes
string
Comma-separated list of OAuth scopes to request.
OAuth login is only supported for streamable HTTP servers.

Examples

codex mcp logout

Remove OAuth credentials for an MCP server.
NAME
string
required
Name of the MCP server to deauthenticate.

Examples

Configuration

MCP servers are stored in ~/.codex/config.toml:

MCP Server Types

stdio Servers

Local servers that communicate via stdin/stdout:
Use cases:
  • Local tools and utilities
  • File system access
  • Development and testing

Streamable HTTP Servers

Remote servers over HTTP:
Use cases:
  • Cloud services
  • Shared team tools
  • OAuth-authenticated APIs

Troubleshooting

Server Won’t Start

Check server configuration:
Verify command is executable:

Environment Variables Not Set

Ensure environment variables are available:
Or set in config.toml:

OAuth Issues

For OAuth authentication problems:
  1. Verify server supports OAuth:
  2. Check credentials:
  3. Re-authenticate: