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))]

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