get_task_instance
Retrieve a specific task instance in Apache Airflow by providing the DAG ID, task ID, and DAG run ID. Simplifies task monitoring and management within workflows.
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 | ||
| dag_run_id | Yes | ||
| task_id | Yes |
Implementation Reference
- src/airflow/taskinstance.py:37-41 (handler)The async handler function that implements the core logic of the 'get_task_instance' tool by calling the Airflow TaskInstanceApi and returning the response as formatted 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 module's get_all_functions() list, providing the function reference, name, description, and read-only flag.(get_task_instance, "get_task_instance", "Get a task instance by DAG ID, task ID, and DAG run ID", True),
- src/main.py:18-18 (registration)Import of the taskinstance module's get_all_functions into the main.py for inclusion in the central tool registration process.from src.airflow.taskinstance import get_all_functions as get_taskinstance_functions
- src/main.py:37-37 (registration)Mapping of APIType.TASKINSTANCE to the taskinstance functions getter in the central APITYPE_TO_FUNCTIONS dictionary.APIType.TASKINSTANCE: get_taskinstance_functions,
- src/main.py:95-96 (registration)The generic loop in main() that adds each tool (including get_task_instance) to the MCP app using Tool.from_function.for func, name, description, *_ in functions: app.add_tool(Tool.from_function(func, name=name, description=description))