Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Backport Windows remote MCP environment preservation to 0.160
Backport #50129. Preserve SYSTEMROOT, TEMP, and TMP when explicit remote environment variables enable filtering.
  • Loading branch information
andrewgu-oai committed Oct 5, 2026
commit b30ce510b0d41438027cbddcd2087dcd34791691
23 changes: 23 additions & 0 deletions codex-rs/rmcp-client/src/stdio_server_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,12 @@ impl ExecutorStdioServerLauncher {
// environment, not copied from Codex. Start from `All` only so the
// named remote variable is available to the filter below; the
// effective child env is still limited by `include_only`.
// The orchestrator may be Unix while the executor is Windows.
// Preserve Windows runtime initialization and temporary-directory
// inputs even when explicit remote vars activate this allowlist.
crate::utils::DEFAULT_ENV_VARS
.iter()
.chain(["SYSTEMROOT", "TEMP", "TMP"].iter())
.map(|name| (*name).to_string())
.chain(remote_env_vars.iter().cloned())
.collect()
Expand Down Expand Up @@ -763,6 +767,15 @@ mod tests {
let env = shell_environment::create_env_from_vars(
[
("PATH".to_string(), "/remote/bin".to_string()),
("SystemRoot".to_string(), r"C:\Windows".to_string()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add integration coverage for the remote MCP launch

When a Unix orchestrator launches a Windows MCP server with a source = "remote" variable, this test calls the private remote_env_policy helper and manually recreates the exec-server conversion, so it can pass even if the actual launch path fails to classify the variable or transmit the allowlist in ExecParams. Add an integration test through the remote MCP launch path that verifies SYSTEMROOT, TEMP, and TMP survive while an unrequested secret does not.

AGENTS.md reference: AGENTS.md:L112-L121

Useful? React with 👍 / 👎.

(
"TEMP".to_string(),
r"C:\Users\test\AppData\Local\Temp".to_string(),
),
(
"TMP".to_string(),
r"C:\Users\test\AppData\Local\Temp".to_string(),
),
("REMOTE_TOKEN".to_string(), "remote-secret".to_string()),
(
"UNREQUESTED_SECRET".to_string(),
Expand All @@ -774,6 +787,16 @@ mod tests {
);

assert_eq!(env.get("PATH").map(String::as_str), Some("/remote/bin"));
assert_eq!(
env.get("SystemRoot").map(String::as_str),
Some(r"C:\Windows")
);
for name in ["TEMP", "TMP"] {
assert_eq!(
env.get(name).map(String::as_str),
Some(r"C:\Users\test\AppData\Local\Temp")
);
}
assert_eq!(
env.get("REMOTE_TOKEN").map(String::as_str),
Some("remote-secret")
Expand Down
Loading