Enforce environment MCP policies (#39335)

## What changed

- Add environment-provided MCP restrictions for configured and plugin-provided servers.
- Disable attachment-scoped servers while their environment configuration is pending, failed, or unselected, while preserving selected-plugin access and the controller-owned Apps server.
- Apply the resolved policy to runtime startup, model tool exposure, telemetry, OAuth flows, and skill dependency installation.

## Testing

- Cover policy filtering for configured and plugin servers, environment state transitions, Apps ownership, and managed OAuth rejection.

GitOrigin-RevId: 7ca5d4dda14068e758497f88835d5cba685e159e
This commit is contained in:
sayan-oai authored and copyberry committed 2026-08-19 01:26:16 +00:00
1 parent d35e5495f9
commit fde2156057
36 files changed
+650 -88

No files matched your search

+7 -1
View File
@@ -147,6 +147,7 @@ impl SessionConfiguration {
permission_profile: self.permission_profile_state.snapshot(),
shell_environment_policy: self.shell_environment_policy.clone(),
exec_policy: None,
mcp_policy: None,
network_policy: None,
selected_capability_roots: Vec::new(),
}
@@ -893,6 +894,7 @@ impl Session {
McpThreadIdentity {
session_source: &mcp_session_source,
originator: &mcp_originator,
environments: McpEnvironmentScope::Initial(environment_selections),
},
/*ready_selected_capability_roots*/ &[],
/*executor_capability_discovery*/ None,
@@ -1046,7 +1048,8 @@ impl Session {
&mcp_projection.config,
auth.as_ref(),
)
.into_keys()
.into_iter()
.filter_map(|(name, server)| server.enabled().then_some(name))
.collect::<Vec<_>>();
session_telemetry.conversation_starts(
config.model_provider.name.as_str(),
@@ -1442,6 +1445,9 @@ impl Session {
McpThreadIdentity {
session_source: &session_configuration.session_source,
originator: &session_configuration.originator,
environments: McpEnvironmentScope::Live(
&sess.services.turn_environments,
),
},
/*ready_selected_capability_roots*/ &[],
/*executor_capability_discovery*/ None,