get_task_instance
Retrieve specific task instance details from Apache Airflow workflows using DAG ID, task ID, and DAG run ID parameters for monitoring and debugging.
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:37-42 (handler)The main handler function for the 'get_task_instance' tool. It calls the Airflow TaskInstanceApi to fetch the task instance and returns it as 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:14-14 (registration)The registration tuple for the 'get_task_instance' tool within the get_all_functions() list, which is imported and used in main.py to register tools with MCP.(get_task_instance, "get_task_instance", "Get a task instance by DAG ID, task ID, and DAG run ID", True),
- src/airflow/taskinstance.py:8-8 (helper)Initialization of the TaskInstanceApi client used by the get_task_instance handler.task_instance_api = TaskInstanceApi(api_client)
- src/main.py:18-18 (registration)Import of get_all_functions from taskinstance module in main.py, which leads to registration of the tool.from src.airflow.taskinstance import get_all_functions as get_taskinstance_functions
- src/main.py:96-96 (registration)The generic tool registration loop in main.py where tools from get_all_functions (including get_task_instance) are added to the MCP app.app.add_tool(Tool.from_function(func, name=name, description=description))