MCPcopy Create free account
hub / github.com/AI45Lab/Code / connect_global_mcp

Function connect_global_mcp

core/src/agent_api/agent_bootstrap.rs:116–143  ·  view source on GitHub ↗
(
    config: &CodeConfig,
)

Source from the content-addressed store, hash-verified

114}
115
116async fn connect_global_mcp(
117 config: &CodeConfig,
118) -> (
119 Option<Arc<crate::mcp::manager::McpManager>>,
120 Vec<(String, crate::mcp::McpTool)>,
121) {
122 if config.mcp_servers.is_empty() {
123 return (None, Vec::new());
124 }
125
126 let manager = Arc::new(crate::mcp::manager::McpManager::new());
127 for server in &config.mcp_servers {
128 if !server.enabled {
129 continue;
130 }
131 manager.register_server(server.clone()).await;
132 if let Err(e) = manager.connect(&server.name).await {
133 tracing::warn!(
134 server = %server.name,
135 error = %e,
136 "Failed to connect to MCP server - skipping"
137 );
138 }
139 }
140
141 let tools = manager.get_all_tools().await;
142 (Some(manager), tools)
143}
144
145#[cfg(test)]
146mod tests {

Callers 1

build_agent_from_configFunction · 0.85

Calls 5

register_serverMethod · 0.80
get_all_toolsMethod · 0.80
is_emptyMethod · 0.45
cloneMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected