#![allow(dead_code, unused_imports, unused_variables)]
use anyhow::Result;
use async_trait::async_trait;
use serde_json::Value;
use std::sync::Arc;
use tracing::{debug, info};
use super::client::McpClient;
use crate::tools::Tool;
pub struct McpTool {
name: String,
description: String,
schema: Value,
client: Arc<McpClient>,
remote_name: String,
}
impl McpTool {
pub fn new(
name: String,
description: String,
schema: Value,
client: Arc<McpClient>,
remote_name: String,
) -> Self {
Self {
name,
description,
schema,
client,
remote_name,
}
}
}
#[async_trait]
impl Tool for McpTool {
fn name(&self) -> &str {
&self.name
}
fn description(&self) -> &str {
&self.description
}
fn schema(&self) -> Value {
self.schema.clone()
}
async fn execute(&self, args: Value) -> Result<Value> {
debug!(
"Executing MCP tool '{}' (remote: '{}') with args: {}",
self.name, self.remote_name, args
);
self.client.call_tool(&self.remote_name, args).await
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_mcp_tool_name() {
let name = "mcp_github_create_issue";
let description = "Create a GitHub issue";
let schema = serde_json::json!({
"type": "object",
"properties": {
"title": {"type": "string"},
"body": {"type": "string"}
}
});
assert!(name.starts_with("mcp_"));
assert!(schema.get("type").is_some());
assert_eq!(description, "Create a GitHub issue");
}
}