pub trait McpService: Send + Sync {
// Required methods
fn list_tools(
&self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, McpError>> + Send + '_>>;
fn call_tool(
&self,
name: &str,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<String, McpError>> + Send + '_>>;
}Expand description
Minimal contract for MCP-like tool sources.
Implement this trait to bridge any MCP client library with llm-core’s tool system. The trait requires only two operations:
- List available tools (with their schemas)
- Call a tool by name with JSON arguments
§Thread Safety
Implementations must be Send + Sync to allow use across async tasks.
Typically achieved by wrapping the underlying client in Arc.
§Object Safety
This trait is object-safe (dyn McpService) to allow storing different
MCP service implementations in the same registry.
Required Methods§
Sourcefn list_tools(
&self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, McpError>> + Send + '_>>
fn list_tools( &self, ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolDefinition>, McpError>> + Send + '_>>
Lists all tools available from the MCP server.