mirror of
https://github.com/openai/codex.git
synced 2026-10-27 18:48:37 +00:00
- Split MCP runtime/server code out of `codex-core` into the new `codex-mcp` crate. New/moved public structs/types include `McpConfig`, `McpConnectionManager`, `ToolInfo`, `ToolPluginProvenance`, `CodexAppsToolsCacheKey`, and the `McpManager` API (`codex_mcp::mcp::McpManager` plus the `codex_core::mcp::McpManager` wrapper/shim). New/moved functions include `with_codex_apps_mcp`, `configured_mcp_servers`, `effective_mcp_servers`, `collect_mcp_snapshot`, `collect_mcp_snapshot_from_manager`, `qualified_mcp_tool_name_prefix`, and the MCP auth/skill-dependency helpers. Why: this creates a focused MCP crate boundary and shrinks `codex-core` without forcing every consumer to migrate in the same PR. - Move MCP server config schema and persistence into `codex-config`. New/moved structs/enums include `AppToolApproval`, `McpServerToolConfig`, `McpServerConfig`, `RawMcpServerConfig`, `McpServerTransportConfig`, `McpServerDisabledReason`, and `codex_config::ConfigEditsBuilder`. New/moved functions include `load_global_mcp_servers` and `ConfigEditsBuilder::replace_mcp_servers`/`apply`. Why: MCP TOML parsing/editing is config ownership, and this keeps config validation/round-tripping (including per-tool approval overrides and inline bearer-token rejection) in the config crate instead of `codex-core`. - Rewire `codex-core`, app-server, and plugin call sites onto the new crates. Updated `Config::to_mcp_config(&self, plugins_manager)`, `codex-rs/core/src/mcp.rs`, `codex-rs/core/src/connectors.rs`, `codex-rs/core/src/codex.rs`, `CodexMessageProcessor::list_mcp_server_status_task`, and `utils/plugins/src/mcp_connector.rs` to build/pass the new MCP config/runtime types. Why: plugin-provided MCP servers still merge with user-configured servers, and runtime auth (`CodexAuth`) is threaded into `with_codex_apps_mcp` / `collect_mcp_snapshot` explicitly so `McpConfig` stays config-only.
54 lines
1.8 KiB
Rust
54 lines
1.8 KiB
Rust
use std::collections::HashMap;
|
|
use std::sync::Arc;
|
|
|
|
pub use codex_mcp::mcp::CODEX_APPS_MCP_SERVER_NAME;
|
|
pub use codex_mcp::mcp::McpConfig;
|
|
pub use codex_mcp::mcp::ToolPluginProvenance;
|
|
pub use codex_mcp::mcp::auth;
|
|
pub use codex_mcp::mcp::canonical_mcp_server_key;
|
|
pub use codex_mcp::mcp::collect_mcp_snapshot;
|
|
pub use codex_mcp::mcp::collect_mcp_snapshot_from_manager;
|
|
pub use codex_mcp::mcp::collect_missing_mcp_dependencies;
|
|
pub use codex_mcp::mcp::configured_mcp_servers;
|
|
pub use codex_mcp::mcp::effective_mcp_servers;
|
|
pub use codex_mcp::mcp::group_tools_by_server;
|
|
pub use codex_mcp::mcp::qualified_mcp_tool_name_prefix;
|
|
pub use codex_mcp::mcp::split_qualified_tool_name;
|
|
pub use codex_mcp::mcp::tool_plugin_provenance as mcp_tool_plugin_provenance;
|
|
pub use codex_mcp::mcp::with_codex_apps_mcp;
|
|
|
|
use crate::CodexAuth;
|
|
use crate::config::Config;
|
|
use crate::plugins::PluginsManager;
|
|
use codex_config::McpServerConfig;
|
|
|
|
#[derive(Clone)]
|
|
pub struct McpManager {
|
|
plugins_manager: Arc<PluginsManager>,
|
|
}
|
|
|
|
impl McpManager {
|
|
pub fn new(plugins_manager: Arc<PluginsManager>) -> Self {
|
|
Self { plugins_manager }
|
|
}
|
|
|
|
pub fn configured_servers(&self, config: &Config) -> HashMap<String, McpServerConfig> {
|
|
let mcp_config = config.to_mcp_config(self.plugins_manager.as_ref());
|
|
configured_mcp_servers(&mcp_config)
|
|
}
|
|
|
|
pub fn effective_servers(
|
|
&self,
|
|
config: &Config,
|
|
auth: Option<&CodexAuth>,
|
|
) -> HashMap<String, McpServerConfig> {
|
|
let mcp_config = config.to_mcp_config(self.plugins_manager.as_ref());
|
|
effective_mcp_servers(&mcp_config, auth)
|
|
}
|
|
|
|
pub fn tool_plugin_provenance(&self, config: &Config) -> ToolPluginProvenance {
|
|
let mcp_config = config.to_mcp_config(self.plugins_manager.as_ref());
|
|
mcp_tool_plugin_provenance(&mcp_config)
|
|
}
|
|
}
|