MCP & tools7 min read

Configure MCP in Codex: HTTP, local servers, and connection checks

Distinguish HTTP from STDIO, configure authentication, discover tools, and validate one small call before expanding access.

Identify the transport first

MCP provides tools and external information; it is separate from the model API. A service URL usually means Streamable HTTP. An executable plus arguments means STDIO. Do not use a website homepage or model Base URL as an MCP endpoint.

Start with one HTTP connection

~/.codex/config.toml · replace the service address
[mcp_servers.team_docs]
url = "https://mcp.example.com/mcp"
bearer_token_env_var = "TEAM_DOCS_TOKEN"
enabled = true

The address is a placeholder. Remove bearer_token_env_var if the service does not use bearer authentication. For OAuth-enabled services, run codex mcp login team_docs. MCP credentials and model-provider credentials serve different purposes.

Inspect connections and locally supported commands
codex mcp list
codex mcp --help

STDIO depends on the launch environment

Local server example · replace with an installed executable
[mcp_servers.local_docs]
command = "/absolute/path/to/your-mcp-server"
args = ["--stdio"]
env_vars = ["TEAM_DOCS_TOKEN"]
startup_timeout_sec = 20

This does not install a server. Use a trusted installed executable and its actual arguments. A command available in a terminal may be missing from the graphical client’s PATH; an absolute path can make that distinction clearer.

Verify tool discovery and one call

  1. Save the configuration and reconnect. Use the client’s Restart control when available, or start a fresh CLI session.
  2. Check configured servers with codex mcp list and session tools with /mcp.
  3. Request one read-only operation, such as retrieving a public document title, naming the intended service.
  4. Confirm the result came from the tool and match it against the service request, rather than accepting a memory-based answer.

Diagnose the failing stage

StageCheck
Process startupExecutable path, arguments, runtime, and environment
HTTP 401 / 403MCP token, OAuth state, and service permissions
Connection timeoutEndpoint, network, proxy, and service availability
Missing toolsServer tool list and enabled_tools / disabled_tools
Tool timeoutOperation duration and tool_timeout_sec

startup_timeout_sec and tool_timeout_sec address different stages. Raise a limit only when the service genuinely needs more time; longer waits do not repair a bad endpoint.

Expand deliberately

If using enabled_tools, copy actual tool names exposed by the server. Set enabled = false to disable a connection without deleting your configuration. A read-only local filesystem does not automatically make remote MCP tools read-only. Continue with permissions and approvals or the configuration library.

Sources and version notes

Based on the official documentation below. Replace example URLs, models, and paths for your environment. Older versions and managed environments may differ.

Sources checked:

More guides

Put your configuration to work

Generate a configuration, follow the setup flow, or diagnose the next issue.

Client + CLI setupOpen configuration tools