ironflow-mcp 0.1.2

MCP server for Ironflow workflow orchestration
//! `approve_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;

/// Approve a run that is awaiting human approval.
#[mcp_tool(
    name = "approve_run",
    description = "Approve a workflow execution that is waiting for human approval. The run will resume execution from where it was paused."
)]
#[derive(Debug, serde::Deserialize, serde::Serialize, JsonSchema)]
pub struct ApproveRunTool {
    /// The run ID (UUID) to approve.
    pub run_id: String,
}

impl ApproveRunTool {
    /// Execute the tool against the Ironflow API.
    pub async fn run(&self, client: &ApiClient) -> Result<CallToolResult, CallToolError> {
        let path = format!("/runs/{}/approve", 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()]))
    }
}