Skip to main content
Glama

get_flow_runs

Retrieve and filter workflow execution records by criteria like status, flow name, tags, or time range to monitor and analyze Prefect flow runs.

Instructions

Get a list of flow runs with optional filtering.

Args: limit: Maximum number of flow runs to return offset: Number of flow runs to skip flow_name: Filter by flow name state_type: Filter by state type (e.g., "RUNNING", "COMPLETED", "FAILED") state_name: Filter by state name deployment_id: Filter by deployment ID tags: Filter by tags start_time_before: ISO formatted datetime string start_time_after: ISO formatted datetime string

Returns: A list of flow runs with their details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deployment_idNo
flow_nameNo
limitNo
offsetNo
start_time_afterNo
start_time_beforeNo
state_nameNo
state_typeNo
tagsNo

Implementation Reference

  • The handler function implementing the 'get_flow_runs' tool logic. It queries the Prefect client for flow runs with applied filters, enriches with UI URLs, and returns as text content.
    @mcp.tool
    async def get_flow_runs(
        limit: Optional[int] = None,
        offset: Optional[int] = None,
        flow_name: Optional[str] = None,
        state_type: Optional[str] = None,
        state_name: Optional[str] = None,
        deployment_id: Optional[str] = None,
        tags: Optional[List[str]] = None,
        start_time_before: Optional[str] = None,
        start_time_after: Optional[str] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Get a list of flow runs with optional filtering.
        
        Args:
            limit: Maximum number of flow runs to return
            offset: Number of flow runs to skip
            flow_name: Filter by flow name
            state_type: Filter by state type (e.g., "RUNNING", "COMPLETED", "FAILED")
            state_name: Filter by state name
            deployment_id: Filter by deployment ID
            tags: Filter by tags
            start_time_before: ISO formatted datetime string
            start_time_after: ISO formatted datetime string
            
        Returns:
            A list of flow runs with their details
        """
        async with get_client() as client:
            # Build filter parameters
            filters = {}
            if flow_name:
                filters["flow_name"] = {"like_": f"%{flow_name}%"}
            if state_type:
                filters["state"] = {"type": {"any_": [state_type.upper()]}}
            if state_name:
                filters["state"] = {"name": {"any_": [state_name]}}
            if deployment_id:
                filters["deployment_id"] = {"eq_": UUID(deployment_id)}
            if tags:
                filters["tags"] = {"all_": tags}
            if start_time_after:
                filters["start_time"] = {"ge_": start_time_after}
            if start_time_before:
                if "start_time" in filters:
                    filters["start_time"]["le_"] = start_time_before
                else:
                    filters["start_time"] = {"le_": start_time_before}
            
            flow_runs = await client.read_flow_runs(
                limit=limit,
                offset=offset,
                **filters
            )
            
            # Add UI links to each flow run
            flow_runs_result = {
                "flow_runs": [
                    {
                        **flow_run.dict(),
                        "ui_url": get_flow_run_url(str(flow_run.id))
                    }
                    for flow_run in flow_runs
                ]
            }
            
            return [types.TextContent(type="text", text=str(flow_runs_result))]
  • The import statement in main.py that loads the flow_run module, triggering registration of the 'get_flow_runs' tool via its @mcp.tool decorator.
    if APIType.FLOW_RUN.value in apis:
        info("Loading Flow Run API...")
        from . import flow_run
  • Helper function used by the handler to generate UI URLs for flow runs.
    def get_flow_run_url(flow_run_id: str) -> str:
        base_url = PREFECT_API_URL.replace("/api", "")
        return f"{base_url}/flow-runs/{flow_run_id}"
  • The @mcp.tool decorator that registers the get_flow_runs function as an MCP tool.
    @mcp.tool
    async def get_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 states this is a 'Get' operation which implies read-only behavior, but doesn't address important aspects like authentication requirements, rate limits, pagination behavior (beyond mentioning limit/offset), error conditions, or what happens when no filters are provided. The description is minimal and leaves many behavioral questions unanswered.

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 organized parameter documentation. The 'Args:' and 'Returns:' sections provide logical grouping. While efficient, the initial purpose statement could be slightly more informative about the tool's scope relative to siblings. Every sentence serves a purpose with minimal waste.

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 9-parameter tool with no annotations and no output schema, the description provides adequate parameter documentation but lacks important context. The return value description ('A list of flow runs with their details') is vague - it doesn't specify what details are included or the response structure. Without annotations covering behavioral aspects and no output schema, the description should provide more complete information about the tool's operation and results.

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 a comprehensive parameter list with brief explanations for all 9 parameters, despite 0% schema description coverage. It clarifies what each filter does (e.g., 'Filter by flow name', 'Filter by state type', 'ISO formatted datetime string' for time filters). This significantly compensates for the schema's lack of descriptions, though some parameter details like format examples for tags or state_type values could be more specific.

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's purpose: 'Get a list of flow runs with optional filtering.' This specifies the verb ('Get') and resource ('flow runs'), and mentions filtering capability. However, it doesn't distinguish this tool from sibling tools like 'get_flow_run' (singular) or 'get_flow_runs_by_flow' - the description doesn't explain how this differs from those 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?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools that retrieve flow runs (get_flow_run, get_flow_runs_by_flow), there's no indication of when this general filtering tool is preferred over more specific ones. The description mentions optional filtering but doesn't provide context about typical use cases or limitations.

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