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.
boolean
Output server list as JSON.

Examples

codex mcp get

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

Examples

codex mcp add

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

For stdio servers:

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

For HTTP servers:

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

Examples

codex mcp remove

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

Examples

codex mcp login

Authenticate with an MCP server using OAuth.
string
required
Name of the MCP server to authenticate with.
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.
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: