Safeguard
AI Security•

Narrow tools or a general shell for AI agents: which is safer?

Narrow, purpose built tools are easier to scope, approve and audit than a general shell or fetch tool. A comparison and a path to replace open ended tools.

Safeguard Security Team
3 min read

Narrow tools are safer because you can state, limit and audit exactly what each one does. A general shell or "fetch any URL" tool can do nearly anything, so it carries nearly every risk. Prefer one tool per job, and use open ended tools only inside a sandbox.

What OWASP says

OWASP's excessive agency guidance includes "avoid open-ended extensions" and gives the example of preferring tools with specific functions over ones that run a shell command or fetch any URL. It also lists minimizing extension functionality: build tools with only the functions the task needs.

Side by side

PropertyNarrow toolGeneral shell or fetch
What can it do?One defined thingAlmost anything the host allows
Easy to scope?Yes, by argumentHard, you must filter strings
Approval prompt readable?Yes, shows a clear actionA command string few people parse
Audit valueHigh, clean eventsLow, free text commands
Build costHigher up frontLow, until the first incident

When a shell is the right call

Coding agents often need a shell, and the sensible answer is containment, not refusal. Run it in a sandbox with no production credentials, limited network and a throwaway filesystem. Then permit the open ended tool only there.

Steps to replace an open ended tool

  1. Log a month of shell or fetch usage and group the real commands.
  2. Find the top five repeated tasks. They are usually things like run tests, read a file, list tickets.
  3. Build or choose a narrow tool for each, with typed arguments.
  4. Move the agent to the narrow tools in a lower environment and compare results.
  5. Remove the general tool from production agents.
  6. Keep the sandboxed shell for development agents that truly need it.

Typed arguments help everything else

A narrow tool with typed, validated arguments is easy to constrain. The MCP specification requires servers to validate all tool inputs and expects tools to declare an input schema. A schema that says "folder name from this list" is a limit you can enforce, where "any string" is not.

The honest trade off

Narrow tools cost engineering time and sometimes block an unusual request. That friction is the point. If a request keeps hitting the wall, add a tool deliberately, with a review, rather than opening the shell.

Safeguard offers MCP Guardrail and agent identity for applying this kind of policy to agent tool calls, and you can run a free scan of your own repositories at gold.safeguard.sh/scan. Autonomous fix pull requests are off by default, and every category starts on Manual.

Quick check

Can I allow a shell if I filter dangerous commands?

Filters are easy to bypass. Use a sandbox with no sensitive access, and keep the shell out of production agents.

How many narrow tools is too many?

Group by job, not by endpoint. A short list of clear tools beats many near duplicates, which also confuse the model.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.