mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Scope MCP sandbox metadata to server environment (#28914)
Scope MCP sandbox metadata to the MCP server's owning environment. Previously, `codex/sandbox-state-meta` always used the turn's primary cwd and rebuilt a legacy sandbox policy from that cwd. That can be wrong for MCP servers owned by a different execution environment. This now sends the owning environment cwd as a `file:` URI in `sandboxCwd`, keeps `permissionProfile` as the permission source of truth, and omits sandbox-state metadata when a non-default server environment is not selected for the turn. Local/default MCP servers keep the existing fallback cwd behavior. Tests: - `just fmt` - `just bazel-lock-update` - `just bazel-lock-check` - `just test -p codex-mcp` - `just test -p codex-core mcp_sandbox_cwd` - `cargo build -p codex-rmcp-client --bin test_stdio_server` - `just test -p codex-core stdio_mcp_tool_call_includes_sandbox_state_meta`
This commit is contained in:
@@ -75,6 +75,7 @@ impl McpServerOrigin {
|
||||
/// Semantic metadata that must survive after the server is launched.
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct McpServerMetadata {
|
||||
pub environment_id: String,
|
||||
pub pollutes_memory: bool,
|
||||
pub origin: Option<McpServerOrigin>,
|
||||
pub supports_parallel_tool_calls: bool,
|
||||
@@ -96,6 +97,7 @@ impl From<&EffectiveMcpServer> for McpServerMetadata {
|
||||
fn from(server: &EffectiveMcpServer) -> Self {
|
||||
match server.launch() {
|
||||
McpServerLaunch::Configured(config) => Self {
|
||||
environment_id: config.environment_id.clone(),
|
||||
pollutes_memory: true,
|
||||
origin: McpServerOrigin::from_transport(&config.transport),
|
||||
supports_parallel_tool_calls: config.supports_parallel_tool_calls,
|
||||
|
||||
Reference in New Issue
Block a user