pub struct McpConnectionPool { /* private fields */ }Expand description
Shared, per-core connection pool. Wrapped in Arc and cloned into each
session plugin instance.
Implementations§
Source§impl McpConnectionPool
impl McpConnectionPool
Sourcepub async fn connect(
servers: BTreeMap<String, McpServerConfig>,
) -> Result<Arc<Self>, McpError>
pub async fn connect( servers: BTreeMap<String, McpServerConfig>, ) -> Result<Arc<Self>, McpError>
Build a pool, connecting to every configured server. Servers are connected sequentially; the first failure aborts.
Sourcepub async fn attach(
self: &Arc<Self>,
server_name: String,
config: McpServerConfig,
) -> Result<(), McpError>
pub async fn attach( self: &Arc<Self>, server_name: String, config: McpServerConfig, ) -> Result<(), McpError>
Add (or replace) one server in the pool. Connects synchronously and caches the server’s advertised tools.
Sourcepub async fn detach(self: &Arc<Self>, server_name: &str) -> Result<(), McpError>
pub async fn detach(self: &Arc<Self>, server_name: &str) -> Result<(), McpError>
Remove and shut down one server.
Sourcepub fn advertised_tools_blocking(&self) -> Vec<ToolDefinition>
pub fn advertised_tools_blocking(&self) -> Vec<ToolDefinition>
All advertised tools across every server, with mcp__<server>__<tool>
prefixed names. Cheap — these are precomputed ToolDefinition clones.
Sourcepub async fn advertised_tools(&self) -> Vec<ToolDefinition>
pub async fn advertised_tools(&self) -> Vec<ToolDefinition>
Same as [advertised_tools_blocking] but for use from async contexts.
Sourcepub async fn call_tool(
&self,
prefixed_name: &str,
args: &Value,
context: &ToolContext<'_>,
) -> ToolResult
pub async fn call_tool( &self, prefixed_name: &str, args: &Value, context: &ToolContext<'_>, ) -> ToolResult
Route a prefixed tool call (mcp__<server>__<tool>) to the appropriate
server and translate its result back to ToolResult.
Sourcepub async fn shutdown_all(&self)
pub async fn shutdown_all(&self)
Tear down all connections. Call this before dropping the pool for a
graceful shutdown; Drop itself cannot await.