get_tasks
Retrieve tasks from an Apache Airflow DAG to manage workflow execution and monitor task status.
Instructions
Get tasks for DAG
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes | ||
| order_by | No |
Implementation Reference
- src/airflow/dag.py:181-189 (handler)The async handler function implementing the 'get_tasks' MCP tool. It accepts a dag_id (required) and optional order_by, calls the Airflow DAGApi.get_tasks, and returns the response as TextContent.async def get_tasks( dag_id: str, order_by: Optional[str] = None ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: kwargs = {} if order_by is not None: kwargs["order_by"] = order_by response = dag_api.get_tasks(dag_id=dag_id, **kwargs) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/dag.py:26-26 (registration)The registration tuple for the 'get_tasks' tool within the get_all_functions() list returned from dag.py. This tuple (function, name, description, read_only) is used by src/main.py to register the tool with the MCP server.(get_tasks, "get_tasks", "Get tasks for DAG", True),
- src/main.py:86-97 (registration)The code in main.py that imports get_all_functions from dag.py (via line 8), calls it for APIType.DAG, and registers each tool (including get_tasks) with the FastMCP app using Tool.from_function and app.add_tool.try: functions = get_function() except NotImplementedError: continue # Filter functions for read-only mode if requested if read_only: functions = filter_functions_for_read_only(functions) for func, name, description, *_ in functions: app.add_tool(Tool.from_function(func, name=name, description=description))