<!-- description: Tool use is the ability of an AI agent to call external functions — such as reading files, running code, or sending messages — enabling it to affect the real world beyond text generation. -->

# Tool Use

**Tool use** is the capability of an AI [agent](agent) to call external functions during inference, enabling it to interact with systems beyond pure text generation. When an agent uses a tool, it generates a structured call that the runtime intercepts, executes, and returns results from — allowing the agent to read files, run code, query databases, send messages, and take real-world actions.

## How Tool Use Works

1. The LLM is provided a list of available tools with their names, descriptions, and parameter schemas
2. During generation, the model decides to call a tool and outputs a structured tool call
3. The runtime (e.g., [Claude Code](claude-code) or an [MCP client](mcp-client)) intercepts the call
4. The tool executes and returns a result
5. The result is injected back into the model's context as a new message
6. The model continues reasoning with the tool result available

## Tool Use in Claude Code

[Claude Code](claude-code) is built around tool use. Its core tools include:

- `Read` — Read file contents
- `Write` / `Edit` — Create or modify files
- `Bash` — Execute shell commands
- `Glob` / `Grep` — Search the codebase
- `Agent` — Spawn sub-agents for parallel work
- MCP tools — Any tools from connected [MCP servers](mcp-server)

## Tool Use via MCP

The [Model Context Protocol](mcp) standardizes tool use for remote services. AgentRQ exposes tools like `createTask`, `reply`, and `getTaskMessages` as [MCP tools](mcp-tool), which [Claude Code](claude-code) calls just like any other tool in its repertoire.

## Safe Tool Use

Not all tools are equal in risk:

| Risk Level | Examples | Recommended Pattern |
|-----------|---------|-------------------|
| Low | Read files, search code | Autonomous |
| Medium | Write files, run tests | Autonomous with logging |
| High | Deploy to production, delete data | Require [approval](approval) |

AgentRQ lets you enforce approval gates for high-risk tool calls via [human-in-the-loop](human-in-the-loop) workflows.

## Related Terms

- [MCP Tool](mcp-tool)
- [MCP](mcp)
- [Claude Code](claude-code)
- [Agent](agent)
- [Approval](approval)
