Skip to main content
Glama
fortunto2

Prefect MCP Server

by fortunto2

search_flow_runs_by_state

Find Prefect workflow runs by their execution state to monitor progress, identify issues, or analyze performance. Filter by state type or name to focus on specific run categories.

Instructions

Search for flow runs by state.

Args:
    state_type: Optional state type (e.g., "COMPLETED", "FAILED", "CRASHED").
    state_name: Optional state name (e.g., "Completed", "Failed").
    limit: Maximum number of flow runs to return (default 20).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
state_typeNo
state_nameNo
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function implementing the 'search_flow_runs_by_state' tool. It is decorated with @mcp.tool() for automatic registration in the MCP server. The function builds a FlowRunFilter based on state_type or state_name, queries the Prefect client for matching flow runs, and returns a dictionary with the list of flow runs and count.
    @mcp.tool()
    async def search_flow_runs_by_state(
        ctx: Context,
        state_type: Optional[str] = None,
        state_name: Optional[str] = None,
        limit: int = 20,
    ) -> Dict[str, Any]:
        """Search for flow runs by state.
    
        Args:
            state_type: Optional state type (e.g., "COMPLETED", "FAILED", "CRASHED").
            state_name: Optional state name (e.g., "Completed", "Failed").
            limit: Maximum number of flow runs to return (default 20).
        """
        filter_dict = {}
    
        if state_type:
            filter_dict["state"] = {"type": {"equals": state_type}}
    
        if state_name:
            filter_dict["state"] = {"name": {"equals": state_name}}
    
        async with get_client() as client:
            flow_run_filter = FlowRunFilter(**filter_dict) if filter_dict else None
            flow_runs = await client.read_flow_runs(
                flow_run_filter=flow_run_filter, limit=limit
            )
            return {
                "flow_runs": [run.model_dump() for run in flow_runs],
                "count": len(flow_runs),
            }
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. It mentions the tool searches and returns results with a limit, but doesn't cover important aspects like whether this is a read-only operation, potential rate limits, authentication requirements, pagination behavior, or what happens when no parameters are provided (all optional).

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 well-structured with a clear purpose statement followed by parameter explanations. Each sentence adds value, though the parameter explanations could be slightly more concise by combining related parameters.

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?

Given the tool has an output schema (which handles return values), 3 parameters with 0% schema coverage, and no annotations, the description does an adequate job explaining the purpose and parameters. However, it lacks behavioral context and usage guidance, making it incomplete for optimal agent understanding.

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?

The description provides clear examples for state_type and state_name parameters (e.g., 'COMPLETED', 'Failed') and specifies the default value for limit. With 0% schema description coverage, this significantly compensates by explaining what each parameter means and how to use them, though it doesn't clarify the relationship between state_type and state_name.

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 tool searches for flow runs by state, which is a specific verb (search) and resource (flow runs). However, it doesn't distinguish itself from sibling tools like 'filter_flow_runs' or 'list_flow_runs', which likely offer similar functionality with different filtering approaches.

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 on when to use this tool versus alternatives like 'filter_flow_runs' or 'list_flow_runs'. The description only explains what parameters it accepts, not the context or scenarios where this specific search method is preferred.

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/fortunto2/prefect-mcp-server'

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