Skip to main content
Glama
yangkyeongmo

MCP Server for Apache Airflow

by yangkyeongmo

clear_task_instances

Clear specific task instances in Apache Airflow to resolve failures or rerun tasks by specifying DAG, tasks, and time range.

Instructions

Clear a set of task instances

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dag_idYes
task_idsNo
start_dateNo
end_dateNo
include_subdagsNo
include_parentdagNo
include_upstreamNo
include_downstreamNo
include_futureNo
include_pastNo
dry_runNo
reset_dag_runsNo

Implementation Reference

  • The main handler function for the clear_task_instances tool. It constructs a ClearTaskInstances object from input parameters and calls the Airflow DAG API to clear the task instances.
    async def clear_task_instances(
        dag_id: str,
        task_ids: Optional[List[str]] = None,
        start_date: Optional[str] = None,
        end_date: Optional[str] = None,
        include_subdags: Optional[bool] = None,
        include_parentdag: Optional[bool] = None,
        include_upstream: Optional[bool] = None,
        include_downstream: Optional[bool] = None,
        include_future: Optional[bool] = None,
        include_past: Optional[bool] = None,
        dry_run: Optional[bool] = None,
        reset_dag_runs: Optional[bool] = None,
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        clear_request = {}
        if task_ids is not None:
            clear_request["task_ids"] = task_ids
        if start_date is not None:
            clear_request["start_date"] = start_date
        if end_date is not None:
            clear_request["end_date"] = end_date
        if include_subdags is not None:
            clear_request["include_subdags"] = include_subdags
        if include_parentdag is not None:
            clear_request["include_parentdag"] = include_parentdag
        if include_upstream is not None:
            clear_request["include_upstream"] = include_upstream
        if include_downstream is not None:
            clear_request["include_downstream"] = include_downstream
        if include_future is not None:
            clear_request["include_future"] = include_future
        if include_past is not None:
            clear_request["include_past"] = include_past
        if dry_run is not None:
            clear_request["dry_run"] = dry_run
        if reset_dag_runs is not None:
            clear_request["reset_dag_runs"] = reset_dag_runs
    
        clear_task_instances = ClearTaskInstances(**clear_request)
    
        response = dag_api.post_clear_task_instances(dag_id=dag_id, clear_task_instances=clear_task_instances)
        return [types.TextContent(type="text", text=str(response.to_dict()))]
  • The get_all_functions lists all tools for registration, including clear_task_instances with its 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_dags, "fetch_dags", "Fetch all DAGs", True),
            (get_dag, "get_dag", "Get a DAG by ID", True),
            (get_dag_details, "get_dag_details", "Get a simplified representation of DAG", True),
            (get_dag_source, "get_dag_source", "Get a source code", True),
            (pause_dag, "pause_dag", "Pause a DAG by ID", False),
            (unpause_dag, "unpause_dag", "Unpause a DAG by ID", False),
            (get_dag_tasks, "get_dag_tasks", "Get tasks for DAG", True),
            (get_task, "get_task", "Get a task by ID", True),
            (get_tasks, "get_tasks", "Get tasks for DAG", True),
            (patch_dag, "patch_dag", "Update a DAG", False),
            (patch_dags, "patch_dags", "Update multiple DAGs", False),
            (delete_dag, "delete_dag", "Delete a DAG", False),
            (clear_task_instances, "clear_task_instances", "Clear a set of task instances", False),
            (set_task_instances_state, "set_task_instances_state", "Set a state of task instances", False),
            (reparse_dag_file, "reparse_dag_file", "Request re-parsing of a DAG file", False),
        ]
Behavior1/5

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

With no annotations provided, the description carries full burden but offers no behavioral details. It doesn't clarify if 'clear' is destructive (e.g., deletes data), requires specific permissions, has side effects, or how it interacts with other operations. The term 'clear' is ambiguous without context on what happens to the cleared instances.

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 extremely concise with a single, straightforward sentence. It avoids redundancy and is front-loaded, though this brevity contributes to underspecification rather than clarity. Every word earns its place, but the place is minimal.

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?

Given the tool's complexity (12 parameters, no annotations, no output schema), the description is grossly inadequate. It fails to explain the tool's purpose beyond the name, provide usage context, disclose behavior, or clarify parameters. This leaves the agent unable to effectively select or invoke the tool.

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 all 12 parameters are undocumented in the schema. The description adds no parameter information—it doesn't explain what 'dag_id', 'task_ids', date ranges, boolean flags (e.g., 'include_subdags'), or 'dry_run' do. This leaves the agent with no semantic understanding of inputs.

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 'Clear a set of task instances' restates the tool name with minimal elaboration, making it tautological. It specifies the verb 'clear' and resource 'task instances', but lacks detail on what 'clear' means operationally (e.g., delete, reset, mark as cleared) and doesn't distinguish it from sibling tools like 'clear_dag_run' or 'set_task_instances_state'.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites, appropriate contexts, or exclusions, leaving the agent to infer usage from the tool name alone. This is particularly problematic given multiple sibling tools that might handle similar operations on tasks or DAGs.

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