Skip to main content
Glama
yangkyeongmo

MCP Server for Apache Airflow

by yangkyeongmo

get_dag_runs

Retrieve and filter DAG execution runs from Apache Airflow by specifying criteria like date ranges, state, and pagination to monitor workflow performance.

Instructions

Get DAG runs by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dag_idYes
limitNo
offsetNo
execution_date_gteNo
execution_date_lteNo
start_date_gteNo
start_date_lteNo
end_date_gteNo
end_date_lteNo
updated_at_gteNo
updated_at_lteNo
stateNo
order_byNo

Implementation Reference

  • The primary handler function for the 'get_dag_runs' tool. It fetches DAG runs using the Airflow API with optional query parameters, enhances the response with UI links, and returns formatted text content.
    async def get_dag_runs(
        dag_id: str,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
        execution_date_gte: Optional[str] = None,
        execution_date_lte: Optional[str] = None,
        start_date_gte: Optional[str] = None,
        start_date_lte: Optional[str] = None,
        end_date_gte: Optional[str] = None,
        end_date_lte: Optional[str] = None,
        updated_at_gte: Optional[str] = None,
        updated_at_lte: Optional[str] = None,
        state: Optional[List[str]] = None,
        order_by: Optional[str] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        # Build parameters dictionary
        kwargs: Dict[str, Any] = {}
        if limit is not None:
            kwargs["limit"] = limit
        if offset is not None:
            kwargs["offset"] = offset
        if execution_date_gte is not None:
            kwargs["execution_date_gte"] = execution_date_gte
        if execution_date_lte is not None:
            kwargs["execution_date_lte"] = execution_date_lte
        if start_date_gte is not None:
            kwargs["start_date_gte"] = start_date_gte
        if start_date_lte is not None:
            kwargs["start_date_lte"] = start_date_lte
        if end_date_gte is not None:
            kwargs["end_date_gte"] = end_date_gte
        if end_date_lte is not None:
            kwargs["end_date_lte"] = end_date_lte
        if updated_at_gte is not None:
            kwargs["updated_at_gte"] = updated_at_gte
        if updated_at_lte is not None:
            kwargs["updated_at_lte"] = updated_at_lte
        if state is not None:
            kwargs["state"] = state
        if order_by is not None:
            kwargs["order_by"] = order_by
    
        response = dag_run_api.get_dag_runs(dag_id=dag_id, **kwargs)
    
        # Convert response to dictionary for easier manipulation
        response_dict = response.to_dict()
    
        # Add UI links to each DAG run
        for dag_run in response_dict.get("dag_runs", []):
            dag_run["ui_url"] = get_dag_run_url(dag_id, dag_run["dag_run_id"])
    
        return [types.TextContent(type="text", text=str(response_dict))]
  • Module-level registration function that includes the tuple for 'get_dag_runs' tool, providing the function reference, name, description, and read-only flag.
    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:95-97 (registration)
    Top-level tool registration loop in the main entrypoint, which adds the 'get_dag_runs' tool (imported via dagrun module) to the MCP app using Tool.from_function.
    for func, name, description, *_ in functions:
        app.add_tool(Tool.from_function(func, name=name, description=description))
  • Helper utility to generate the Airflow UI URL for a specific DAG run, used within the get_dag_runs handler to enhance the response.
    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}"
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers none. It doesn't indicate whether this is a read-only operation, what permissions might be required, whether results are paginated (despite having limit/offset parameters), what format the results return, or any error conditions. For a tool with 13 parameters and no annotation coverage, this is critically insufficient.

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 maximally concise at just four words. While this represents severe under-specification, from a pure conciseness perspective, there's zero wasted language. Every word earns its place, though collectively they provide inadequate information.

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

Completeness1/5

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

For a tool with 13 parameters, no annotations, no output schema, and 0% schema description coverage, the description is completely inadequate. It doesn't explain what the tool returns, how to interpret the numerous filtering parameters, what DAG runs are, or how this differs from similar tools. The agent would struggle to use this tool correctly without significant external knowledge.

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

Parameters1/5

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

Schema description coverage is 0%, meaning none of the 13 parameters have descriptions in the schema. The description 'Get DAG runs by ID' only vaguely references the 'dag_id' parameter but doesn't explain what a DAG ID is, what format it expects, or how it relates to the other 12 filtering parameters (date ranges, state, ordering, etc.). The description fails to compensate for the complete lack of parameter documentation.

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

Purpose2/5

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

The description 'Get DAG runs by ID' is a tautology that essentially restates the tool name 'get_dag_runs'. It doesn't specify what 'get' means (list, retrieve, fetch), nor does it explain what DAG runs are or how they differ from other DAG-related resources. While it mentions 'by ID', the required parameter is 'dag_id', which suggests it's filtering by DAG identifier rather than retrieving specific run IDs.

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

Usage Guidelines1/5

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

The description provides zero guidance on when to use this tool versus alternatives. With sibling tools like 'get_dag_run' (singular), 'get_dag_runs_batch', 'fetch_dags', and 'get_dag_details', there's no indication of which tool to choose for different scenarios. No prerequisites, limitations, or comparison context is provided.

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