Implementation:AI Shell Team Aish McpManager new
| Knowledge Sources | |
|---|---|
| Domains | MCP, Configuration |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete tool for initializing the MCP server lifecycle manager without I/O provided by the aish-mcp crate.
Description
The McpManager::new constructor builds a manager from resolved McpSettings. It creates a ServerState entry for each configured server (including disabled ones) with an initial status based on the enabled flags. No I/O is performed — call start to connect servers.
The manager uses a RwLock for settings and server state, a generation AtomicU64 for driver invalidation, a watch channel for shutdown signaling, and a self-referential weak handle so `&self` methods can spawn drivers lazily without storing a strong `Arc<Self>`.
Usage
Call this constructor when setting up the MCP subsystem. The returned Arc<McpManager> is shared across the shell, the gateway tool, and the `/mcp` command.
Code Reference
Source Location
- Repository: aish
- File: crates/aish-mcp/src/manager.rs
Signature
impl McpManager {
pub fn new(settings: McpSettings) -> Arc<Self>
}
Import
use aish_mcp::{McpManager, McpSettings};
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| settings | McpSettings | Yes | Map of server configs (command, args, env, URL, trust, timeout, expose mode) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | Arc<McpManager> | Manager with per-server state entries; no I/O performed yet |
Usage Examples
Manager Initialization
use aish_mcp::{McpManager, McpSettings};
let settings = McpSettings::from_config(&config)?;
let manager = McpManager::new(settings);
// No connections yet — call start() to connect
manager.start(&tokio::runtime::Handle::current());