clear_dag_run
Clear a specific DAG run in Apache Airflow by providing the DAG ID and run ID, enabling users to manage workflow execution directly through the MCP server interface.
Instructions
Clear a DAG run
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes | ||
| dag_run_id | Yes | ||
| dry_run | No |
Implementation Reference
- src/airflow/dagrun.py:207-212 (handler)The main handler function that executes the clear_dag_run tool logic using the Airflow API.async def clear_dag_run( dag_id: str, dag_run_id: str, dry_run: Optional[bool] = None ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: clear_dag_run = ClearDagRun(dry_run=dry_run) response = dag_run_api.clear_dag_run(dag_id=dag_id, dag_run_id=dag_run_id, clear_dag_run=clear_dag_run) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/dagrun.py:17-29 (registration)Module-level registration of the clear_dag_run tool within the list of DAG run related tools.def get_all_functions() -> list[tuple[Callable, str, str, bool]]: """Return list of (function, name, description, is_read_only) tuples for registration.""" return [ (post_dag_run, "post_dag_run", "Trigger a DAG by ID", False), (get_dag_runs, "get_dag_runs", "Get DAG runs by ID", True), (get_dag_runs_batch, "get_dag_runs_batch", "List DAG runs (batch)", True), (get_dag_run, "get_dag_run", "Get a DAG run by DAG ID and DAG run ID", True), (update_dag_run_state, "update_dag_run_state", "Update a DAG run state by DAG ID and DAG run ID", False), (delete_dag_run, "delete_dag_run", "Delete a DAG run by DAG ID and DAG run ID", False), (clear_dag_run, "clear_dag_run", "Clear a DAG run", False), (set_dag_run_note, "set_dag_run_note", "Update the DagRun note", False), (get_upstream_dataset_events, "get_upstream_dataset_events", "Get dataset events for a DAG run", True), ]
- src/airflow/dagrun.py:6-6 (schema)Import of the ClearDagRun Pydantic model used for input parameter validation and API call.from airflow_client.client.model.clear_dag_run import ClearDagRun
- src/main.py:9-9 (registration)Top-level import of dagrun module's tool list for aggregation into MCP server tools.from src.airflow.dagrun import get_all_functions as get_dagrun_functions
- src/main.py:95-96 (registration)Generic registration loop that adds all aggregated tools, including clear_dag_run, to the MCP app.for func, name, description, *_ in functions: app.add_tool(Tool.from_function(func, name=name, description=description))