pub struct McpToolBridge { /* private fields */ }Expand description
A wrapper that exposes one MCP server tool as a xcodeai Tool.
Created by register_mcp_tools() — one bridge per tool returned by
McpClient::list_tools().
Implementations§
Source§impl McpToolBridge
impl McpToolBridge
Trait Implementations§
Source§impl Tool for McpToolBridge
impl Tool for McpToolBridge
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
_ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Forward the tool call to the MCP server and convert the result.
§How it works
- Lock the mutex to get exclusive access to the MCP connection.
- Call
McpClient::call_tool(raw_name, args). - Convert
McpToolCallResult→ToolResultviaformat_mcp_result().
§Error propagation
- If the MCP call itself fails (e.g. server crashed, network error),
we return
Ok(ToolResult { is_error: true, output: "<message>" }). - If the MCP call succeeds but the tool reported an error
(
isError: true), the same pattern applies — the output contains the error text from the server.
fn name(&self) -> &str
fn description(&self) -> &str
fn parameters_schema(&self) -> Value
Auto Trait Implementations§
impl Freeze for McpToolBridge
impl !RefUnwindSafe for McpToolBridge
impl Send for McpToolBridge
impl Sync for McpToolBridge
impl Unpin for McpToolBridge
impl UnsafeUnpin for McpToolBridge
impl !UnwindSafe for McpToolBridge
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
Mutably borrows from an owned value. Read more