mirror of
https://github.com/openai/codex.git
synced 2026-11-23 07:17:11 +00:00
Enforce Agent Plugin runtime boundaries (#37027)
## What changed - Track Agent Plugin manifests through plugin, skill, and MCP loading so their capabilities use format-specific behavior without changing legacy plugins. - Discover only direct-child skills, exclude app and hook capabilities, isolate MCP data, and reject MCP configuration files that are non-regular or resolve outside the plugin root. - Bound model-visible skill instructions, plugin instructions, MCP descriptions, schemas, individual tools, and the aggregate Agent Plugin MCP tool set. - Stop MCP and OAuth redirects when Agent Plugins send configured or authorization headers, while retaining existing redirect behavior for legacy MCP servers. ## Testing - Add coverage for capability filtering, skill discovery, isolated MCP data and reserved-path expansion, unsafe MCP configuration files, context limits, and redirect handling. GitOrigin-RevId: c9af66b051269f3226628ca280a58d32c808c38f
This commit is contained in:
1 parent
f21dc46388
commit
56b82e676c
63 files changed
+1830
-106
No files matched your search
@@ -12,6 +12,7 @@ use codex_login::CodexAuth;
|
||||
use codex_rmcp_client::McpAuthState;
|
||||
use codex_rmcp_client::OAuthDiscoveryTimeout;
|
||||
use codex_rmcp_client::OAuthProviderError;
|
||||
use codex_rmcp_client::StreamableHttpRedirectMode;
|
||||
use codex_rmcp_client::determine_streamable_http_auth_status;
|
||||
use codex_rmcp_client::discover_streamable_http_oauth;
|
||||
use futures::FutureExt;
|
||||
@@ -61,6 +62,7 @@ pub async fn oauth_login_support(
|
||||
transport: &McpServerTransportConfig,
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
discovery_timeout: OAuthDiscoveryTimeout,
|
||||
redirect_mode: StreamableHttpRedirectMode,
|
||||
) -> McpOAuthLoginSupport {
|
||||
let Some(mut config) = oauth_login_candidate(transport) else {
|
||||
return McpOAuthLoginSupport::Unsupported;
|
||||
@@ -71,6 +73,7 @@ pub async fn oauth_login_support(
|
||||
config.env_http_headers.clone(),
|
||||
http_client,
|
||||
discovery_timeout,
|
||||
redirect_mode,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -108,8 +111,9 @@ pub async fn discover_supported_scopes(
|
||||
transport: &McpServerTransportConfig,
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
discovery_timeout: OAuthDiscoveryTimeout,
|
||||
redirect_mode: StreamableHttpRedirectMode,
|
||||
) -> Option<Vec<String>> {
|
||||
match oauth_login_support(transport, http_client, discovery_timeout).await {
|
||||
match oauth_login_support(transport, http_client, discovery_timeout, redirect_mode).await {
|
||||
McpOAuthLoginSupport::Supported(config) => config.discovered_scopes,
|
||||
McpOAuthLoginSupport::Unsupported | McpOAuthLoginSupport::Unknown(_) => None,
|
||||
}
|
||||
@@ -166,6 +170,11 @@ where
|
||||
{
|
||||
let futures = servers.into_iter().map(|(name, server)| {
|
||||
let name = name.clone();
|
||||
let redirect_mode = if server.is_agent_plugin() {
|
||||
StreamableHttpRedirectMode::AgentPluginV1
|
||||
} else {
|
||||
StreamableHttpRedirectMode::Legacy
|
||||
};
|
||||
let config = server.config().clone();
|
||||
let runtime_context = runtime_context.clone();
|
||||
let has_runtime_auth = matches!(&config.auth, McpServerAuth::ChatGpt)
|
||||
@@ -185,6 +194,7 @@ where
|
||||
keyring_backend_kind,
|
||||
has_runtime_auth,
|
||||
&runtime_context,
|
||||
redirect_mode,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@@ -212,6 +222,7 @@ async fn compute_auth_status(
|
||||
keyring_backend_kind: AuthKeyringBackendKind,
|
||||
has_runtime_auth: bool,
|
||||
runtime_context: &McpRuntimeContext,
|
||||
redirect_mode: StreamableHttpRedirectMode,
|
||||
) -> Result<McpAuthState> {
|
||||
if !config.enabled {
|
||||
return Ok(McpAuthState::Unsupported);
|
||||
@@ -256,6 +267,7 @@ async fn compute_auth_status(
|
||||
keyring_backend_kind,
|
||||
http_client,
|
||||
discovery_timeout,
|
||||
redirect_mode,
|
||||
)
|
||||
.boxed()
|
||||
.await
|
||||
|
||||
@@ -321,7 +321,14 @@ pub fn effective_mcp_servers_from_configured(
|
||||
}
|
||||
McpServerAuth::OAuth => {}
|
||||
}
|
||||
(name, EffectiveMcpServer::configured(server))
|
||||
let agent_plugin = config
|
||||
.mcp_server_catalog
|
||||
.server(&name)
|
||||
.is_some_and(|server| server.source().is_agent_plugin());
|
||||
(
|
||||
name,
|
||||
EffectiveMcpServer::configured(server).with_agent_plugin(agent_plugin),
|
||||
)
|
||||
})
|
||||
.collect::<HashMap<_, _>>();
|
||||
if !host_owned_codex_apps_enabled(config, auth) {
|
||||
|
||||
@@ -148,6 +148,7 @@ fn tool_plugin_provenance_collects_app_and_mcp_sources() {
|
||||
PluginCapabilitySummary {
|
||||
config_name: "alpha@test".to_string(),
|
||||
display_name: "alpha-plugin".to_string(),
|
||||
plugin_namespace: None,
|
||||
app_connector_ids: vec![AppConnectorId("connector_example".to_string())],
|
||||
mcp_server_names: vec!["alpha".to_string()],
|
||||
..PluginCapabilitySummary::default()
|
||||
@@ -155,6 +156,7 @@ fn tool_plugin_provenance_collects_app_and_mcp_sources() {
|
||||
PluginCapabilitySummary {
|
||||
config_name: "beta@test".to_string(),
|
||||
display_name: "beta-plugin".to_string(),
|
||||
plugin_namespace: None,
|
||||
app_connector_ids: vec![
|
||||
AppConnectorId("connector_example".to_string()),
|
||||
AppConnectorId("connector_gmail".to_string()),
|
||||
@@ -219,6 +221,7 @@ fn selected_mcp_attribution_does_not_join_an_unrelated_local_summary() {
|
||||
PluginCapabilitySummary {
|
||||
config_name: "shared-plugin-id".to_string(),
|
||||
display_name: "Local GitHub".to_string(),
|
||||
plugin_namespace: None,
|
||||
mcp_server_names: vec!["github".to_string()],
|
||||
..PluginCapabilitySummary::default()
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user