Skip to main content

connect_all_from_config

Function connect_all_from_config 

Source
pub async fn connect_all_from_config(
    start_dir: &Path,
) -> Result<Vec<Box<dyn Tool>>>
Expand description

连接配置文件中的所有 MCP 服务器

从当前目录或用户主目录查找 mcp.toml / mcp.json 配置文件, 并连接所有启用的 MCP 服务器。

§Example

use matrixcode_core::mcp::connect_all_from_config;
use std::path::Path;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let tools = connect_all_from_config(Path::new(".")).await?;
    println!("Total tools: {}", tools.len());
    Ok(())
}