icarus_core/
tool.rs

1//! Tool abstraction for Icarus MCP servers
2
3use crate::error::Result;
4use async_trait::async_trait;
5use rmcp::model::Tool;
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8
9/// Information about a tool
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct ToolInfo {
12    pub name: String,
13    pub description: String,
14    pub input_schema: Value,
15}
16
17/// Storage requirements for a tool
18#[derive(Debug, Clone, Default)]
19pub struct StorageRequirements {
20    /// Estimated stable memory usage in bytes
21    pub stable_memory: Option<u64>,
22    /// Whether the tool needs persistent state
23    pub requires_persistence: bool,
24}
25
26/// Core trait for Icarus tools that integrate with rmcp
27#[async_trait]
28pub trait IcarusTool: Send + Sync {
29    /// Get tool information
30    fn info(&self) -> ToolInfo;
31
32    /// Convert to rmcp tool representation
33    fn to_rmcp_tool(&self) -> Tool;
34
35    /// Check if the tool requires stable storage
36    fn requires_stable_storage(&self) -> bool {
37        false
38    }
39
40    /// Get storage requirements for capacity planning
41    fn storage_requirements(&self) -> StorageRequirements {
42        StorageRequirements::default()
43    }
44
45    /// Execute the tool with given arguments
46    async fn execute(&self, args: Value) -> Result<Value>;
47}