How Do You Give an AI Agent Access to Tools Safely?
Give an AI agent tool access safely: only the tools its job needs, a key per agent, approval for risky actions, sandboxes in Claude Code and Codex, a log.
Reviewed by WaveBrain Operations TeamReviewed 9 min read
The short answer
You give an AI agent access to tools safely by granting only the tools and permissions its job needs, giving each agent its own key, requiring human approval for anything hard to undo and keeping a record of what it did. OWASP names excessive functionality, excessive permissions and excessive autonomy as the root causes of harmful agent actions, so trim all three before you connect a tool.
Connecting an AI agent to a tool is the moment it stops being a chat and starts acting for you. Give a support agent your help desk and it can refund customers. Give a coding agent a terminal and it can push to production. Give a marketing agent your ad account and it can change a budget at 3 a.m.
None of that is a reason to avoid tools. It's a reason to hand them out the way you'd hand keys to a new hire: one door at a time, with someone checking the work. This guide covers what goes wrong, a step-by-step setup that works for founders and small teams, and how Claude Code, Codex and MCP servers let you enforce it.
What does giving an AI agent tool access safely mean?#
It means the agent can do its job and very little else, a person approves anything hard to undo, and you can see afterwards what it did. Security people call the first part least privilege. For agents, it applies to three things at once: which tools they have, what those tools are allowed to do, and how much they can do without asking.
The OWASP Top 10 for LLM Applications 2025 lists this risk as LLM06, Excessive Agency, and names its root cause as one or more of "excessive functionality", "excessive permissions" and "excessive autonomy". Each one maps to a question you can answer before you connect anything:
| OWASP root cause | Question to ask | Example of getting it wrong |
|---|---|---|
| Excessive functionality | Does the agent need this tool at all? | A tool that reads documents also deletes them |
| Excessive permissions | Does the tool's login need this much access? | A read-only report uses a database login that can also update and delete |
| Excessive autonomy | Should a person approve this action first? | An agent deletes a user's documents without confirmation |
All three examples in the table come from OWASP's own list.
What can go wrong when an AI agent has too much access?#
An agent with too much access can take a damaging action because it misread a task, or because someone tricked it. OWASP lists the common triggers as hallucination from poorly written prompts or a weak model, and prompt injection from a malicious user, a compromised tool or, in multi-agent setups, "a malicious/compromised peer agent".
OWASP's own example is an email assistant. It only needs to summarize incoming mail, but its mail tool can also send messages. A crafted email tells it to search the inbox for sensitive information and forward it to the attacker. OWASP says three changes would each prevent this: a tool that can only read mail, a read-only login scope, or a person who reviews and clicks send on every drafted email.
The lesson for anyone running AI employees is that the agent doesn't need to be malicious for this to happen. It needs to be able to do something you never meant it to do, and to meet text that asks it to.
How do you give an AI agent tool access safely, step by step?#
You set it up in seven steps, starting from the job and working back to the access. Most of them take minutes, and none need code.
- Write the job in a paragraph: what the agent does, what it must never do and what finished looks like. Our explainer on what an AI employee is shows how narrow a good first job should be.
- List the tools that job needs, and remove every tool it doesn't. OWASP's advice is to limit extensions "to only the minimum necessary", including old ones you tried during setup and forgot.
- Pick the narrowest version of each tool. A tool that only reads mail beats a full mailbox tool, and a "write this file" tool beats a general shell, which OWASP calls open-ended.
- Give each agent its own login or API key with the smallest scope that works, so its actions are attributable and you can revoke one agent without breaking the rest.
- Require approval for anything hard to undo: payments, refunds, deletions, deploys, emails to customers, price and budget changes.
- Keep secrets out of prompts and instructions. Store keys in environment variables or the tool's credential store, not in text the agent reads or writes.
- Record every action with an external effect in one log, and review it weekly. Our small business audit checklist turns that review into a 15-minute routine.
Which tools should an AI agent get for common jobs?#
An agent should get the tools that match its job's finished state, with write access only where the job writes. The table shows a starting point for the most common AI employees.
| Job | Give it | Hold back | Ask a person before |
|---|---|---|---|
| Support agent | Read tickets, draft and send replies | Admin settings, bulk exports | Refunds above a set amount |
| Marketing agent | Draft posts, schedule to a queue | Billing, account roles | Publishing, ad budget changes |
| Ops workflow (n8n, Make, Zapier) | The one app each step touches | Full-account credentials shared across workflows | Emails to a whole list, deleting records |
| Coding agent (Claude Code, Codex, Cursor) | Edit files and run tests in the project | Production secrets, other repositories | Pushes to main, deploys, database migrations |
If you can't decide whether an action belongs in the last column, ask how long it would take to undo. Anything that reaches a customer or moves money usually belongs there.
How do Claude Code and Codex limit what an agent can do?#
Both coding agents ship with built-in controls you should use instead of relying on instructions alone. Claude Code uses permission rules and modes, and Codex uses a sandbox plus an approval policy.
In Claude Code, rules are allow, ask or deny, and they're "evaluated in order: deny, then ask, then allow", so a deny rule such as Bash(git push *) wins over any allow rule that also matches. The docs are explicit that "Permission rules are enforced by Claude Code, not by the model", and that instructions in your prompt or CLAUDE.md shape what Claude tries to do without changing what it's allowed to do. The bypassPermissions mode skips prompts, and Anthropic says to use it only "in isolated environments like containers or VMs where Claude Code can't cause damage."
In Codex, security comes from two layers: the sandbox mode decides what Codex can technically do, such as where it can write and whether it can reach the network, and the approval policy decides when it must stop and ask. OpenAI's docs say that by default "the agent runs with network access turned off", and the default workspace-write mode limits writes to the active workspace. The flag that removes both layers, --dangerously-bypass-approvals-and-sandbox (alias --yolo), is marked "not recommended".
The same idea carries over to tools without these settings: put the limit in the tool or account, not in the prompt.
What should you check before connecting a new MCP server?#
Check what the server can do, what it runs as and what scopes it asks for. An MCP server adds tools to every agent that connects to it, so it deserves the same review as a new app with access to your accounts.
The Model Context Protocol's security best practices give three checks worth copying:
- Local servers run on your machine with your privileges. The spec tells clients to warn "that MCP servers run with the same privileges as the client" and to show the exact command before a one-click install runs.
- Scopes should start small. The spec recommends a minimal initial scope set "containing only low-risk discovery/read operations", and lists wildcard or omnibus scopes such as
*,allorfull-accessas a common mistake. - Tokens belong to one server. MCP servers "MUST NOT accept any tokens that were not explicitly issued for the MCP server", so don't reuse one broad API token across several servers.
If a server only offers one all-powerful key, treat every tool on it as needing approval.
Why do you still need a record of what the agent did?#
Because limits reduce what can go wrong, but they don't tell you what did happen. OWASP says logging and monitoring "will not prevent Excessive Agency, but can limit the level of damage caused", along with rate limits that slow down a bad run until someone notices.
A record also tells you whether your permissions are right. If the log shows a marketing agent never touches the ad budget, you can remove that access. If it shows a support agent asking for approval twenty times a day for the same safe action, you can allow it. Our guide on what an AI agent audit trail is explains which fields make a record useful.
Where does WaveBrain fit?#
WaveBrain covers the record. It's a hosted activity log that your agents report their finished actions to, so you get one timeline across Claude Code, Codex, Cursor, Hermes, Claude Desktop, scripts and no-code workflows instead of a separate history in each tool.
Agents that connect to its MCP server get a log_action tool and instructions to call it after any action with an external effect, such as a post, an email, an ad change or a deploy. Scripts and workflows log with one REST request. With the Claude Code, Codex, Cursor or Hermes plugin, the Stats page also shows which MCP tools each agent calls, by server and tool name, with error rates, never the arguments or results. That's a quick way to spot an agent using a tool you forgot it had.
WaveBrain is also a low-privilege tool to add. Its API key only works with WaveBrain itself, and WaveBrain never signs in to your inbox, social pages, ad accounts or app stores, and it never reads your repository. The dashboard suggests a separate API key per machine or agent so you can revoke them one at a time. See what gets logged for the full list.
Be clear about what it isn't. WaveBrain isn't a permission system: it doesn't block, approve or sandbox anything, so the steps above still need your agent's own settings. It records only what agents report, so an agent that never calls log_action leaves no entry. It isn't LLM tracing and doesn't record prompts, responses or token costs. It isn't a tamper-proof audit trail, and it doesn't filter secrets from the text agents write, so entries should read like commit messages.
The Free plan includes 1,000 actions a month, 7-day history and 2 API keys. Pro is $12 a month for 50,000 actions, 90-day history and 50 API keys. You can start free with no credit card.
Frequently asked questions#
What is excessive agency in AI agents?#
Excessive agency is OWASP's name for an AI system that can take damaging actions because it has more tools, permissions or autonomy than its job needs. It's LLM06 in the OWASP Top 10 for LLM Applications 2025.
Should an AI agent use my own login?#
Prefer a separate login or API key for each agent with the narrowest scope that works. Its actions are then easy to tell apart from yours and easy to revoke without locking yourself out.
Is telling an agent "never delete files" enough?#
No. Instructions shape what an agent tries, but they aren't a limit. Claude Code's docs say permission rules are enforced by Claude Code, not by the model, so put hard limits in tool settings or account permissions.
Which actions should always need human approval?#
Anything hard to undo or that reaches customers or money: payments, refunds, deletions, deploys, database migrations, emails to many people and ad budget changes. OWASP recommends human approval for high-impact actions.
Does WaveBrain control what my agents can do?#
No. WaveBrain records the actions agents report, so you can review them and adjust access. Permissions, sandboxes and approvals come from the agent's own settings and the accounts you connect.