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()))]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it mentions this is a state-setting operation (implying mutation), it doesn't describe permissions required, whether the operation is idempotent, what happens with invalid states, or any rate limits. The description provides minimal behavioral context beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by Args and Returns sections. Each sentence serves a purpose, though the 'Returns' line is somewhat vague ('Result of the state change operation'). Overall, it's appropriately sized and well-organized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description provides basic parameter explanations but lacks critical context about behavioral implications, error conditions, and what constitutes valid state transitions. It's minimally adequate but leaves significant gaps for an agent to understand the full operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates well by explaining all three parameters: 'flow_run_id' is identified as a UUID, 'state' gets example values, and 'message' is explained as optional explanatory text. This adds meaningful semantics beyond the bare schema, though it doesn't specify format constraints or validation rules.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Set a flow run's state') and identifies the resource ('flow run'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling tools like 'set_task_run_state' or 'cancel_flow_run' that also modify flow/task run states, so it doesn't fully differentiate from alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives like 'cancel_flow_run', 'restart_flow_run', or 'set_task_run_state'. The description lacks context about appropriate state transitions, prerequisites, or when this operation is valid versus other state-changing operations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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