Skip to content

Commit 721003c

Browse files
authored
[MCP] Improve docs (#4811)
Updated, expanded on, clarified, and deduplicated some MCP docs
1 parent 36f1cca commit 721003c

File tree

5 files changed

+48
-22
lines changed

5 files changed

+48
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ You can also use Codex with an API key, but this requires [additional setup](./d
6161

6262
### Model Context Protocol (MCP)
6363

64-
Codex CLI supports [MCP servers](./docs/advanced.md#model-context-protocol-mcp). Enable by adding an `mcp_servers` section to your `~/.codex/config.toml`.
64+
Codex can access MCP servers. To configure them, refer to the [config docs](./docs/config.md#mcp_servers).
6565

6666
### Configuration
6767

codex-rs/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ Codex supports a rich set of configuration options. Note that the Rust CLI uses
2323

2424
### Model Context Protocol Support
2525

26-
Codex CLI functions as an MCP client that can connect to MCP servers on startup. See the [`mcp_servers`](../docs/config.md#mcp_servers) section in the configuration documentation for details.
26+
#### MCP client
2727

28-
It is still experimental, but you can also launch Codex as an MCP _server_ by running `codex mcp-server`. Use the [`@modelcontextprotocol/inspector`](https://github.com/modelcontextprotocol/inspector) to try it out:
28+
Codex CLI functions as an MCP client that allows the Codex CLI and IDE extension to connect to MCP servers on startup. See the [`configuration documentation`](../docs/config.md#mcp_servers) for details.
29+
30+
#### MCP server (experimental)
31+
32+
Codex can be launched as an MCP _server_ by running `codex mcp-server`. This allows _other_ MCP clients to use Codex as a tool for another agent.
33+
34+
Use the [`@modelcontextprotocol/inspector`](https://github.com/modelcontextprotocol/inspector) to try it out:
2935

3036
```shell
3137
npx @modelcontextprotocol/inspector codex mcp-server

codex-rs/docs/codex_mcp_interface.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Codex MCP Interface [experimental]
1+
# Codex MCP Server Interface [experimental]
22

3-
This document describes Codex’s experimental MCP interface: a JSON‑RPC API that runs over the Model Context Protocol (MCP) transport to control a local Codex engine.
3+
This document describes Codex’s experimental MCP server interface: a JSON‑RPC API that runs over the Model Context Protocol (MCP) transport to control a local Codex engine.
44

55
- Status: experimental and subject to change without notice
66
- Server binary: `codex mcp-server` (or `codex-mcp-server`)

docs/advanced.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@ See the Rust documentation on [`RUST_LOG`](https://docs.rs/env_logger/latest/env
1616

1717
## Model Context Protocol (MCP)
1818

19-
The Codex CLI can be configured to leverage MCP servers by defining an [`mcp_servers`](./config.md#mcp_servers) section in `~/.codex/config.toml`. It is intended to mirror how tools such as Claude and Cursor define `mcpServers` in their respective JSON config files, though the Codex format is slightly different since it uses TOML rather than JSON, e.g.:
20-
21-
```toml
22-
# IMPORTANT: the top-level key is `mcp_servers` rather than `mcpServers`.
23-
[mcp_servers.server-name]
24-
command = "npx"
25-
args = ["-y", "mcp-server"]
26-
env = { "API_KEY" = "value" }
27-
```
19+
The Codex CLI and IDE extension is a MCP client which means that it can be configured to connect to MCP servers. For more information, refer to the [`config docs`](./config.md#connecting-to-mcp-servers).
2820

2921
## Using Codex as an MCP Server
3022

docs/config.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,40 +335,47 @@ Codex provides three main Approval Presets:
335335

336336
You can further customize how Codex runs at the command line using the `--ask-for-approval` and `--sandbox` options.
337337

338-
## MCP Servers
338+
## Connecting to MCP servers
339339

340-
You can configure Codex to use [MCP servers](https://modelcontextprotocol.io/about) to give Codex access to external applications, resources, or services such as [Playwright](https://github.com/microsoft/playwright-mcp), [Figma](https://www.figma.com/blog/design-context-everywhere-you-build/), [documentation](https://context7.com/), and [more](https://github.com/mcp?utm_source=blog-source&utm_campaign=mcp-registry-server-launch-2025).
340+
You can configure Codex to use [MCP servers](https://modelcontextprotocol.io/about) to give Codex access to external applications, resources, or services.
341341

342-
### Server transport configuration
342+
### Server configuration
343343

344344
#### STDIO
345345

346+
[STDIO servers](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#stdio) are MCP servers that you can launch directly via commands on your computer.
347+
346348
```toml
347349
# The top-level table name must be `mcp_servers`
348350
# The sub-table name (`server-name` in this example) can be anything you would like.
349-
[mcp_servers.server-name]
351+
[mcp_servers.server_name]
350352
command = "npx"
351353
# Optional
352354
args = ["-y", "mcp-server"]
353355
# Optional: propagate additional env vars to the MVP server.
354356
# A default whitelist of env vars will be propagated to the MCP server.
355357
# https://github.com/openai/codex/blob/main/codex-rs/rmcp-client/src/utils.rs#L82
356358
env = { "API_KEY" = "value" }
359+
# or
360+
[mcp_servers.server_name.env]
361+
API_KEY = "value"
357362
```
358363

359364
#### Streamable HTTP
360365

366+
[Streamable HTTP servers](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) enable Codex to talk to resources that are accessed via a http url (either on localhost or another domain).
367+
361368
```toml
362369
# Streamable HTTP requires the experimental rmcp client
363370
experimental_use_rmcp_client = true
364371
[mcp_servers.figma]
365-
url = "http://127.0.0.1:3845/mcp"
372+
url = "https://mcp.linear.app/mcp"
366373
# Optional bearer token to be passed into an `Authorization: Bearer <token>` header
367-
# Use this with caution because the token is in plaintext.
374+
# Use this with caution because the token is in plaintext and can be read by Codex itself.
368375
bearer_token = "<token>"
369376
```
370377

371-
Refer to the MCP CLI commands for oauth login
378+
For oauth login, you must enable `experimental_use_rmcp_client = true` and then run `codex mcp login server_name`
372379

373380
### Other configuration options
374381

@@ -381,17 +388,25 @@ tool_timeout_sec = 30
381388

382389
### Experimental RMCP client
383390

384-
Codex is transitioning to the [official Rust MCP SDK](https://github.com/modelcontextprotocol/rust-sdk) and new functionality such as streamable http servers will only work with the new client.
391+
Codex is transitioning to the [official Rust MCP SDK](https://github.com/modelcontextprotocol/rust-sdk).
392+
393+
The flag enabled OAuth support for streamable HTTP servers and uses a new STDIO client implementation.
385394

386395
Please try and report issues with the new client. To enable it, add this to the top level of your `config.toml`
387396

388397
```toml
389398
experimental_use_rmcp_client = true
399+
400+
[mcp_servers.server_name]
401+
390402
```
391403

392404
### MCP CLI commands
393405

394406
```shell
407+
# List all available commands
408+
codex mcp --help
409+
395410
# Add a server (env can be repeated; `--` separates the launcher command)
396411
codex mcp add docs -- docs-server --port 4000
397412

@@ -413,6 +428,19 @@ codex mcp login SERVER_NAME
413428
codex mcp logout SERVER_NAME
414429
```
415430

431+
## Examples of useful MCPs
432+
433+
There is an ever growing list of useful MCP servers that can be helpful while you are working with Codex.
434+
435+
Some of the most common MCPs we've seen are:
436+
437+
- [Context7](https://github.com/upstash/context7) — connect to a wide range of up-to-date developer documentation
438+
- Figma [Local](https://developers.figma.com/docs/figma-mcp-server/local-server-installation/) and [Remote](https://developers.figma.com/docs/figma-mcp-server/remote-server-installation/) - access to your Figma designs
439+
- [Playwright](https://www.npmjs.com/package/@playwright/mcp) - control and inspect a browser using Playwright
440+
- [Chrome Developer Tools](https://github.com/ChromeDevTools/chrome-devtools-mcp/) — control and inspect a Chrome browser
441+
- [Sentry](https://docs.sentry.io/product/sentry-mcp/#codex) — access to your Sentry logs
442+
- [GitHub](https://github.com/github/github-mcp-server) — Control over your GitHub account beyond what git allows (like controlling PRs, issues, etc.)
443+
416444
## shell_environment_policy
417445

418446
Codex spawns subprocesses (e.g. when executing a `local_shell` tool-call suggested by the assistant). By default it now passes **your full environment** to those subprocesses. You can tune this behavior via the **`shell_environment_policy`** block in `config.toml`:

0 commit comments

Comments
 (0)