# canUseTool Callback

> Your own function that decides a tool call when nothing else has.

**Field:** Artificial Intelligence  
**Category:** Claude Agent SDK  
**Also known as:** canUseTool, can_use_tool, Agent SDK approval callback, Claude Agent SDK canUseTool

## Think of it like

It is like a helper who calls you to ask, may I do this?

## Definition

canUseTool is an Agent SDK option that takes your own function for approving tool calls. Claude Code calls it only when no earlier check decides, so it is the last step. It gets the tool name and its input. It returns allow, perhaps with changed input, or deny with a message Claude reads. Apps use it to show their own approval prompt.

## Example

Mia's web app shows an Approve button when the agent wants to write a file. Her canUseTool callback waits for the click.

## Example code

```typescript
canUseTool: async (tool, input) =>
  tool === "Bash" ? { behavior: "deny", message: "No shell" }
                  : { behavior: "allow", updatedInput: input }
```

Deny shell commands, allow the rest.

## Why it matters

It is how a person, or your own rules, stay in charge of what the agent does.

## Common mistake

Allowing a tool by name and expecting the callback to see it. Allowed calls never reach it.

## Three principles

- **The last check.** After rules and mode.
- **allow or deny.** With a reason.
- **Can change input.** updatedInput.

## Related terms

- [permissionMode Option](https://learn.benibix.com/term/ai/permission-mode-option)
- [allowedTools Option](https://learn.benibix.com/term/ai/allowed-tools-option)
- [PermissionRequest Hook](https://learn.benibix.com/term/ai/permissionrequest-hook)
- [PermissionResult](https://learn.benibix.com/term/ai/permission-result)

![The six checks a tool call passes in the Agent SDK: hooks, deny rules, ask rules, the permission mode, allow rules, then your canUseTool callback.](https://learn.benibix.com/diagrams/agent-sdk-permission-order.svg)

---

Source: https://learn.benibix.com/term/ai/can-use-tool-callback
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
