Skip to main content
Glama
yangkyeongmo

MCP Server for Apache Airflow

by yangkyeongmo

get_dag_run

Retrieve specific DAG run details from Apache Airflow by providing DAG ID and run ID for workflow monitoring and debugging.

Instructions

Get a DAG run by DAG ID and DAG run ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dag_idYes
dag_run_idYes

Implementation Reference

  • The core handler function for the 'get_dag_run' tool. Fetches the DAG run details from Airflow API, adds a UI URL using the 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))]
  • Module-level registration function that includes the 'get_dag_run' tool in its list of tools to be registered with the MCP server.
    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/main.py:6-20 (registration)
    Imports the get_all_functions from dagrun module (line 9) and maps it in APITYPE_TO_FUNCTIONS dict (line 28, not shown) for top-level tool registration.
    from src.airflow.config import get_all_functions as get_config_functions
    from src.airflow.connection import get_all_functions as get_connection_functions
    from src.airflow.dag import get_all_functions as get_dag_functions
    from src.airflow.dagrun import get_all_functions as get_dagrun_functions
    from src.airflow.dagstats import get_all_functions as get_dagstats_functions
    from src.airflow.dataset import get_all_functions as get_dataset_functions
    from src.airflow.eventlog import get_all_functions as get_eventlog_functions
    from src.airflow.importerror import get_all_functions as get_importerror_functions
    from src.airflow.monitoring import get_all_functions as get_monitoring_functions
    from src.airflow.plugin import get_all_functions as get_plugin_functions
    from src.airflow.pool import get_all_functions as get_pool_functions
    from src.airflow.provider import get_all_functions as get_provider_functions
    from src.airflow.taskinstance import get_all_functions as get_taskinstance_functions
    from src.airflow.variable import get_all_functions as get_variable_functions
    from src.airflow.xcom import get_all_functions as get_xcom_functions
  • Helper function used by the handler to generate the UI URL for the DAG run.
    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:95-96 (registration)
    The loop where all collected functions, including get_dag_run, are registered as MCP tools using app.add_tool.
    for func, name, description, *_ in functions:
        app.add_tool(Tool.from_function(func, name=name, description=description))
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states it 'gets' a DAG run, implying a read-only operation, but doesn't disclose behavioral traits like error handling (e.g., what happens if IDs are invalid), authentication needs, rate limits, or response format. This leaves gaps for safe and effective use.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it directly states the tool's purpose without fluff. It's appropriately sized for a simple retrieval tool and front-loaded with essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, no output schema, and a read operation with two required parameters, the description is incomplete. It lacks details on parameter semantics, behavioral context (e.g., errors, permissions), and what the tool returns, making it inadequate for reliable agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions parameters 'dag_id' and 'dag_run_id' but adds no meaning beyond their names—no explanation of what these IDs represent, their format, or where to obtain them. This is insufficient for a tool with two required parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('a DAG run'), specifying it's retrieved by DAG ID and DAG run ID. It distinguishes from sibling tools like 'get_dag_runs' (plural) which likely lists multiple runs, but doesn't explicitly contrast with 'get_dag' or 'get_task_instance' which fetch different resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing existing DAG and run IDs), contrast with 'get_dag_runs' for listing runs, or specify use cases like monitoring or debugging. The agent must infer usage from the name and context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yangkyeongmo/mcp-server-apache-airflow'

If you have feedback or need assistance with the MCP directory API, please join our Discord server