Skip to main content
Glama
nikhil-ganage

MCP Server Airflow Token

clear_task_instances

Clear specific task instances in Airflow workflows to resolve failures or restart jobs, allowing precise control over which tasks to reset based on criteria like date ranges and dependencies.

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 specified 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 in dag.py includes the registration tuple for clear_task_instances, which is later used in main.py to add the tool.
    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),
        ]
  • src/main.py:90-92 (registration)
    The generic registration loop in main.py where tools from all modules, including clear_task_instances from dag.py, are added to the MCP app using app.add_tool.
    for func, name, description, *_ in functions:
        app.add_tool(func, name=name, description=description)
Behavior2/5

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

With no annotations, the description carries full burden but lacks behavioral details. 'Clear' implies a destructive or mutative action, but it doesn't specify permissions needed, side effects (e.g., data loss, state changes), or response format. This is inadequate for a tool with 12 parameters and potential impact.

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

Conciseness4/5

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

The description is a single, efficient sentence with no wasted words, making it front-loaded and easy to parse. However, its brevity contributes to underspecification rather than optimal clarity.

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 tool's complexity (12 parameters, no annotations, no output schema), the description is incomplete. It doesn't cover parameter roles, behavioral traits, or output expectations, leaving significant gaps for an agent to understand and invoke the tool correctly.

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 parameters like 'dag_id', 'task_ids', and booleans (e.g., 'include_subdags', 'dry_run') are undocumented. The description adds no meaning beyond the schema, failing to explain what parameters do or how they interact, which is critical given the complexity.

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

Purpose3/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' states a verb ('Clear') and resource ('task instances'), providing a basic purpose. However, it's vague about what 'Clear' means (e.g., delete, reset, mark as cleared) and doesn't differentiate from sibling tools like 'clear_dag_run' or 'set_task_instances_state', leaving ambiguity in scope and action.

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. The description doesn't mention prerequisites, context (e.g., for debugging, cleanup), or comparisons to siblings like 'clear_dag_run' or 'delete_dag_run', leaving the agent without usage direction.

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/nikhil-ganage/mcp-server-airflow-token'

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