update_dag_run_state
Modify the execution status of an Airflow DAG run to manage workflow progression or resolve issues.
Instructions
Update a DAG run state by DAG ID and DAG run ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes | ||
| dag_run_id | Yes | ||
| state | No |
Implementation Reference
- src/airflow/dagrun.py:188-197 (handler)The async handler function that implements the core logic of the 'update_dag_run_state' tool by calling the Airflow DAGRunApi to update the state.async def update_dag_run_state( dag_id: str, dag_run_id: str, state: Optional[str] = None ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: update_dag_run_state = UpdateDagRunState(state=state) response = dag_run_api.update_dag_run_state( dag_id=dag_id, dag_run_id=dag_run_id, update_dag_run_state=update_dag_run_state, ) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/dagrun.py:17-29 (registration)The registration function that includes the 'update_dag_run_state' tool in the list of tools to be registered with MCP.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:9-9 (schema)Import of the UpdateDagRunState schema/model used for structuring the input parameters in the handler.from airflow_client.client.model.update_dag_run_state import UpdateDagRunState
- src/airflow/dagrun.py:14-14 (helper)Initialization of the DAGRunApi client instance used by the handler.dag_run_api = DAGRunApi(api_client)