Sub topic 11
Permissions for External Tools and Servers
This chapter assumes you know the allow, ask, and deny decisions, how allow and deny rules match commands, and what prompt injection is. It covers tools that come from outside the agent, such as servers that expose extra tools to the model.
Why external tools are different
Built-in tools such as file read, file write, and shell have known behavior. The agent's authors wrote them, and you can predict what each one does.
An external tool is added by configuration. A common example is an MCP server (Model Context Protocol), a separate process that advertises tools to the agent. The agent calls those tools the same way it calls built-in ones. The difference is that someone else wrote the code, and you may not know what it does.
Three things follow from this:
- The tool's name and description come from the server. The model reads that text, so a malicious or compromised server can include instructions in it.
- The tool's output is untrusted content. It can carry injected instructions just like a web page.
- The server may run with your user account's rights. It may read files, use the network, or hold API tokens that the agent's own tools never touch.
Writing rules for external tools
Rules for external tools are usually keyed by server name and tool name, not by a command string. This makes matching simpler than for shell commands, because you match an identifier and not free text. The exact syntax depends on your agent, so the pattern below is illustrative.
from fnmatch import fnmatch
DENY = ["github/delete_*", "db/drop_*"]
ALLOW = ["github/get_*", "github/list_*", "docs/search"]
def decide_tool(server: str, tool: str) -> str:
"""Return 'deny', 'allow', or 'ask' for an external tool call."""
name = f"{server}/{tool}"
if any(fnmatch(name, p) for p in DENY):
return "deny"
if any(fnmatch(name, p) for p in ALLOW):
return "allow"
return "ask"
print(decide_tool("github", "list_issues")) # allow
print(decide_tool("github", "delete_branch")) # deny
print(decide_tool("github", "create_issue")) # askNotice that the default is ask. New or unknown tools should never be allowed automatically.
Common errors
- Allowing a whole server. A rule such as
github/*approves every tool the server has now, plus any it adds later. Prefer a list of read-only tools. - Trusting names. A tool called
get_statuscan still write data. The name is a claim by the server author. Read the tool's description and, where possible, its source. - Ignoring the server's own credentials. If the server holds a token with write access, a read-only rule on the agent side does not limit what the token can do. Give the server the narrowest token it needs.
- Skipping the output risk. Allowing a read tool still lets untrusted text reach the model. Combine it with limits on what the agent can do next, such as denying network and write tools in the same session.
A practical approach
- Install only servers whose source you can inspect or whose publisher you trust.
- Allow read-only tools by exact name. Leave write and delete tools on
askordeny. - Run the server with a scoped, short-lived credential.
- Treat the output of every external tool as data, not instructions.
Exercise
Your agent has a rule allow: ["tracker/*"] for an issue tracker server. The server's next release adds a delete_project tool. What happens, and how would you change the rule?
Show answer
The wildcard allows delete_project automatically, so the agent could call it without asking. Replace the wildcard with exact read-only names such as tracker/get_issue and tracker/list_issues, and add tracker/delete_* to the deny list. Anything else then falls back to ask.