---
url: 'https://adk.nht.io/api/@nhtio/adk/forge/type-aliases/ToolHandler.md'
description: 'The execution function for a [`Tool`](https://adk.nht.io/api/@nhtio/adk/forge/classes/Tool).'
---

# Type Alias: ToolHandler

```ts
type ToolHandler = (
  args: unknown,
  ctx: DispatchContext,
  meta: Registry,
) =>
  | string
  | Uint8Array
  | Media
  | Media[]
  | Promise<string | Uint8Array | Media | Media[]>;
```

Defined in: [lib/classes/tool.ts:51](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/tool.ts#L51)

The execution function for a [Tool](../classes/Tool.md).

## Parameters

| Parameter | Type                                                           |
| --------- | -------------------------------------------------------------- |
| `args`    | `unknown`                                                      |
| `ctx`     | [`DispatchContext`](../../types/interfaces/DispatchContext.md) |
| `meta`    | [`Registry`](../../common/classes/Registry.md)                 |

## Returns

| `string`
| `Uint8Array`
| [`Media`](../../common/classes/Media.md)
| [`Media`](../../common/classes/Media.md)\[]
| `Promise`<
| `string`
| `Uint8Array`
| [`Media`](../../common/classes/Media.md)
| [`Media`](../../common/classes/Media.md)\[]>

## Remarks

Receives the raw arguments passed to the executor, the active [@nhtio/adk!DispatchContext](../../types/interfaces/DispatchContext.md), and the
tool's metadata registry.

Return shapes:

* `string` / `Uint8Array` — opaque serialised output. The ADK does not persist the bytes
  itself; the consumer's executor middleware is responsible for storing them and wrapping
  them via `tool.artifactConstructor?.() ?? SpooledArtifact` when assembling the `ToolCall`
  record.
* [@nhtio/adk!Media](../../common/classes/Media.md) / `Media[]` — explicit-modality silo. Bypasses
  [Tool.artifactConstructor](../classes/Tool.md#property-artifactconstructor) — the handler returns the final result shape directly.
  The LLM battery renders each `Media` as a provider-specific content block.
