get_dag
Retrieve a specific Directed Acyclic Graph (DAG) from Apache Airflow using its unique identifier to access workflow definitions and configurations.
Instructions
Get a DAG by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes |
Implementation Reference
- src/airflow/dag.py:79-88 (handler)The core handler function implementing the 'get_dag' tool logic: fetches DAG details from Airflow API, adds UI URL, and returns as text content.async def get_dag(dag_id: str) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: response = dag_api.get_dag(dag_id=dag_id) # Convert response to dictionary for easier manipulation response_dict = response.to_dict() # Add UI link to DAG response_dict["ui_url"] = get_dag_url(dag_id) return [types.TextContent(type="text", text=str(response_dict))]
- src/airflow/dag.py:19-19 (registration)Specific registration entry for the 'get_dag' tool within the get_all_functions() list for DAG-related tools.(get_dag, "get_dag", "Get a DAG by ID", True),
- src/main.py:90-91 (registration)The generic app.add_tool() call in main.py that registers the 'get_dag' handler (among others) to the MCP server.for func, name, description, *_ in functions: app.add_tool(func, name=name, description=description)
- src/airflow/dag.py:36-37 (helper)Helper utility to generate UI URL for DAGs, invoked by the get_dag handler.def get_dag_url(dag_id: str) -> str: return f"{AIRFLOW_HOST}/dags/{dag_id}/grid"