use rust_mcp_sdk::macros::{JsonSchema, mcp_tool};
use rust_mcp_sdk::schema::CallToolResult;
use rust_mcp_sdk::schema::schema_utils::CallToolError;
use serde_json::Value;
use crate::client::ApiClient;
#[mcp_tool(
name = "retry_run",
description = "Retry a failed, cancelled, or retrying workflow execution. Creates a new run with the same workflow and payload."
)]
#[derive(Debug, serde::Deserialize, serde::Serialize, JsonSchema)]
pub struct RetryRunTool {
pub run_id: String,
}
impl RetryRunTool {
pub async fn run(&self, client: &ApiClient) -> Result<CallToolResult, CallToolError> {
let path = format!("/runs/{}/retry", self.run_id);
let result: Value = client
.post_action(&path)
.await
.map_err(CallToolError::new)?;
let text = serde_json::to_string_pretty(&result).map_err(CallToolError::new)?;
Ok(CallToolResult::text_content(vec![text.into()]))
}
}