pub struct McpToolExecutor { /* private fields */ }Expand description
ToolExecutor implementation that dispatches tool calls to MCP servers.
McpToolExecutor bridges the zeph-tools dispatch layer and McpManager. It
maintains a local snapshot of the registered MCP tools (updated via
set_tools) and resolves tool calls by matching
the sanitized tool ID against the snapshot before forwarding to the manager.
§Security invariant
execute_tool_call sets
ToolOutput::tool_name to McpTool::qualified_name (i.e. "server_id:name").
The ':' in the name is the signal used by zeph-core’s sanitize_tool_output()
to route responses through the quarantine pipeline. Do not change this.
§Fenced-block execution
execute parses ```mcp fenced blocks
from LLM output and validates each server:tool pair against the registered list
before dispatching, preventing prompt injection from routing calls to unknown servers.
Implementations§
Source§impl McpToolExecutor
impl McpToolExecutor
Sourcepub fn new(manager: Arc<McpManager>, tools: Arc<RwLock<Vec<McpTool>>>) -> Self
pub fn new(manager: Arc<McpManager>, tools: Arc<RwLock<Vec<McpTool>>>) -> Self
Create a new executor from a shared McpManager and a shared tool list.
The tools RwLock is updated via set_tools after each
connect or refresh. Pass the same Arc<RwLock<Vec<McpTool>>> to both the executor
and the code that handles tools/list_changed events.
Sourcepub fn set_tools(&self, tools: Vec<McpTool>)
pub fn set_tools(&self, tools: Vec<McpTool>)
Replace the registered tool snapshot.
Logs a WARN for each sanitized_id collision: when two tools map to the same
sanitized ID the second is unreachable via execute_tool_call.
Trait Implementations§
Source§impl Clone for McpToolExecutor
impl Clone for McpToolExecutor
Source§fn clone(&self) -> McpToolExecutor
fn clone(&self) -> McpToolExecutor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for McpToolExecutor
impl Debug for McpToolExecutor
Source§impl ToolExecutor for McpToolExecutor
impl ToolExecutor for McpToolExecutor
Source§fn tool_definitions(&self) -> Vec<ToolDef>
fn tool_definitions(&self) -> Vec<ToolDef>
Source§async fn execute_tool_call(
&self,
call: &ToolCall,
) -> Result<Option<ToolOutput>, ToolError>
async fn execute_tool_call( &self, call: &ToolCall, ) -> Result<Option<ToolOutput>, ToolError>
Source§async fn execute(&self, response: &str) -> Result<Option<ToolOutput>, ToolError>
async fn execute(&self, response: &str) -> Result<Option<ToolOutput>, ToolError>
response for fenced tool blocks and execute them. Read moreSource§fn execute_confirmed(
&self,
response: &str,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
fn execute_confirmed( &self, response: &str, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
Source§fn execute_tool_call_confirmed(
&self,
call: &ToolCall,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
fn execute_tool_call_confirmed( &self, call: &ToolCall, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
Source§fn set_skill_env(&self, _env: Option<HashMap<String, String>>)
fn set_skill_env(&self, _env: Option<HashMap<String, String>>)
Source§fn set_effective_trust(&self, _level: SkillTrustLevel)
fn set_effective_trust(&self, _level: SkillTrustLevel)
Source§fn is_tool_retryable(&self, _tool_id: &str) -> bool
fn is_tool_retryable(&self, _tool_id: &str) -> bool
Auto Trait Implementations§
impl !RefUnwindSafe for McpToolExecutor
impl !UnwindSafe for McpToolExecutor
impl Freeze for McpToolExecutor
impl Send for McpToolExecutor
impl Sync for McpToolExecutor
impl Unpin for McpToolExecutor
impl UnsafeUnpin for McpToolExecutor
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ErasedToolExecutor for Twhere
T: ToolExecutor,
impl<T> ErasedToolExecutor for Twhere
T: ToolExecutor,
fn execute_erased<'a>( &'a self, response: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn execute_confirmed_erased<'a>( &'a self, response: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn tool_definitions_erased(&self) -> Vec<ToolDef>
fn execute_tool_call_erased<'a>( &'a self, call: &'a ToolCall, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
fn execute_tool_call_confirmed_erased<'a>( &'a self, call: &'a ToolCall, ) -> Pin<Box<dyn Future<Output = Result<Option<ToolOutput>, ToolError>> + Send + 'a>>
Source§fn set_skill_env(&self, env: Option<HashMap<String, String>>)
fn set_skill_env(&self, env: Option<HashMap<String, String>>)
Source§fn set_effective_trust(&self, level: SkillTrustLevel)
fn set_effective_trust(&self, level: SkillTrustLevel)
Source§fn is_tool_retryable_erased(&self, tool_id: &str) -> bool
fn is_tool_retryable_erased(&self, tool_id: &str) -> bool
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request