get_dag_run
Retrieve a specific DAG run's details by providing the DAG ID and DAG run ID from Apache Airflow deployments.
Instructions
Get a DAG run by DAG ID and DAG run ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes | ||
| dag_run_id | Yes |
Implementation Reference
- src/airflow/dagrun.py:174-185 (handler)The main execution handler for the 'get_dag_run' tool. It calls the Airflow API to fetch the DAG run by dag_id and dag_run_id, adds a UI URL using get_dag_run_url helper, converts to dict, and returns as MCP TextContent.async def get_dag_run( dag_id: str, dag_run_id: str ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: response = dag_run_api.get_dag_run(dag_id=dag_id, dag_run_id=dag_run_id) # Convert response to dictionary for easier manipulation response_dict = response.to_dict() # Add UI link to DAG run response_dict["ui_url"] = get_dag_run_url(dag_id, dag_run_id) return [types.TextContent(type="text", text=str(response_dict))]
- src/airflow/dagrun.py:17-29 (registration)The get_all_functions() defines and returns the tuple for 'get_dag_run' tool (line 23) which is imported into src/main.py and used to register the tool via app.add_tool().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:32-33 (helper)Helper function to generate the UI URL for a DAG run, used in the get_dag_run handler and other functions.def get_dag_run_url(dag_id: str, dag_run_id: str) -> str: return f"{AIRFLOW_HOST}/dags/{dag_id}/grid?dag_run_id={dag_run_id}"
- src/main.py:90-92 (registration)The generic registration loop in main.py where tools from get_dagrun_functions() (including get_dag_run) are added to the MCP app via app.add_tool.for func, name, description, *_ in functions: app.add_tool(func, name=name, description=description)