## Tool: `get_task_instance`

Retrieves details of a specific task instance from a Managed Airflow environment.

Use this tool to retrieve details of a specific task instance, such as its state, start time, end time, or parameters, to understand its status or to debug a failure.

This tool does not return task instance logs directly. Instead, use the `cloud_logging_filter` field from the response to query Cloud Logging for the logs for this task instance.

The following code sample shows how to use `curl` to call the `get_task_instance` MCP tool.

| Curl Request |
|---|
| ```bash curl --location 'https://composer.{region}.rep.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "get_task_instance", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' ``` |

## Input Schema

Parameters of the `get_task_instance` tool.

### GetTaskInstanceRequestMCP

| JSON representation |
|---|
| ``` { "environment": string, "dagId": string, "dagRunId": string, "taskId": string, // Union field `_map_index` can be only one of the following: "mapIndex": integer // End of list of possible types for union field `_map_index`. } ``` |

| Fields ||
|---|---|
| `environment` | `string` Required. The name of the environment. Format: `projects/{projectId}/locations/{locationId}/environments/{environmentId}` |
| `dagId` | `string` Required. The Airflow DAG ID. |
| `dagRunId` | `string` Required. The Airflow DAG run ID. |
| `taskId` | `string` Required. The Airflow task ID. |
| Union field `_map_index`. `_map_index` can be only one of the following: ||
| `mapIndex` | `integer` Optional. For mapped tasks, the map index of the task. It should not be populated for non-mapped tasks. |

## Output Schema

Task instance in a DAG run.

### TaskInstance

| JSON representation |
|---|
| ``` { "name": string, "id": string, "taskId": string, "dagRunId": string, "dagId": string, "taskType": string, "executionDate": string, "startDate": string, "endDate": string, "runAfter": string, "state": enum (`https://docs.cloud.google.com/composer/docs/reference/mcp/tools_list/get_task_instance#Output.Schema.State`), "tryNumber": integer, "hostname": string, "queuedDttm": string, "pool": string, "queue": string, "priorityWeight": integer, "maxTries": integer, "isDynamicallyMapped": boolean, "mapIndex": integer, "externalExecutorId": string, "renderedMapIndex": string, "note": string, "cloudLoggingFilter": string } ``` |

| Fields ||
|---|---|
| `name` | `string` Required. The resource name of the task instance, in the form: "projects/{project_id}/locations/{location_id}/environments/{environment_id}/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_instance_id_with_optional_map_index}". |
| `id` | `string` The task instance ID. It is the same as the task ID of a DAG. |
| `taskId` | `string` The task instance ID. It is the same as the task ID in the DAG. |
| `dagRunId` | `string` The DAG run ID the task instance belongs to. |
| `dagId` | `string` The DAG ID of the DAG whose execution is described by the DAG run the taskInstance belongs to. |
| `taskType` | `string` The operator used in this task. |
| `executionDate` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Execution date for the task. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `startDate` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Timestamp when the task instance started execution. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `endDate` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Timestamp when the task instance finished execution. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `runAfter` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Timestamp when the parent DAG run was scheduled to start. Added in Airflow 3. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `state` | ``enum (`https://docs.cloud.google.com/composer/docs/reference/mcp/tools_list/get_task_instance#Output.Schema.State`)`` Task instance state. |
| `tryNumber` | `integer` The try number that this task number will be when it is actually run. |
| `hostname` | `string` Hostname of the machine or pod the task runs on. |
| `queuedDttm` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Timestamp when the task was queued. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `pool` | `string` The slot pool this task runs in. |
| `queue` | `string` Which queue to target when running this task. |
| `priorityWeight` | `integer` Priority weight of this task against other tasks. |
| `maxTries` | `integer` The number of tries that should be performed before failing the task. |
| `isDynamicallyMapped` | `boolean` Whether this TaskInstance is dynamically mapped. |
| `mapIndex` | `integer` If is_dynamically_mapped is set to true, this field contains index of the dynamically-mapped TaskInstance, If is_dynamically_mapped is set to false, this field has no meaning. |
| `externalExecutorId` | `string` ID of the external executor. |
| `renderedMapIndex` | `string` Named mapping - a rendered map index template for this task instance. If task doesn't have a template specified or is_dynamically_mapped is set to false, this field is empty. |
| `note` | `string` The note content of the task instance. Added in Airflow 2.10.0. |
| `cloudLoggingFilter` | `string` Output only. A Cloud Logging filter that can be used to retrieve the logs of this task instance. |

### Timestamp

| JSON representation |
|---|
| ``` { "seconds": string, "nanos": integer } ``` |

| Fields ||
|---|---|
| `seconds` | `string (https://developers.google.com/discovery/v1/type-format format)` Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
| `nanos` | `integer` Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |

### State

State of the task instance.

| Enums ||
|---|---|
| `STATE_UNSPECIFIED` | The state of the task instance is unknown. |
| `SUCCEEDED` | Task execution succeeded. |
| `FAILED` | Task execution failed. |
| `UPSTREAM_FAILED` | Upstream task failed. |
| `SKIPPED` | Task skipped. |
| `UP_FOR_RETRY` | Task waiting to be retried. |
| `UP_FOR_RESCHEDULE` | Task waiting to be rescheduled. |
| `QUEUED` | Task queued. |
| `SCHEDULED` | Task scheduled for execution. |
| `SENSING` | Task in sensing mode. |
| `REMOVED` | Task vanished from DAG before it ran. |
| `RUNNING` | Task is executing. |
| `SHUTDOWN` | External request to shut down (e.g. marked failed when running). |
| `RESTARTING` | External request to restart (e.g. cleared when running). |
| `DEFERRED` | Deferrable operator waiting on a trigger. |

### Tool Annotations


[Tool annotations](https://modelcontextprotocol.io/specification/latest/schema#toolannotations) are sent to MCP clients to describe the basic risk of a given tool. Most clients treat these hints as untrusted, but they can be used to decide when a confirmation prompt might be sent to a user.


Along with the title string, the following boolean hints are defined as follows:

- `readOnlyHint`: If true, the tool doesn't modify its environment. Default: false.
- `destructiveHint`: If true, then the tool can perform destructive actions. If false, then the tool can only perform additive actions. Default: true.
- `idempotentHint`: If true, then calling the tool repeatedly with the same arguments will have no additional effect on its environment. Default: false.
- `openWorldHint`: If true, then the tool can interact with an 'open world' of external entities. If false, then the tool can only interact with internal entities. For example, a web search tool would be open world, while a memory tool would not be open world.

Destructive Hint: ❌ \| Idempotent Hint: ✅ \| Read Only Hint: ✅ \| Open World Hint: ❌