use rmcp::{
RoleClient,
model::{CallToolRequestParams, CallToolResult, ContentBlock},
service::RunningService,
};
pub type Client = RunningService<RoleClient, ()>;
pub async fn call_tool(client: &Client, name: &str, args: serde_json::Value) -> CallToolResult {
client
.call_tool(
CallToolRequestParams::new(name.to_string())
.with_arguments(args.as_object().expect("args object").clone()),
)
.await
.expect("tool call succeeds")
}
#[allow(dead_code)]
pub fn python_invocation() -> Vec<String> {
const CANDIDATES: &[&[&str]] = &[&["python3"], &["python"], &["py", "-3"]];
for candidate in CANDIDATES {
let probe = std::process::Command::new(candidate[0])
.args(&candidate[1..])
.arg("--version")
.output();
if probe.map(|out| out.status.success()).unwrap_or(false) {
return candidate.iter().map(|s| s.to_string()).collect();
}
}
panic!("no Python interpreter (python3/python/py) found for child MCP fixtures")
}
#[allow(dead_code)]
pub fn text(result: &CallToolResult) -> String {
result
.content
.iter()
.filter_map(|block| match block {
ContentBlock::Text(t) => Some(t.text.clone()),
_ => None,
})
.collect::<Vec<_>>()
.join("")
}