fix(test): fix tool deserialization error (#68)

This commit is contained in:
4t145 2025-03-31 13:05:35 +08:00 • committed by GitHub
commit 0eea9aad4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 63 additions and 34 deletions

View file

@ -1,4 +1,4 @@
cargo-features = ["edition2024"]
[package]
name = "mcp-client-examples"

View file

@ -1,5 +1,3 @@
cargo-features = ["edition2024"]
[package]
name = "rig-integration"
edition = { workspace = true }

View file

@ -1,6 +1,6 @@
use std::collections::HashMap;
use rig::tool::{ToolDyn as RigTool, ToolEmbeddingDyn, ToolSet};
use rig::tool::{ToolDyn as RigTool, ToolSet};
use rmcp::{
RoleClient,
model::{CallToolRequestParam, CallToolResult, Tool as McpTool},
@ -24,7 +24,12 @@ impl RigTool for McpToolAdaptor {
{
Box::pin(std::future::ready(rig::completion::ToolDefinition {
name: self.name(),
description: self.tool.description.to_string(),
description: self
.tool
.description
.as_deref()
.unwrap_or_default()
.to_string(),
parameters: self.tool.schema_as_json_value(),
}))
}
@ -51,22 +56,6 @@ impl RigTool for McpToolAdaptor {
}
}
impl ToolEmbeddingDyn for McpToolAdaptor {
fn embedding_docs(&self) -> Vec<String> {
vec![
self.tool.description.clone().to_string(),
format!("Tool name: {}", self.tool.name),
format!("Tool capability: {}", self.tool.description),
]
}
fn context(&self) -> serde_json::Result<serde_json::Value> {
Ok(serde_json::json!({
"tool_name": self.tool.name,
}))
}
}
pub struct McpManager {
pub clients: HashMap<String, RunningService<RoleClient, ()>>,
}

View file

@ -1,4 +1,4 @@
cargo-features = ["edition2024"]
[package]
name = "mcp-server-examples"

View file

@ -1,5 +1,3 @@
cargo-features = ["edition2024"]
[package]
name = "transport"
edition = { workspace = true }

View file

@ -1,4 +1,4 @@
cargo-features = ["edition2024"]
[package]
name = "wasi"