Skip to main content
Glama

get_task_runs_by_flow_run

Retrieve task runs for a specific flow run in Prefect, with options to filter by state type, limit results, and paginate through large datasets.

Instructions

Get task runs for a specific flow run.

Args: flow_run_id: The flow run UUID limit: Maximum number of task runs to return offset: Number of task runs to skip state_type: Filter by state type (e.g., "RUNNING", "COMPLETED", "FAILED")

Returns: A list of task runs for the specified flow run

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
flow_run_idYes
limitNo
offsetNo
state_typeNo

Implementation Reference

  • The core handler function decorated with @mcp.tool, which registers and implements the get_task_runs_by_flow_run tool. It retrieves task runs associated with a specific flow run using the Prefect client, supports filtering by state_type, limit, and offset, adds UI links, and returns formatted results.
    @mcp.tool
    async def get_task_runs_by_flow_run(
        flow_run_id: str,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
        state_type: Optional[str] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        """
        Get task runs for a specific flow run.
        
        Args:
            flow_run_id: The flow run UUID
            limit: Maximum number of task runs to return
            offset: Number of task runs to skip
            state_type: Filter by state type (e.g., "RUNNING", "COMPLETED", "FAILED")
            
        Returns:
            A list of task runs for the specified flow run
        """
        async with get_client() as client:
            # Build filter using new filter objects
            flow_run_filter = FlowRunFilter(
                id=FlowRunFilterId(any_=[UUID(flow_run_id)])
            )
            
            task_run_filter = None
            if state_type:
                task_run_filter = TaskRunFilter(
                    state=TaskRunFilterState(
                        type=TaskRunFilterStateType(any_=[state_type.upper()])
                    )
                )
            
            task_runs = await client.read_task_runs(
                flow_run_filter=flow_run_filter,
                task_run_filter=task_run_filter,
                limit=limit,
                offset=offset or 0
            )
            
            # Add UI links to each task run
            task_runs_result = {
                "task_runs": [
                    {
                        **task_run.model_dump(),
                        "ui_url": get_task_run_url(str(task_run.id))
                    }
                    for task_run in task_runs
                ]
            }
            
            return [types.TextContent(type="text", text=str(task_runs_result))]
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'Get[s] task runs' (implying a read operation) and mentions pagination via limit/offset, but doesn't describe key behaviors: whether it's safe (read-only), what permissions are needed, how errors are handled (e.g., invalid flow_run_id), or if there are rate limits. For a tool with 4 parameters and no annotations, this leaves significant gaps in understanding its operation.

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

Conciseness5/5

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

The description is well-structured and front-loaded: the first sentence states the core purpose, followed by a clear 'Args:' section with bullet points for each parameter and a 'Returns:' statement. Every sentence earns its place, with no wasted words, making it easy to scan and understand quickly.

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 4 parameters, 0% schema coverage, no annotations, and no output schema, the description does an adequate job: it explains the tool's purpose and parameters. However, it lacks behavioral details (e.g., safety, errors) and doesn't fully describe the return value beyond 'A list of task runs' (no structure or examples). For a read operation with filtering and pagination, this is minimally viable but leaves room for improvement in context.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful context for all 4 parameters: flow_run_id is explained as 'The flow run UUID', limit as 'Maximum number of task runs to return', offset as 'Number of task runs to skip', and state_type as 'Filter by state type (e.g., "RUNNING", "COMPLETED", "FAILED")'. This clarifies purpose and usage beyond the bare schema, though it doesn't detail format constraints (e.g., UUID format) or default values.

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 task runs for a specific flow run.' It specifies the verb ('Get') and resource ('task runs'), and distinguishes it from siblings like 'get_task_runs' (which presumably gets all task runs) by focusing on a specific flow run. However, it doesn't explicitly differentiate from 'get_task_run' (singular) or 'get_flow_run' (which gets the flow run itself), so it's not a perfect 5.

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. It doesn't mention siblings like 'get_task_runs' (without flow run filter) or 'get_flow_run' (which might include task runs), nor does it specify prerequisites (e.g., needing a valid flow_run_id). The only implied usage is when you have a flow run ID and want its task runs, but this is basic and lacks explicit alternatives or exclusions.

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