Commit Graph

1438 Commits

Author SHA1 Message Date
Michael Bolin
d97cc8ec8c feat: show MCP tool calls in TUI 2025-05-06 15:54:59 -07:00
Michael Bolin
147a940449 feat: support mcp_servers in config.toml (#829)
This adds initial support for MCP servers in the style of Claude Desktop
and Cursor. Note this PR is the bare minimum to get things working end
to end: all configured MCP servers are launched every time Codex is run,
there is no recovery for MCP servers that crash, etc.

(Also, I took some shortcuts to change some fields of `Session` to be
`pub(crate)`, which also means there are circular deps between
`codex.rs` and `mcp_tool_call.rs`, but I will clean that up in a
subsequent PR.)

`codex-rs/README.md` is updated as part of this PR to explain how to use
this feature. There is a bit of plumbing to route the new settings from
`Config` to the business logic in `codex.rs`. The most significant
chunks for new code are in `mcp_connection_manager.rs` (which defines
the `McpConnectionManager` struct) and `mcp_tool_call.rs`, which is
responsible for tool calls.

This PR also introduces new `McpToolCallBegin` and `McpToolCallEnd`
event types to the protocol, but does not add any handlers for them.
(See https://github.com/openai/codex/pull/836 for initial usage.)

To test, I added the following to my `~/.codex/config.toml`:

```toml
# Local build of https://github.com/hideya/mcp-server-weather-js
[mcp_servers.weather]
command = "/Users/mbolin/code/mcp-server-weather-js/dist/index.js"
args = []
```

And then I ran the following:

```
codex-rs$ cargo run --bin codex exec 'what is the weather in san francisco'
[2025-05-06T22:40:05] Task started: 1
[2025-05-06T22:40:18] Agent message: Here’s the latest National Weather Service forecast for San Francisco (downtown, near 37.77° N, 122.42° W):

This Afternoon (Tue):
• Sunny, high near 69 °F
• West-southwest wind around 12 mph

Tonight:
• Partly cloudy, low around 52 °F
• SW wind 7–10 mph
...
```

Note that Codex itself is not able to make network calls, so it would
not normally be able to get live weather information like this. However,
the weather MCP is [currently] not run under the Codex sandbox, so it is
able to hit `api.weather.gov` and fetch current weather information.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/829).
* #836
* __->__ #829
2025-05-06 15:47:59 -07:00
Michael Bolin
e6af355312 merge commit for archive created by Sapling 2025-05-06 15:38:56 -07:00
Michael Bolin
e9b4217ea1 feat: show MCP tool calls in TUI 2025-05-06 15:38:51 -07:00
Michael Bolin
54e382e2a9 feat: support mcp_servers in config.toml 2025-05-06 15:38:51 -07:00
Michael Bolin
00dd6fe2e1 merge commit for archive created by Sapling 2025-05-06 15:37:28 -07:00
Michael Bolin
8ed9aff351 feat: show MCP tool calls in TUI 2025-05-06 15:37:23 -07:00
Michael Bolin
007c0a3984 feat: support mcp_servers in config.toml 2025-05-06 15:37:23 -07:00
Michael Bolin
ff52475646 merge commit for archive created by Sapling 2025-05-06 15:36:22 -07:00
Michael Bolin
e812b4ffeb feat: show MCP tool calls in TUI 2025-05-06 15:36:17 -07:00
Michael Bolin
9f6c4c5167 feat: support mcp_servers in config.toml 2025-05-06 15:36:17 -07:00
Michael Bolin
9ac3c96671 merge commit for archive created by Sapling 2025-05-06 15:25:46 -07:00
Michael Bolin
1d5bfb96a8 feat: show MCP tool calls in TUI 2025-05-06 15:25:40 -07:00
Michael Bolin
851afb5366 feat: support mcp_servers in config.toml 2025-05-06 15:25:40 -07:00
Michael Bolin
bb3775e451 merge commit for archive created by Sapling 2025-05-06 15:24:42 -07:00
Michael Bolin
4a6f2aa574 feat: show MCP tool calls in TUI 2025-05-06 15:24:35 -07:00
Michael Bolin
4917413b73 feat: support mcp_servers in config.toml 2025-05-06 15:24:35 -07:00
Michael Bolin
53deb3f16b merge commit for archive created by Sapling 2025-05-06 15:17:24 -07:00
Michael Bolin
306219c1d1 feat: show MCP tool calls in TUI 2025-05-06 15:17:18 -07:00
Michael Bolin
a0a79fa3a5 feat: support mcp_servers in config.toml 2025-05-06 15:17:18 -07:00
Michael Bolin
3dd7140148 merge commit for archive created by Sapling 2025-05-06 15:13:08 -07:00
Michael Bolin
c9f5d3e9b2 feat: show MCP tool calls in TUI 2025-05-06 15:13:02 -07:00
Michael Bolin
14c37c20eb merge commit for archive created by Sapling 2025-05-06 15:12:46 -07:00
Michael Bolin
c443dcb4d9 feat: support mcp_servers in config.toml 2025-05-06 15:12:40 -07:00
Michael Bolin
1068433c04 feat: show MCP tool calls in TUI 2025-05-06 15:12:40 -07:00
Michael Bolin
a2ba35b720 merge commit for archive created by Sapling 2025-05-06 15:08:28 -07:00
Michael Bolin
550f674ca2 feat: show MCP tool calls in TUI 2025-05-06 15:08:17 -07:00
Michael Bolin
b103e58895 feat: support mcp_servers in config.toml 2025-05-06 15:08:17 -07:00
Michael Bolin
b06a148fd0 merge commit for archive created by Sapling 2025-05-06 15:02:33 -07:00
Michael Bolin
4cdb8613b7 feat: show MCP tool calls in TUI 2025-05-06 15:02:25 -07:00
Michael Bolin
4d92c12cf4 feat: support mcp_servers in config.toml 2025-05-06 15:02:24 -07:00
Michael Bolin
4f473048be merge commit for archive created by Sapling 2025-05-06 14:53:17 -07:00
Michael Bolin
d0a643ec16 feat: show MCP tool calls in TUI 2025-05-06 14:53:06 -07:00
Michael Bolin
56a5d4315f feat: support mcp_servers in config.toml 2025-05-06 14:52:42 -07:00
Michael Bolin
2736cbe80a merge commit for archive created by Sapling 2025-05-06 14:09:45 -07:00
Michael Bolin
b17c5c9f06 feat: show MCP tool calls in TUI 2025-05-06 14:09:34 -07:00
Michael Bolin
a4e59988db feat: support mcp_servers in config.toml 2025-05-06 14:09:34 -07:00
Michael Bolin
2ba60d75b9 merge commit for archive created by Sapling 2025-05-06 14:08:41 -07:00
Michael Bolin
15243bd2b3 feat: show MCP tool calls in TUI 2025-05-06 14:08:31 -07:00
Michael Bolin
a14e109f26 feat: support mcp_servers in config.toml 2025-05-06 14:08:31 -07:00
Michael Bolin
d90e715f73 merge commit for archive created by Sapling 2025-05-06 14:07:34 -07:00
Michael Bolin
6f15edfc61 feat: show MCP tool calls in TUI 2025-05-06 14:07:26 -07:00
Michael Bolin
5ff4707b71 feat: support mcp_servers in config.toml 2025-05-06 14:07:26 -07:00
Michael Bolin
a885ccc005 merge commit for archive created by Sapling 2025-05-06 14:06:19 -07:00
Michael Bolin
bf7421637f feat: show MCP tool calls in TUI 2025-05-06 14:06:08 -07:00
Michael Bolin
69edf7a34e feat: support mcp_servers in config.toml 2025-05-06 12:38:30 -07:00
Michael Bolin
2456db8c12 merge commit for archive created by Sapling 2025-05-06 12:37:04 -07:00
Michael Bolin
f92ffdc74f feat: support mcp_servers in config.toml 2025-05-06 12:36:57 -07:00
Michael Bolin
1c2cd732d1 Merge 63552c01d8 into sapling-pr-archive-bolinfest 2025-05-06 12:03:00 -07:00
Michael Bolin
63552c01d8 feat: support mcp_servers in config.toml 2025-05-06 12:02:54 -07:00