get_task_instance
Retrieve specific task instance details from Apache Airflow using DAG ID, task ID, and DAG run ID parameters for workflow monitoring and management.
Instructions
Get a task instance by DAG ID, task ID, and DAG run ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | Yes | ||
| task_id | Yes | ||
| dag_run_id | Yes |
Implementation Reference
- src/airflow/taskinstance.py:25-29 (handler)The asynchronous handler function that implements the core logic of the 'get_task_instance' tool by calling the Airflow TaskInstanceApi to retrieve the task instance and formatting it as MCP TextContent.async def get_task_instance( dag_id: str, task_id: str, dag_run_id: str ) -> List[Union[types.TextContent, types.ImageContent, types.EmbeddedResource]]: response = task_instance_api.get_task_instance(dag_id=dag_id, dag_run_id=dag_run_id, task_id=task_id) return [types.TextContent(type="text", text=str(response.to_dict()))]
- src/airflow/taskinstance.py:11-22 (registration)The get_all_functions() function that registers the 'get_task_instance' tool (line 14) along with related task instance tools, which is later imported and used in src/main.py 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 [ (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, ), ]
- src/airflow/taskinstance.py:8-8 (helper)Initialization of the TaskInstanceApi client instance used by the get_task_instance handler.task_instance_api = TaskInstanceApi(api_client)