pub struct ToolExecutor { /* private fields */ }Expand description
Tool execution service that routes tool calls to the correct MCP server.
Implementations§
Source§impl ToolExecutor
impl ToolExecutor
Sourcepub fn add_client_advertised(
&mut self,
server_name: String,
client: MCPClient,
reserved: &HashSet<String>,
) -> Vec<ToolMetadata>
pub fn add_client_advertised( &mut self, server_name: String, client: MCPClient, reserved: &HashSet<String>, ) -> Vec<ToolMetadata>
Register a client and return its tools under advertised names.
Each advertised name is sanitize_tool_named and made unique against
reserved (e.g. the built-in tool names) and every previously-registered
tool, so the set of names handed to the provider is always valid and
collision-free. The returned metadata carries the advertised names; the
alias back to (server, original) is recorded for routing.
Sourcepub fn remove_client(&mut self, server_name: &str) -> Option<MCPClient>
pub fn remove_client(&mut self, server_name: &str) -> Option<MCPClient>
Take a server’s client back out of the executor, dropping the aliases
that routed to it. The caller owns the returned client and is expected
to shut it down - removal alone does not kill a stdio server’s child
process. None if no such server is registered.
The pool’s idle-disconnect uses this: a per-agent server whose last leasing run ended has no caller left, and before this the connection (and its child process) lived until the daemon exited.
Sourcepub async fn execute(
&mut self,
tool_name: &str,
arguments: Value,
) -> Result<ExecutionResult>
pub async fn execute( &mut self, tool_name: &str, arguments: Value, ) -> Result<ExecutionResult>
Execute a tool by its advertised name, routing to the owning server.
Sourcepub async fn execute_on(
&mut self,
server_name: &str,
tool_name: &str,
arguments: Value,
) -> Result<ExecutionResult>
pub async fn execute_on( &mut self, server_name: &str, tool_name: &str, arguments: Value, ) -> Result<ExecutionResult>
Execute a tool on a specific server.
Sourcepub async fn shutdown_all(&mut self) -> Result<()>
pub async fn shutdown_all(&mut self) -> Result<()>
Shutdown all connected MCP clients.
MCPClient::shutdown always returns Ok by design (it swallows
subprocess errors so a dead server cannot block cleanup), so errors
are discarded here too.
Sourcepub fn server_count(&self) -> usize
pub fn server_count(&self) -> usize
Get the number of connected servers.