mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
1 parent
a124ddb854
commit
32b1ae7099
22 files changed
+12
-559
No files matched your search
@@ -106,7 +106,7 @@ pub struct McpPermissionPromptAutoApproveContext {
|
||||
pub struct McpConfig {
|
||||
/// Base URL for ChatGPT-hosted app MCP servers, copied from the root config.
|
||||
pub chatgpt_base_url: String,
|
||||
/// Optional path override for the built-in apps MCP server.
|
||||
/// Optional path override for the host-owned apps MCP server.
|
||||
pub apps_mcp_path_override: Option<String>,
|
||||
/// Codex home directory used for MCP OAuth state and app-tool cache files.
|
||||
pub codex_home: PathBuf,
|
||||
@@ -126,16 +126,13 @@ pub struct McpConfig {
|
||||
pub use_legacy_landlock: bool,
|
||||
/// Whether the app MCP integration is enabled by config.
|
||||
///
|
||||
/// ChatGPT auth is checked separately at runtime before the built-in apps
|
||||
/// ChatGPT auth is checked separately at runtime before the host-owned apps
|
||||
/// MCP server is added.
|
||||
pub apps_enabled: bool,
|
||||
/// Config-backed MCP servers keyed by server name.
|
||||
///
|
||||
/// Product-owned built-ins and runtime-only additions are merged later by
|
||||
/// [`effective_mcp_servers`].
|
||||
/// Runtime-only additions are merged later by [`effective_mcp_servers`].
|
||||
pub configured_mcp_servers: HashMap<String, McpServerConfig>,
|
||||
/// Product-owned built-ins enabled for this runtime config.
|
||||
pub builtin_mcp_servers: Vec<codex_builtin_mcps::BuiltinMcpServer>,
|
||||
/// Plugin metadata used to attribute MCP tools/connectors to plugin display names.
|
||||
pub plugin_capability_summaries: Vec<PluginCapabilitySummary>,
|
||||
}
|
||||
@@ -234,16 +231,10 @@ pub fn effective_mcp_servers_from_configured(
|
||||
config: &McpConfig,
|
||||
auth: Option<&CodexAuth>,
|
||||
) -> HashMap<String, EffectiveMcpServer> {
|
||||
let mut servers = configured_servers
|
||||
let servers = configured_servers
|
||||
.into_iter()
|
||||
.map(|(name, server)| (name, EffectiveMcpServer::configured(server)))
|
||||
.collect::<HashMap<_, _>>();
|
||||
for builtin_server in &config.builtin_mcp_servers {
|
||||
servers.insert(
|
||||
builtin_server.name().to_string(),
|
||||
EffectiveMcpServer::builtin(*builtin_server),
|
||||
);
|
||||
}
|
||||
with_codex_apps_mcp(servers, auth, config)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ use codex_protocol::protocol::GranularApprovalConfig;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn test_mcp_config(codex_home: PathBuf) -> McpConfig {
|
||||
McpConfig {
|
||||
@@ -29,7 +28,6 @@ fn test_mcp_config(codex_home: PathBuf) -> McpConfig {
|
||||
use_legacy_landlock: false,
|
||||
apps_enabled: false,
|
||||
configured_mcp_servers: HashMap::new(),
|
||||
builtin_mcp_servers: Vec::new(),
|
||||
plugin_capability_summaries: Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -347,53 +345,3 @@ async fn effective_mcp_servers_preserve_user_servers_and_add_codex_apps() {
|
||||
other => panic!("expected streamable http transport, got {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn effective_mcp_servers_preserve_builtin_runtime_shape() {
|
||||
let mut config = test_mcp_config(PathBuf::from("/tmp"));
|
||||
config.builtin_mcp_servers = vec![codex_builtin_mcps::BuiltinMcpServer::Memories];
|
||||
|
||||
let effective = effective_mcp_servers(&config, /*auth*/ None);
|
||||
let memories = effective
|
||||
.get(codex_builtin_mcps::MEMORIES_MCP_SERVER_NAME)
|
||||
.expect("memories server should exist");
|
||||
|
||||
assert!(!crate::server::McpServerMetadata::from(memories).pollutes_memory);
|
||||
assert!(matches!(
|
||||
memories.launch(),
|
||||
crate::server::McpServerLaunch::Builtin(codex_builtin_mcps::BuiltinMcpServer::Memories)
|
||||
));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn builtin_memories_server_runs_in_process() {
|
||||
let codex_home = tempfile::tempdir().expect("tempdir");
|
||||
let mut config = test_mcp_config(codex_home.path().to_path_buf());
|
||||
config.builtin_mcp_servers = vec![codex_builtin_mcps::BuiltinMcpServer::Memories];
|
||||
|
||||
let snapshot = collect_mcp_server_status_snapshot_with_detail(
|
||||
&config,
|
||||
/*auth*/ None,
|
||||
"builtin-memories-test".to_string(),
|
||||
McpRuntimeEnvironment::new(
|
||||
Arc::new(codex_exec_server::Environment::default_for_tests()),
|
||||
codex_home.path().to_path_buf(),
|
||||
),
|
||||
McpSnapshotDetail::ToolsAndAuthOnly,
|
||||
)
|
||||
.await;
|
||||
|
||||
let tools = snapshot
|
||||
.tools_by_server
|
||||
.get(codex_builtin_mcps::MEMORIES_MCP_SERVER_NAME)
|
||||
.expect("memories tools should be listed");
|
||||
assert_eq!(
|
||||
tools
|
||||
.keys()
|
||||
.cloned()
|
||||
.collect::<std::collections::BTreeSet<_>>(),
|
||||
["list".to_string(), "read".to_string(), "search".to_string()]
|
||||
.into_iter()
|
||||
.collect()
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user