Skip to main content
Glama
yangkyeongmo

MCP Server for Apache Airflow

by yangkyeongmo

list_task_instances

Retrieve task instances for a specific DAG and run in Apache Airflow to monitor execution status and filter by date, duration, or state.

Instructions

List task instances by DAG ID and DAG run ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dag_idYes
dag_run_idYes
execution_date_gteNo
execution_date_lteNo
start_date_gteNo
start_date_lteNo
end_date_gteNo
end_date_lteNo
updated_at_gteNo
updated_at_lteNo
duration_gteNo
duration_lteNo
stateNo
poolNo
queueNo
limitNo
offsetNo

Implementation Reference

  • Main handler function for the 'list_task_instances' tool. It builds query parameters based on inputs and calls the Airflow TaskInstanceApi to list task instances, returning the response as text.
    async def list_task_instances(
        dag_id: str,
        dag_run_id: str,
        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,
        duration_gte: Optional[float] = None,
        duration_lte: Optional[float] = None,
        state: Optional[List[str]] = None,
        pool: Optional[List[str]] = None,
        queue: Optional[List[str]] = None,
        limit: Optional[int] = None,
        offset: Optional[int] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        # Build parameters dictionary
        kwargs: Dict[str, Any] = {}
        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 duration_gte is not None:
            kwargs["duration_gte"] = duration_gte
        if duration_lte is not None:
            kwargs["duration_lte"] = duration_lte
        if state is not None:
            kwargs["state"] = state
        if pool is not None:
            kwargs["pool"] = pool
        if queue is not None:
            kwargs["queue"] = queue
        if limit is not None:
            kwargs["limit"] = limit
        if offset is not None:
            kwargs["offset"] = offset
    
        response = task_instance_api.get_task_instances(dag_id=dag_id, dag_run_id=dag_run_id, **kwargs)
        return [types.TextContent(type="text", text=str(response.to_dict()))]
  • Registration function that includes 'list_task_instances' in the list of tools to be registered with MCP, 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 [
            (get_task_instance, "get_task_instance", "Get a task instance by DAG ID, task ID, and DAG run ID", True),
            (list_task_instances, "list_task_instances", "List task instances by DAG ID and DAG run ID", True),
            (
                update_task_instance,
                "update_task_instance",
                "Update a task instance by DAG ID, DAG run ID, and task ID",
                False,
            ),
            (
                get_log,
                "get_log",
                "Get the log from a task instance by DAG ID, task ID, DAG run ID and task try number",
                True,
            ),
            (
                list_task_instance_tries,
                "list_task_instance_tries",
                "List task instance tries by DAG ID, DAG run ID, and task ID",
                True,
            ),
        ]
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's a list operation (implied read-only) but doesn't disclose behavioral traits like pagination (implied by limit/offset parameters), rate limits, authentication needs, return format, or whether it's destructive. The description is minimal and lacks critical operational context.

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?

Extremely concise with a single, front-loaded sentence that states the core purpose. There's no wasted text, though this brevity contributes to gaps in other dimensions.

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 the complexity (17 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the rich filtering options, return values, or operational behavior. For a tool with many parameters and no structured documentation, this minimal description is inadequate.

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 only mentions 'dag_id' and 'dag_run_id', ignoring 15 other parameters (e.g., date ranges, state, pool, limit/offset). No parameter semantics, formats, or examples are provided, leaving most inputs undocumented.

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 ('List') and resource ('task instances'), specifying filtering by 'DAG ID and DAG run ID'. It distinguishes from siblings like 'get_task_instance' (singular) and 'list_task_instance_tries', but doesn't explicitly differentiate from broader listing tools like 'get_dag_runs'.

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 on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing valid DAG IDs), exclusions, or compare with siblings like 'get_task_instance' (for single instance) or 'list_task_instance_tries' (for retry details).

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