mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Separate MCP sandbox policy from launcher metadata (#53709)
## Why MCP servers must forward sandbox policy unchanged to `codex sandbox --sandbox-state-json`, while interpreting launcher information to find the Codex CLI. Keep those contracts separate so consumers can preserve unknown policy fields. ## What changed - Accept the experimental `codex/sandbox-state` capability alongside the deprecated `codex/sandbox-state-meta` capability, and send identical policy values under both `_meta` keys. - Move `codexExecutable` out of the policy into `codex/sandbox-launcher`, supplied only when a verified CLI path is available for a local stdio server. - Replace stale sandbox metadata while retaining unrelated entries, and remove stale launcher metadata when no launcher is available. - Document the metadata contract and how servers should forward policy and retain authority for long-lived subprocesses. ## Testing Update unit and integration coverage for policy serialization, identical state aliases, launcher availability across execution environments, and stale metadata replacement. GitOrigin-RevId: e544c06e6e023953b1fc8069b7b1affa065262d1
This commit is contained in:
@@ -875,40 +875,23 @@ async fn augment_mcp_tool_request_meta_with_sandbox_state(
|
||||
};
|
||||
// TODO(anp): Build this metadata from the server's captured
|
||||
// TurnEnvironment::sandbox_context instead of the runtime-wide Landlock value.
|
||||
let sandbox_state = serde_json::to_value(SandboxState {
|
||||
codex_executable: prepared_call
|
||||
.sandbox_codex_executable()
|
||||
.await
|
||||
.map(AbsolutePathBuf::into_path_buf),
|
||||
permission_profile: prepared_call.permission_profile().clone(),
|
||||
codex_linux_sandbox_exe: prepared_call.config().codex_linux_sandbox_exe.clone(),
|
||||
sandbox_cwd,
|
||||
use_legacy_landlock: prepared_call.config().use_legacy_landlock,
|
||||
use_mxc: prepared_call
|
||||
.config()
|
||||
.environment_use_mxc
|
||||
.get(server_environment_id)
|
||||
.copied()
|
||||
.unwrap_or(false),
|
||||
})?;
|
||||
|
||||
match meta.as_mut() {
|
||||
Some(serde_json::Value::Object(map)) => {
|
||||
map.insert(
|
||||
codex_mcp::MCP_SANDBOX_STATE_META_CAPABILITY.to_string(),
|
||||
sandbox_state,
|
||||
);
|
||||
}
|
||||
Some(_) => {}
|
||||
None => {
|
||||
let mut map = serde_json::Map::new();
|
||||
map.insert(
|
||||
codex_mcp::MCP_SANDBOX_STATE_META_CAPABILITY.to_string(),
|
||||
sandbox_state,
|
||||
);
|
||||
meta = Some(serde_json::Value::Object(map));
|
||||
}
|
||||
}
|
||||
prepared_call
|
||||
.augment_sandbox_metadata(
|
||||
&mut meta,
|
||||
SandboxState {
|
||||
permission_profile: prepared_call.permission_profile().clone(),
|
||||
codex_linux_sandbox_exe: prepared_call.config().codex_linux_sandbox_exe.clone(),
|
||||
sandbox_cwd,
|
||||
use_legacy_landlock: prepared_call.config().use_legacy_landlock,
|
||||
use_mxc: prepared_call
|
||||
.config()
|
||||
.environment_use_mxc
|
||||
.get(server_environment_id)
|
||||
.copied()
|
||||
.unwrap_or(false),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(meta)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user