Skip to main content
Glama

set_flow_run_state

Update the execution status of a Prefect workflow run by setting its state to values like SCHEDULED, RUNNING, COMPLETED, or FAILED with an optional message.

Instructions

Set a flow run's state.

Args: flow_run_id: The flow run UUID state: The new state to set (e.g., "SCHEDULED", "RUNNING", "COMPLETED", "FAILED") message: An optional message explaining the state change

Returns: Result of the state change operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
flow_run_idYes
messageNo
stateYes

Implementation Reference

  • The main handler function for the 'set_flow_run_state' MCP tool. It maps string state names to Prefect state objects and uses the Prefect client to update the flow run state.
    async def set_flow_run_state(
        flow_run_id: str,
        state: str,
        message: Optional[str] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Set a flow run's state.
        
        Args:
            flow_run_id: The flow run UUID
            state: The new state to set (e.g., "SCHEDULED", "RUNNING", "COMPLETED", "FAILED")
            message: An optional message explaining the state change
            
        Returns:
            Result of the state change operation
        """
        async with get_client() as client:
            state_obj = None
            if state.upper() == "SCHEDULED":
                state_obj = Scheduled(message=message)
            elif state.upper() == "RUNNING":
                state_obj = Running(message=message)
            elif state.upper() == "COMPLETED":
                state_obj = Completed(message=message)
            elif state.upper() == "FAILED":
                state_obj = Failed(message=message)
            elif state.upper() == "PENDING":
                state_obj = Pending(message=message)
            elif state.upper() == "CANCELLED":
                state_obj = Cancelled(message=message)
            else:
                return [types.TextContent(
                    type="text", 
                    text=f"Invalid state '{state}'. Must be one of: SCHEDULED, RUNNING, COMPLETED, FAILED, PENDING, CANCELLED"
                )]
            
            result = await client.set_flow_run_state(
                flow_run_id=UUID(flow_run_id),
                state=state_obj
            )
            
            return [types.TextContent(type="text", text=str(result.dict()))]

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/allen-munsch/mcp-prefect'

If you have feedback or need assistance with the MCP directory API, please join our Discord server