Skip to content

Craft Anything: understand how any software works, and craft your own.

Rust

Make all permitted tools available to Codex from startup (#805)

Agapenor98d12f23a016
diff --git a/crates/ai/src/cli_agents/adapters.rs b/crates/ai/src/cli_agents/adapters.rs
index 7f3f0502..0992cc8b 100644
--- a/crates/ai/src/cli_agents/adapters.rs
+++ b/crates/ai/src/cli_agents/adapters.rs
@@ -735,7 +735,13 @@ impl AgentAdapter for Codex {
v.extend(["--sandbox".into(), "workspace-write".into()]);
}
v.extend(["-c".into(), format!("mcp_servers.{MCP_NAME}.command={}", toml_string(&cx.mcp.command))]);
- let args_toml = format!("[{}]", cx.mcp.args.iter().map(|s| toml_string(s)).collect::<Vec<_>>().join(", "));
+ // Codex doesn't refresh its callable tools after enable_toolset (#538), so list every
+ // permitted tool from startup. The server still applies Clean room's restrictions.
+ let mut mcp_args = cx.mcp.args.clone();
+ if !mcp_args.iter().any(|a| a == "--all-tools") {
+ mcp_args.push("--all-tools".into());
+ }
+ let args_toml = format!("[{}]", mcp_args.iter().map(|s| toml_string(s)).collect::<Vec<_>>().join(", "));
v.extend(["-c".into(), format!("mcp_servers.{MCP_NAME}.args={args_toml}")]);
// `codex exec` can't ask, so without this it refuses a tool not marked read-only, such as
// rebuild_start, before our server sees the call (#540). Only tools that ask the person
diff --git a/crates/ai/src/cli_agents/mod.rs b/crates/ai/src/cli_agents/mod.rs
index 52e9aeb7..c006df65 100644
--- a/crates/ai/src/cli_agents/mod.rs
+++ b/crates/ai/src/cli_agents/mod.rs
@@ -1467,7 +1467,14 @@ mod tests {
let o = BackendOptions { args: vec!["--skip-git-repo-check".into()], ..Default::default() };
assert_eq!(skip(&build_args(adapter_for("codex").as_ref(), &o, "q", "P:", &mcp(), None, Access::Build)), 1);
assert!(a.contains(&"mcp_servers.craft-anything.command=\"/opt/ca/craft-anything-cli\"".to_string()));
- assert!(a.contains(&"mcp_servers.craft-anything.args=[\"mcp\", \"--project\", \"/p/x.cany\"]".to_string()));
+ // #538: Codex doesn't refresh its callable tools after enable_toolset, so list all permitted
+ // tools from startup. Clean room still filters what the server lists and allows.
+ assert!(a.contains(&"mcp_servers.craft-anything.args=[\"mcp\", \"--project\", \"/p/x.cany\", \"--all-tools\"]".to_string()));
+ let mut already_all = mcp();
+ already_all.args.push("--all-tools".into());
+ let deep = build_args(adapter_for("codex").as_ref(), &BackendOptions::default(), "q", "P:", &already_all, None, Access::Build);
+ let args = deep.iter().find(|a| a.starts_with("mcp_servers.craft-anything.args=")).unwrap();
+ assert_eq!(args.matches("--all-tools").count(), 1, "a Deep build already lists every tool");
// #528: the message goes in on stdin; `-` tells `codex exec` to read it there.
assert_eq!(a.last().unwrap(), "-");
// #540: `codex exec` can't ask, so the tools that ask for themselves are approved in the
@@ -1494,7 +1501,7 @@ mod tests {
assert!(a.contains(&"--skip-git-repo-check".to_string()));
assert!(a.windows(2).any(|w| w[0] == "--sandbox" && w[1] == "workspace-write"));
assert!(a.contains(&"mcp_servers.craft-anything.command=\"/opt/ca/craft-anything-cli\"".to_string()));
- assert!(a.contains(&"mcp_servers.craft-anything.args=[\"mcp\", \"--project\", \"/p/x.cany\"]".to_string()));
+ assert!(a.contains(&"mcp_servers.craft-anything.args=[\"mcp\", \"--project\", \"/p/x.cany\", \"--all-tools\"]".to_string()));
}
#[test]
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md
index be244d10..a757b665 100644
--- a/docs/ROADMAP.md
+++ b/docs/ROADMAP.md
@@ -506,9 +506,10 @@ Owner: open · Status: in progress
- [x] Aider has no adapter, so the plain one hands it the prompt as a file name, and it can open a
browser sign-in nobody agreed to (#72). Give it an adapter, or stop offering it — claimed: Afloat16, branch bugfix/r2.2-aider-recommendations-20261103
- [ ] Add a non-interactive Aider adapter before recommending it again; detection currently leaves it out.
-- [ ] Codex (#499): in a chat the tool server has no active target, tools turned on with
- `enable_toolset` can't be called, The
- reporter attached a patch for chat continuity; look at that first
+- [ ] Codex (#499): in a chat the tool server has no active target. The reporter attached a patch
+ for chat continuity; look at that first
+- [x] Codex (#538): list every permitted tool from startup, since Codex doesn't refresh its callable
+ list after `enable_toolset` changes it — PR #805
- [x] Codex (#540): `rebuild_start` was refused by `codex exec`'s approval policy and showed as
`null`; setup and the builder now approve our tools for Codex (we still ask before running
code) and a refusal explains the fix (`docs/codex.md`)
diff --git a/docs/STATUS.md b/docs/STATUS.md
index 6769bc2e..d9a5263a 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -249,7 +249,9 @@ laptops are covered by unit tests on fake `/sys/class/drm` folders only.
that would ask (an MCP server's tools, in subagents too) unless the person allowed it in Maki's
own permissions. It hasn't been run as a `maki -p` builder here.
- Claude Code is fully wired as a builder; Codex works through its own flags (our tools are pre-approved for
- `codex exec`, see `docs/codex.md`) but is unverified on a real install and doesn't resume;
+ `codex exec` and every tool permitted by the current mode is listed from startup, see `docs/codex.md`)
+ but doesn't resume. Codex 0.166.0 received the full Clean room inventory through a loopback model;
+ no real-account build has been run;
Copilot builds, model discovery and real-account session
resume were confirmed by the person using the app. Other agent programs
without an adapter get plain text in and out. API-key
diff --git a/docs/codex.md b/docs/codex.md
index 25480f76..b43a4f89 100644
--- a/docs/codex.md
+++ b/docs/codex.md
@@ -33,7 +33,9 @@ asks for consent). Every other tool keeps whatever approval policy you set in Co
`craft-anything-cli doctor --client codex` reports an entry without the approval as "a different
copy or shape of the command"; running setup again fixes it.
- **Building with Codex from the app** starts `codex exec` with the same setting on its `-c`
- flags, so nothing in your config is needed.
+ flags, so nothing in your config is needed. Chats and builds also start the Craft Anything MCP
+ server with `--all-tools`: Codex doesn't refresh its callable tool list after `enable_toolset`,
+ so every tool permitted by the current mode is listed from startup. Clean room restrictions still apply.
## Who still asks
@@ -59,5 +61,6 @@ again. Approving all of them (`default_tools_approval_mode = "approve"`) also ap
no consent check of their own, such as `project_inbox_answer`, which can answer a pending approval,
so we don't do it.
-Not yet verified on a real Codex install (this was written from Codex's published configuration
-keys, tested with stand-in output).
+Startup tool discovery was verified with Codex CLI 0.166.0, a loopback model and the real MCP server:
+Codex received 107 Clean-room-permitted tools, including non-Core tools, while Deep-only tools stayed
+hidden. No real-account build was run.