mirror of
https://github.com/openai/codex.git
synced 2026-11-23 07:17:11 +00:00
Freeze plugin roots in MCP tool attribution (#41117)
## Why Plugin MCP trust decisions must describe the exact host-discovered server registration. Looking up a plugin again by ID can resolve a different root. ## What changed - Retain the host plugin root in MCP catalog attribution and connection identity. - Reconnect an MCP server when its attributed plugin root changes. - Pass the retained root through tool lifecycle attribution and use it directly when building trusted tool context. ## Testing Add coverage for catalog identity, connection reconciliation, lifecycle attribution, and rejecting a different root associated with the same plugin ID. GitOrigin-RevId: bc92743dd40ab44065a07c3ea972b4956ef8351f
This commit is contained in:
1 parent
6c59264b14
commit
aa89cf62bb
11 files changed
+279
-38
No files matched your search
@@ -9,6 +9,7 @@ use codex_config::McpServerToolConfig;
|
||||
use codex_config::McpServerTransportConfig;
|
||||
use codex_protocol::mcp_policy::EnvironmentMcpPolicy;
|
||||
use codex_protocol::mcp_policy::PluginMcpRequirements;
|
||||
use codex_utils_path_uri::PathUri;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::CODEX_APPS_MCP_SERVER_NAME;
|
||||
@@ -20,6 +21,7 @@ use super::McpServerConflictAction;
|
||||
use super::McpServerRegistration;
|
||||
use super::McpServerSource;
|
||||
use super::ResolvedMcpCatalog;
|
||||
use super::ResolvedMcpServer;
|
||||
|
||||
fn server(url: &str) -> McpServerConfig {
|
||||
McpServerConfig {
|
||||
@@ -85,6 +87,33 @@ fn remove(source: McpServerSource) -> McpServerConflictAction {
|
||||
McpServerConflictAction::Remove(source)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plugin_host_root_is_retained_in_catalog_identity() {
|
||||
let original_root = PathUri::parse("file:///plugins/original").expect("valid plugin root URI");
|
||||
let replacement_root =
|
||||
PathUri::parse("file:///plugins/replacement").expect("valid plugin root URI");
|
||||
let catalog_for_root = |root| {
|
||||
let mut builder = ResolvedMcpCatalog::builder();
|
||||
builder.register(McpServerRegistration::from_plugin(
|
||||
"docs".to_string(),
|
||||
plugin("plugin@test").with_host_root(root),
|
||||
/*plugin_order*/ 0,
|
||||
server("https://plugin.example/mcp"),
|
||||
));
|
||||
builder.build()
|
||||
};
|
||||
let original = catalog_for_root(original_root.clone());
|
||||
let replacement = catalog_for_root(replacement_root);
|
||||
|
||||
let Some(McpServerSource::Plugin(attribution)) =
|
||||
original.server("docs").map(ResolvedMcpServer::source)
|
||||
else {
|
||||
panic!("expected host-discovered plugin registration");
|
||||
};
|
||||
assert_eq!(attribution.host_root(), Some(&original_root));
|
||||
assert!(!original.has_same_servers(&replacement));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_precedence_preserves_the_winning_registration() {
|
||||
let extension = server("https://extension.example/mcp");
|
||||
|
||||
Reference in new issue
Block a user