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(&mut self, server_name: String, client: MCPClient)
pub fn add_client(&mut self, server_name: String, client: MCPClient)
Register an MCP client for a server, advertising its tools under names safe for the LLM/provider.
Equivalent to Self::add_client_advertised reserving nothing; kept for
callers that don’t need the advertised metadata back.
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 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 execute_filtered(
&mut self,
tool_name: &str,
arguments: Value,
allowed_tools: &[String],
) -> Result<ExecutionResult>
pub async fn execute_filtered( &mut self, tool_name: &str, arguments: Value, allowed_tools: &[String], ) -> Result<ExecutionResult>
Execute a tool only if it is in the allowed list.
Returns an error if the tool is not in the allowed_tools list.
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.