ironflow-mcp 0.1.2

MCP server for Ironflow workflow orchestration
//! `retry_run` MCP tool.

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;

/// Retry a failed workflow execution.
#[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 {
    /// The run ID (UUID) to retry.
    pub run_id: String,
}

impl RetryRunTool {
    /// Execute the tool against the Ironflow API.
    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()]))
    }
}