Skip to main content
Glama
yangkyeongmo

MCP Server for Apache Airflow

by yangkyeongmo

post_dag_run

Trigger a DAG by ID in Apache Airflow to start workflow execution with optional parameters like run ID, data intervals, and execution date.

Instructions

Trigger a DAG by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dag_idYes
dag_run_idNo
data_interval_endNo
data_interval_startNo
execution_dateNo
logical_dateNo
noteNo

Implementation Reference

  • The main handler function for the 'post_dag_run' tool. It constructs a DAGRun object from provided parameters and triggers the DAG run using the Airflow DAGRunApi.
    async def post_dag_run(
        dag_id: str,
        dag_run_id: Optional[str] = None,
        data_interval_end: Optional[datetime] = None,
        data_interval_start: Optional[datetime] = None,
        execution_date: Optional[datetime] = None,
        logical_date: Optional[datetime] = None,
        note: Optional[str] = None,
        # state: Optional[str] = None,  # TODO: add state
    ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]:
        # Build kwargs dictionary with only non-None values
        kwargs = {}
    
        # Add non-read-only fields that can be set during creation
        if dag_run_id is not None:
            kwargs["dag_run_id"] = dag_run_id
        if data_interval_end is not None:
            kwargs["data_interval_end"] = data_interval_end
        if data_interval_start is not None:
            kwargs["data_interval_start"] = data_interval_start
        if execution_date is not None:
            kwargs["execution_date"] = execution_date
        if logical_date is not None:
            kwargs["logical_date"] = logical_date
        if note is not None:
            kwargs["note"] = note
    
        # Create DAGRun without read-only fields
        dag_run = DAGRun(**kwargs)
    
        response = dag_run_api.post_dag_run(dag_id=dag_id, dag_run=dag_run)
        return [types.TextContent(type="text", text=str(response.to_dict()))]
  • Registration of the 'post_dag_run' tool within the list of functions returned by get_all_functions(), used for MCP tool registration.
    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),
        ]

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