use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::BoxFuture;
use crate::agents::error::AgentError;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct McpToolDescriptor {
pub name: String,
pub description: String,
pub input_schema: Value,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[non_exhaustive]
pub enum McpConnectionState {
#[default]
Disconnected,
Connecting,
Connected,
Reconnecting,
Shutdown,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct McpServerStatus {
pub name: String,
pub state: McpConnectionState,
pub calls_succeeded: u64,
pub calls_failed: u64,
pub enabled: bool,
}
pub trait McpTransport: Send + Sync {
fn connect(&self) -> BoxFuture<'_, Result<(), AgentError>>;
fn reconnect(&self) -> BoxFuture<'_, Result<(), AgentError>>;
fn status(&self) -> BoxFuture<'_, McpServerStatus>;
fn list_tools(&self) -> BoxFuture<'_, Result<Vec<McpToolDescriptor>, AgentError>>;
fn call_tool(
&self,
tool_name: &str,
arguments: Value,
) -> BoxFuture<'_, Result<Value, AgentError>>;
fn disconnect(&self) -> BoxFuture<'_, Result<(), AgentError>>;
}