pub struct MultiServerMcpClient { /* private fields */ }Expand description
A client that connects to multiple MCP servers simultaneously and aggregates their tools under a unified interface.
§Connection
Call connect to establish connections to all configured
servers in parallel. Tools become available immediately after connection.
§Tool naming
Each server may have an optional prefix. When a prefix is configured,
tool names are exposed as {prefix}/{tool_name} to avoid collisions
across servers. The original server-local name is preserved for routing.
Implementations§
Source§impl MultiServerMcpClient
impl MultiServerMcpClient
Sourcepub async fn connect(
config: MultiServerMcpClientConfig,
callbacks: McpCallbacks,
) -> Result<Self, McpAdapterError>
pub async fn connect( config: MultiServerMcpClientConfig, callbacks: McpCallbacks, ) -> Result<Self, McpAdapterError>
Connects to all servers in config simultaneously and returns a
fully initialised client.
Connection failures for individual servers are logged and their status
will show as Disconnected. Call health to inspect
per-server status.
§Errors
Returns McpAdapterError only if configuration is fundamentally
invalid. Individual server failures are accumulated silently.
Sourcepub async fn get_tool_descriptors(&self) -> Vec<AggregatedToolDescriptor>
pub async fn get_tool_descriptors(&self) -> Vec<AggregatedToolDescriptor>
Returns all aggregated tool descriptors from all connected servers.
Tool names are prefixed when a server prefix is configured.
Sourcepub async fn health(&self) -> Vec<McpServerStatus>
pub async fn health(&self) -> Vec<McpServerStatus>
Returns health status for all servers.
Sourcepub async fn call_tool(
&self,
exposed_tool_name: &str,
arguments: Value,
) -> Result<Value, McpAdapterError>
pub async fn call_tool( &self, exposed_tool_name: &str, arguments: Value, ) -> Result<Value, McpAdapterError>
Calls a tool by its exposed name (including any prefix).
§Errors
McpAdapterError::ToolNotFoundif no server exposes the given name.McpAdapterError::Transportif the tool call fails.
Sourcepub fn callbacks(&self) -> &McpCallbacks
pub fn callbacks(&self) -> &McpCallbacks
Returns a reference to the callbacks bundle.