pub struct McpManager { /* private fields */ }Expand description
Manages multiple MCP server connections.
Implementations§
Source§impl McpManager
impl McpManager
Sourcepub fn new(servers: HashMap<String, McpServerConfig>) -> Self
pub fn new(servers: HashMap<String, McpServerConfig>) -> Self
Create a manager from a set of named server configs.
Sourcepub fn load_config(path: &Path) -> Result<Self, AgentError>
pub fn load_config(path: &Path) -> Result<Self, AgentError>
Load from .tiny-agent/mcp.json.
The expected JSON format is:
{ "mcpServers": { "name": { "command": "...", "args": [...], "auto_connect": true } } }Sourcepub async fn register_server(&self, id: String, config: McpServerConfig)
pub async fn register_server(&self, id: String, config: McpServerConfig)
Register a new server configuration. If a server with the same id already exists, it is replaced.
Sourcepub async fn register_servers(
&self,
new_servers: HashMap<String, McpServerConfig>,
)
pub async fn register_servers( &self, new_servers: HashMap<String, McpServerConfig>, )
Register multiple servers from a map of configs.
Sourcepub async fn connect_all(&self)
pub async fn connect_all(&self)
Connect all servers with auto_connect enabled.
Sourcepub async fn all_tools(&self) -> Vec<(String, McpTool)>
pub async fn all_tools(&self) -> Vec<(String, McpTool)>
Collect all tools from all connected servers.
Returns (server_id, tool) pairs.
Sourcepub async fn call_tool(
&self,
server_id: &str,
tool_name: &str,
args: Value,
) -> Result<Value, AgentError>
pub async fn call_tool( &self, server_id: &str, tool_name: &str, args: Value, ) -> Result<Value, AgentError>
Call a tool on a specific server.
Sourcepub async fn disconnect_all(&self)
pub async fn disconnect_all(&self)
Disconnect all servers.
Auto Trait Implementations§
impl !Freeze for McpManager
impl !RefUnwindSafe for McpManager
impl Send for McpManager
impl Sync for McpManager
impl Unpin for McpManager
impl UnsafeUnpin for McpManager
impl UnwindSafe for McpManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more