From bcfd5495df66f36484888e9a059fcca8ccb00928 Mon Sep 17 00:00:00 2001 From: Gautam Korlam Date: Mon, 28 Apr 2025 09:28:59 -0700 Subject: [PATCH] Make get_tool sync --- README.md | 2 +- src/tools/calculator.rs | 2 +- src/tools/file_system/directory.rs | 2 +- src/tools/file_system/mod.rs | 10 +++++----- src/tools/file_system/read.rs | 2 +- src/tools/file_system/search.rs | 2 +- src/tools/file_system/write.rs | 2 +- src/tools/mod.rs | 8 ++++---- src/tools/test_tool.rs | 4 ++-- tests/tools.rs | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6c1b303..4d718d9 100644 --- a/README.md +++ b/README.md @@ -318,7 +318,7 @@ use serde_json::Value; #[async_trait] pub trait ToolProvider: Send + Sync { // Return tool definition - async fn get_tool(&self) -> Tool; + fn get_tool(&self) -> Tool; // Execute tool with given arguments async fn execute(&self, arguments: Value) -> Result; diff --git a/src/tools/calculator.rs b/src/tools/calculator.rs index 34ab525..20f9f2f 100644 --- a/src/tools/calculator.rs +++ b/src/tools/calculator.rs @@ -163,7 +163,7 @@ impl CalculatorTool { #[async_trait] impl ToolProvider for CalculatorTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { let mut schema_properties = HashMap::new(); schema_properties.insert( "operation".to_string(), diff --git a/src/tools/file_system/directory.rs b/src/tools/file_system/directory.rs index 2daabcd..b7a6b4f 100644 --- a/src/tools/file_system/directory.rs +++ b/src/tools/file_system/directory.rs @@ -18,7 +18,7 @@ impl DirectoryTool { #[async_trait] impl ToolProvider for DirectoryTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { let mut schema_properties = HashMap::new(); schema_properties.insert( "operation".to_string(), diff --git a/src/tools/file_system/mod.rs b/src/tools/file_system/mod.rs index 6654980..87320cf 100644 --- a/src/tools/file_system/mod.rs +++ b/src/tools/file_system/mod.rs @@ -81,13 +81,13 @@ impl FileSystemTools { #[async_trait] impl ToolProvider for FileSystemTools { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { // Return composite tool definition containing all file system operations let mut tools = vec![ - self.read_tool.get_tool().await, - self.write_tool.get_tool().await, - self.directory_tool.get_tool().await, - self.search_tool.get_tool().await, + self.read_tool.get_tool(), + self.write_tool.get_tool(), + self.directory_tool.get_tool(), + self.search_tool.get_tool(), ]; // Return the first tool as the main tool definition diff --git a/src/tools/file_system/read.rs b/src/tools/file_system/read.rs index 7087209..2b7af69 100644 --- a/src/tools/file_system/read.rs +++ b/src/tools/file_system/read.rs @@ -43,7 +43,7 @@ impl ReadFileTool { #[async_trait] impl ToolProvider for ReadFileTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { let mut schema_properties = HashMap::new(); schema_properties.insert( "operation".to_string(), diff --git a/src/tools/file_system/search.rs b/src/tools/file_system/search.rs index a161ec0..7dbf354 100644 --- a/src/tools/file_system/search.rs +++ b/src/tools/file_system/search.rs @@ -78,7 +78,7 @@ impl SearchTool { #[async_trait] impl ToolProvider for SearchTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { let mut schema_properties = HashMap::new(); schema_properties.insert( "operation".to_string(), diff --git a/src/tools/file_system/write.rs b/src/tools/file_system/write.rs index d34905e..f7ec5e5 100644 --- a/src/tools/file_system/write.rs +++ b/src/tools/file_system/write.rs @@ -18,7 +18,7 @@ impl WriteFileTool { #[async_trait] impl ToolProvider for WriteFileTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { let mut schema_properties = HashMap::new(); schema_properties.insert( "operation".to_string(), diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 28e004e..e79b437 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -123,7 +123,7 @@ pub struct CallToolArgs { #[async_trait] pub trait ToolProvider: Send + Sync { /// Get tool definition - async fn get_tool(&self) -> Tool; + fn get_tool(&self) -> Tool; /// Execute tool async fn execute( @@ -183,7 +183,7 @@ impl ToolManager { } pub async fn register_tool(&self, provider: Arc) { - let tool = provider.get_tool().await; + let tool = provider.get_tool(); let mut tools = self.tools.write().await; tools.insert(tool.name.clone(), provider); @@ -220,7 +220,7 @@ impl ToolManager { } pub async fn update_tool(&self, provider: Arc) -> Result<(), McpError> { - let tool = provider.get_tool().await; + let tool = provider.get_tool(); let mut tools = self.tools.write().await; if tools.contains_key(&tool.name) { @@ -274,7 +274,7 @@ impl ToolManager { let mut tool_list = Vec::new(); for provider in tools.values() { - tool_list.push(provider.get_tool().await); + tool_list.push(provider.get_tool()); } Ok(ListToolsResponse { diff --git a/src/tools/test_tool.rs b/src/tools/test_tool.rs index 95e8f3d..e2652ea 100644 --- a/src/tools/test_tool.rs +++ b/src/tools/test_tool.rs @@ -21,7 +21,7 @@ impl TestTool { #[async_trait] impl ToolProvider for TestTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { Tool { name: "test_tool".to_string(), description: "Test Tool".to_string(), @@ -70,7 +70,7 @@ impl PingTool { #[async_trait] impl ToolProvider for PingTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { Tool { name: "ping_tool".to_string(), description: "Ping Tool".to_string(), diff --git a/tests/tools.rs b/tests/tools.rs index a1712ce..a87da02 100644 --- a/tests/tools.rs +++ b/tests/tools.rs @@ -14,7 +14,7 @@ struct MockCalculatorTool; #[async_trait] impl ToolProvider for MockCalculatorTool { - async fn get_tool(&self) -> Tool { + fn get_tool(&self) -> Tool { let mut properties = HashMap::new(); properties.insert( "operation".to_string(),