Skip to main content

atomcode_core/mcp/
client.rs

1//! MCP client trait and common utilities.
2
3use anyhow::Result;
4use async_trait::async_trait;
5
6use super::types::{InitializeResult, ListToolsResult, CallToolResult, ServerStatus};
7
8/// Information about an MCP tool.
9#[derive(Debug, Clone)]
10pub struct McpToolInfo {
11    pub server_name: String,
12    pub tool_name: String,
13    pub description: String,
14    pub input_schema: serde_json::Value,
15}
16
17/// MCP client trait for communicating with an MCP server.
18#[async_trait]
19pub trait McpClient: Send + Sync {
20    /// Initialize the connection to the MCP server.
21    async fn initialize(&mut self) -> Result<InitializeResult>;
22
23    /// List available tools from the server.
24    async fn list_tools(&self) -> Result<ListToolsResult>;
25
26    /// Call a tool on the server.
27    async fn call_tool(&self, tool_name: &str, arguments: serde_json::Value) -> Result<CallToolResult>;
28
29    /// Get the server name.
30    fn server_name(&self) -> &str;
31
32    /// Get the current server status.
33    fn status(&self) -> ServerStatus;
34}