Forward local env vars to Agent Plugin MCP servers (#40363)

## What changed

- Apply local `env_vars` declarations from `.codex-plugin/plugin.json` to matching stdio servers loaded from an Agent Plugin manifest.
- Replace matching `${NAME}` entries in the portable server environment with host environment forwarding while preserving the portable command, arguments, and unrelated servers.
- Ignore remote-sourced environment variables and support both inline and file-based Codex MCP declarations.

## Testing

- Cover matching-server filtering, local and remote sources, inline declarations, and an end-to-end `PATH` forwarding round trip.

GitOrigin-RevId: 843e1232a084fa5f571fe56e07266995b87fd53d
This commit is contained in:
jif authored and copyberry committed 2026-08-24 08:43:25 +00:00
1 parent 2df6705423
commit 40b7560169
4 files changed
+270 -3

No files matched your search

+7
View File
@@ -61,6 +61,9 @@ use tempfile::TempDir;
use tracing::instrument;
use tracing::warn;
#[path = "agent_plugin_mcp_overlay.rs"]
mod agent_plugin_mcp_overlay;
const DEFAULT_SKILLS_DIR_NAME: &str = "skills";
const DEFAULT_HOOKS_CONFIG_FILE: &str = "hooks/hooks.json";
const DEFAULT_MCP_CONFIG_FILE: &str = ".mcp.json";
@@ -1560,6 +1563,10 @@ pub(crate) async fn load_plugin_mcp_servers_from_manifest_with_format(
}
}
if manifest_format == PluginManifestFormat::AgentPlugin {
agent_plugin_mcp_overlay::apply_codex_env_overlay(plugin_root, &mut mcp_servers).await;
}
mcp_servers
}