alexhancock/mcp-crate-cleanup (#4885)

This commit is contained in:
Alex Hancock
2025-09-29 17:00:17 -04:00
committed by GitHub
parent 2bd18a757b
commit cb0eca9966
78 changed files with 1039 additions and 1090 deletions
+31 -10
View File
@@ -390,9 +390,8 @@ mod tests {
use super::*;
use crate::conversation::message::Message;
use anyhow::Result;
use mcp_core::tool::ToolCall;
use rmcp::model::Content;
use serde_json::json;
use rmcp::model::{CallToolRequestParam, Content};
use rmcp::object;
// Helper function to create a user text message with a specified token count
fn user_text(index: usize, tokens: usize) -> (Message, usize) {
@@ -407,7 +406,11 @@ mod tests {
}
// Helper function to create a tool request message with a specified token count
fn assistant_tool_request(id: &str, tool_call: ToolCall, tokens: usize) -> (Message, usize) {
fn assistant_tool_request(
id: &str,
tool_call: CallToolRequestParam,
tokens: usize,
) -> (Message, usize) {
(
Message::assistant().with_tool_request(id, Ok(tool_call)),
tokens,
@@ -458,7 +461,10 @@ mod tests {
user_text(1, 10).0,
assistant_tool_request(
"tool1",
ToolCall::new("read_file", json!({"path": "large_file.txt"})),
CallToolRequestParam {
name: "read_file".into(),
arguments: Some(object!({"path": "large_file.txt"})),
},
20,
)
.0,
@@ -520,8 +526,14 @@ mod tests {
#[test]
fn test_complex_conversation_with_tools() -> Result<()> {
// Simulating a real conversation with multiple tool interactions
let tool_call1 = ToolCall::new("file_read", json!({"path": "/tmp/test.txt"}));
let tool_call2 = ToolCall::new("database_query", json!({"query": "SELECT * FROM users"}));
let tool_call1 = CallToolRequestParam {
name: "file_read".into(),
arguments: Some(object!({"path": "/tmp/test.txt"})),
};
let tool_call2 = CallToolRequestParam {
name: "database_query".into(),
arguments: Some(object!({"query": "SELECT * FROM users"})),
};
let messages = vec![
user_text(1, 15).0, // Initial user query
@@ -622,9 +634,18 @@ mod tests {
fn test_multi_tool_chain() -> Result<()> {
// Simulate a chain of dependent tool calls
let tool_calls = vec![
ToolCall::new("git_status", json!({})),
ToolCall::new("git_diff", json!({"file": "main.rs"})),
ToolCall::new("git_commit", json!({"message": "Update"})),
CallToolRequestParam {
name: "git_status".into(),
arguments: Some(object!({})),
},
CallToolRequestParam {
name: "git_diff".into(),
arguments: Some(object!({"file": "main.rs"})),
},
CallToolRequestParam {
name: "git_commit".into(),
arguments: Some(object!({"message": "Update"})),
},
];
let mut messages = Vec::new();