Codex CLI MCP Setup: From Zero to Connected

Install your first MCP server, verify the connection and understand where Codex stores its configuration.

terminal
codex mcp add context7 -- npx -y @upstash/context7-mcp
What you will learn

Follow a practical setup path, understand the permission boundary and leave with a configuration you can review and adapt.

01

What you are setting up

Model Context Protocol gives Codex a standard way to discover and call tools supplied by an external server. The server may run locally as a child process or remotely over HTTP.

This walkthrough begins with a local documentation server because it is easy to verify and does not require write access to a production account.

  • Codex acts as the MCP client.
  • The MCP server exposes tools and optional server-wide instructions.
  • Your server entry is stored in Codex configuration.
02

Add a local STDIO server

Run the command below in the environment where Codex CLI is installed. Codex records the server name together with the command used to start it.

terminal / config.toml
codex mcp add context7 -- npx -y @upstash/context7-mcp

Use a short, memorable server name. You will use it later when listing, disabling or removing the connection.

03

Verify server and tool discovery

List configured servers before starting a real task. Then open the Codex terminal interface and inspect the MCP tools available in the active session.

terminal / config.toml
codex mcp list

# Inside the Codex terminal UI
/mcp
  • Confirm that the expected server is enabled.
  • Check that one or more tools were discovered.
  • Run a narrow read-only prompt as the first test.
04

Choose the right configuration scope

User-level MCP settings normally live in ~/.codex/config.toml. A trusted repository can also contain .codex/config.toml when a connection should apply only to that project.

Keep secrets in environment variables or an approved authentication flow instead of writing tokens into a file that may be committed to Git.

05

A safer first-day checklist

Start with one server, one narrow purpose and one read-only test. Add more capability only after you understand the tools the server exposes and the actions those tools can perform.

  • Verify the server publisher and command.
  • Review discovered tool names and descriptions.
  • Require approval for writes.
  • Remove unused connections.
Ready-to-review starter

Download this guide’s configuration.

Review the endpoint, package, credentials and permission settings before using it in a trusted environment.

Download file
Guide FAQs

Frequently asked questions

The common user-level location is ~/.codex/config.toml. Trusted projects can also use .codex/config.toml for project-scoped configuration.

Run codex mcp list, then use /mcp inside the Codex terminal interface to inspect active tools.

Begin with one read-only server. A smaller setup is easier to verify, secure and troubleshoot.

Use official documentation as the source of truth

Provider endpoints, authentication requirements and supported options can change. Confirm current details before connecting a sensitive service.

Open MCP docs