Birta
← Back to blog

· Max Krou, Founder Birta

Codex MCP: Add a Server With One Command or config.toml

How to add an MCP server to OpenAI Codex: codex mcp add for local and remote servers, the config.toml entry, OAuth sign-in, plugins, and fixes for servers that fail.

Codex MCP: Add a Server With One Command or config.toml

Codex supports MCP in the CLI, the desktop app and the IDE extension, and all three read the same configuration. Add a local server with codex mcp add <name> -- <command>, a remote one with codex mcp add <name> --url <url>, sign in with codex mcp login <name>, and check it with /mcp inside Codex. Everything lands in ~/.codex/config.toml.

  1. Step 1AddOne codex mcp add
  2. Step 2Sign incodex mcp login
  3. Step 3UseAsk for the result

What MCP gives Codex

MCP, the Model Context Protocol, lets Codex reach tools outside the repository: an issue tracker, a database, a browser, a publishing service. Each server exposes named tools, and Codex calls them when a task needs them. What MCP is, in plain terms; the same job in Claude Code is one claude mcp add. Which servers are worth adding, and how many tokens each one's tools take, is in our MCP server list.

Add a remote server

A hosted service runs its server over streamable HTTP. Give it a name and the address:

codex mcp add sentry --url https://mcp.sentry.dev/mcp

If the server signs in through the browser, Codex runs OAuth. If it takes an API key, keep the key in an environment variable and name the variable, not the key:

codex mcp add my-api --url https://api.example.com/mcp --bearer-token-env-var MY_API_TOKEN

Add a local server

A local server is a program Codex starts over stdio. Everything after -- is the command; --env sets its environment:

codex mcp add context7 -- npx -y @upstash/context7-mcp
codex mcp add airtable --env AIRTABLE_API_KEY=your_key -- npx -y airtable-mcp-server

The config.toml entry

codex mcp add writes a table into ~/.codex/config.toml. You can write it by hand instead, and that is where you tune a server:

[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
startup_timeout_sec = 20   # default 10
tool_timeout_sec = 120     # default 60

[mcp_servers.my-api]
url = "https://api.example.com/mcp"
bearer_token_env_var = "MY_API_TOKEN"
enabled_tools = ["search", "fetch"]

A local server takes command, args, env and cwd. A remote one takes url, bearer_token_env_var and http_headers. Any server takes enabled = false to switch it off without deleting it, and enabled_tools or disabled_tools to narrow what Codex can call. A project can keep its own servers in .codex/config.toml at the repository root; Codex reads it only in projects you have marked as trusted.

Sign in and check it

For a server with browser sign-in, run:

codex mcp login sentry

Codex opens the sign-in page and keeps the token itself, outside the repository. codex mcp list shows every configured server, codex mcp get <name> one of them, and /mcp inside a Codex session lists the servers that started and their tools. codex mcp logout and codex mcp remove undo the two steps.

Servers that come in a plugin

A plugin bundles MCP servers with skills, the instructions that tell Codex how to use them. One install adds both:

codex plugin marketplace add birtadev/plugins
codex plugin add birta@birta

/plugins in the CLI opens the same catalogue. Plugins work in the CLI and the desktop app; the IDE extension does not load them, so add the server by hand there. Which other plugins are worth adding, and what each puts into every session, is in the Codex plugins guide.

A worked example: Birta

Birta's server publishes what Codex makes: a page, a report, a whole site, at a link people open and leave remarks on. Install the plugin with the two commands above, then sign in:

codex mcp login birta

Enter the code sent to your email and allow access; there is no key to paste. Start Codex and ask:

Prompt for Codex

Read this repository's README and make a one-page overview of the project: what it does, how to run it, what is in progress. Publish it on Birta and send me the link.

The answer ends with a birta.link address. Open it, leave a remark on a paragraph, and ask Codex to work the remarks: the next version goes to the same link. In the IDE extension, or without plugins, the server goes in by hand:

codex mcp add birta --url https://birta.dev/mcp
codex mcp login birta

That route skips the skills, so pages come out plainer. For a full site the steps are in deploying a website with Codex.

When a server does not start

  • Not in /mcp. Check codex mcp list. A server in .codex/config.toml loads only in a trusted project; move it to ~/.codex/config.toml or trust the project.
  • Remote server refuses calls. Run codex mcp login <name> again; the token may have expired.
  • Local server fails at start. Run its command yourself in a terminal: a missing package or variable shows up there.
  • Timed out. Raise startup_timeout_sec for a slow start, tool_timeout_sec for a slow tool.
  • Too many tools. Each server adds its tool list to the context. Narrow it with enabled_tools, or set enabled = false on servers you are not using.

A server acts with your permission: connect those you have a reason to trust.

Add Birta to Codex

One install adds the server and the skills; Codex publishes what it makes at a link people comment on.

Get the Birta plugin

Frequently asked questions