Skip to main content
Glama

MCP Server Airflow Token

get_tasks

Retrieve and list tasks associated with a specific DAG in Apache Airflow deployments, enabling users to view task details and organization within workflows.

Instructions

Get tasks for DAG

Input Schema

NameRequiredDescriptionDefault
dag_idYes
order_byNo

Input Schema (JSON Schema)

{ "properties": { "dag_id": { "title": "Dag Id", "type": "string" }, "order_by": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Order By" } }, "required": [ "dag_id" ], "type": "object" }

Implementation Reference

  • The main handler function that executes the 'get_tasks' tool. It accepts a required 'dag_id' and optional 'order_by', calls the Airflow DAG API to retrieve tasks, and returns the response formatted as MCP TextContent.
    async def get_tasks( dag_id: str, order_by: Optional[str] = None ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: kwargs = {} if order_by is not None: kwargs["order_by"] = order_by response = dag_api.get_tasks(dag_id=dag_id, **kwargs) return [types.TextContent(type="text", text=str(response.to_dict()))]
  • Registers the 'get_tasks' tool (at line 26 of the returned list) by including it in the list of DAG-related functions provided to the MCP server via src/main.py. Each entry is a tuple of (function, name, description, read_only).
    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:22-38 (registration)
    Maps APIType.DAG to get_dag_functions (imported from src.airflow.dag.get_all_functions at line 7), enabling the registration of DAG tools including 'get_tasks' when the DAG API is selected.
    APITYPE_TO_FUNCTIONS = { APIType.CONFIG: get_config_functions, APIType.CONNECTION: get_connection_functions, APIType.DAG: get_dag_functions, APIType.DAGRUN: get_dagrun_functions, APIType.DAGSTATS: get_dagstats_functions, APIType.DATASET: get_dataset_functions, APIType.EVENTLOG: get_eventlog_functions, APIType.IMPORTERROR: get_importerror_functions, APIType.MONITORING: get_monitoring_functions, APIType.PLUGIN: get_plugin_functions, APIType.POOL: get_pool_functions, APIType.PROVIDER: get_provider_functions, APIType.TASKINSTANCE: get_taskinstance_functions, APIType.VARIABLE: get_variable_functions, APIType.XCOM: get_xcom_functions, }
  • src/main.py:90-91 (registration)
    The loop in main() that actually calls app.add_tool for each function from get_all_functions(), registering 'get_tasks' with its name and description in the MCP app.
    for func, name, description, *_ in functions: app.add_tool(func, name=name, description=description)

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