pub struct McpPool { /* private fields */ }Expand description
Pool of MCP connections for reuse
Implementations§
Source§impl McpPool
impl McpPool
Sourcepub fn from_config_path(path: &Path) -> Result<McpPool, Error>
pub fn from_config_path(path: &Path) -> Result<McpPool, Error>
Create a pool from a configuration file path
Sourcepub fn with_network_policy(self, policy: NetworkPolicyDecider) -> McpPool
pub fn with_network_policy(self, policy: NetworkPolicyDecider) -> McpPool
Attach a per-domain network policy (#135). When set, HTTP/SSE transports are gated through it; STDIO transports are unaffected.
Sourcepub async fn get_or_connect(
&mut self,
server_name: &str,
) -> Result<&mut McpConnection, Error>
pub async fn get_or_connect( &mut self, server_name: &str, ) -> Result<&mut McpConnection, Error>
Get or create a connection to a server
Sourcepub async fn connect_all(&mut self) -> Vec<(String, Error)>
pub async fn connect_all(&mut self) -> Vec<(String, Error)>
Connect to all enabled servers, returning errors for failed connections
Sourcepub fn all_tools(&self) -> Vec<(String, &McpTool)>
pub fn all_tools(&self) -> Vec<(String, &McpTool)>
Get all discovered tools with server-prefixed names
Sourcepub fn all_resources(&self) -> Vec<(String, &McpResource)>
pub fn all_resources(&self) -> Vec<(String, &McpResource)>
Get all discovered resources with server-prefixed names
Sourcepub fn all_resource_templates(&self) -> Vec<(String, &McpResourceTemplate)>
pub fn all_resource_templates(&self) -> Vec<(String, &McpResourceTemplate)>
Get all discovered resource templates with server-prefixed names
Sourcepub fn all_prompts(&self) -> Vec<(String, &McpPrompt)>
pub fn all_prompts(&self) -> Vec<(String, &McpPrompt)>
Get all discovered prompts with server-prefixed names
Sourcepub async fn read_resource(
&mut self,
server_name: &str,
uri: &str,
) -> Result<Value, Error>
pub async fn read_resource( &mut self, server_name: &str, uri: &str, ) -> Result<Value, Error>
Read a resource from a specific server
Sourcepub async fn get_prompt(
&mut self,
server_name: &str,
prompt_name: &str,
arguments: Value,
) -> Result<Value, Error>
pub async fn get_prompt( &mut self, server_name: &str, prompt_name: &str, arguments: Value, ) -> Result<Value, Error>
Get a prompt from a specific server
Sourcepub fn to_api_tools(&self) -> Vec<Tool>
pub fn to_api_tools(&self) -> Vec<Tool>
Convert discovered tools to API Tool format
Sourcepub async fn call_tool(
&mut self,
prefixed_name: &str,
arguments: Value,
) -> Result<Value, Error>
pub async fn call_tool( &mut self, prefixed_name: &str, arguments: Value, ) -> Result<Value, Error>
Call a tool by its prefixed name (mcp_{server}_{tool})
Sourcepub fn server_names(&self) -> Vec<&str>
pub fn server_names(&self) -> Vec<&str>
Get list of configured server names
Sourcepub fn connected_servers(&self) -> Vec<&str>
pub fn connected_servers(&self) -> Vec<&str>
Get list of connected server names
Sourcepub fn disconnect_all(&mut self)
pub fn disconnect_all(&mut self)
Disconnect all connections
Sourcepub async fn reload_from_path(
&mut self,
path: &Path,
) -> Result<McpReloadReport, Error>
pub async fn reload_from_path( &mut self, path: &Path, ) -> Result<McpReloadReport, Error>
Reload pool configuration from disk and reconcile live connections.
Sourcepub async fn reload_config(
&mut self,
new_config: McpConfig,
reconnect: bool,
) -> McpReloadReport
pub async fn reload_config( &mut self, new_config: McpConfig, reconnect: bool, ) -> McpReloadReport
Apply a new config: drop removed/changed/disabled connections, swap config, then optionally reconnect all enabled servers.
Sourcepub async fn shutdown_all(&mut self)
pub async fn shutdown_all(&mut self)
Graceful shutdown of every connection in the pool: send SIGTERM to each stdio child and give them a short grace period before drop fires SIGKILL. Whalescale#420.
Call from the TUI exit path before dropping the pool to give
MCP servers a chance to flush state. The fallback Drop on
StdioTransport still sends SIGTERM if this never runs, so even
abnormal exits avoid leaking PIDs without a signal.
Sourcepub fn is_mcp_tool(name: &str) -> bool
pub fn is_mcp_tool(name: &str) -> bool
Check if a tool name is an MCP tool
Trait Implementations§
Source§impl McpHost for McpPool
impl McpHost for McpPool
Source§fn is_mcp_tool(&self, name: &str) -> bool
fn is_mcp_tool(&self, name: &str) -> bool
Source§fn tool_is_parallel_safe(&self, name: &str) -> bool
fn tool_is_parallel_safe(&self, name: &str) -> bool
name may run inside the parallel batch
executor (read-only + side-effect-free). Read moreAuto Trait Implementations§
impl !RefUnwindSafe for McpPool
impl !UnwindSafe for McpPool
impl Freeze for McpPool
impl Send for McpPool
impl Sync for McpPool
impl Unpin for McpPool
impl UnsafeUnpin for McpPool
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more