Lesson 36.3 · 3 of 5 · 4 min read · Reviewed 24 Nov 2026
Splitting tools across agents
By the end, you can
- Give each agent only the MCP tools its role needs.
- Restrict MCP tools by name in allowed tool lists.
Adding a server makes all its tools available. That’s rarely what each agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. should have.
Tool names
In Claude Code and the Agent SDK, MCPModel Context Protocol (MCP): An open protocol that standardises how AI applications connect to tools, data and prompts through servers. tools are named mcp__<server>__<tool>, for example mcp__github__get_pull_request. You can target them in:
- A subagentSubagent: A separate agent instance, with its own context and instructions, that a main agent delegates a task to.’s
toolslist. allowedToolsin the Agent SDKClaude Agent SDK: Anthropic’s library for building agents on the same loop that powers Claude Code, with tools, hooks, subagents and MCP. or headlessHeadless mode: Running a coding agent non-interactively from a script or CI job, with a prompt and output on the command line. runs.- Permission rulesPermission rule: An allow, ask or deny rule that controls which tools, commands or paths a coding agent may use.:
"deny": ["mcp__github__delete_repository"].
Split by role
| Agent | MCP tools |
|---|---|
| Researcher | mcp__docs__search, mcp__github__get_pull_request |
| Triage | mcp__tracker__get_issue, mcp__tracker__add_label |
| Release | mcp__github__create_release (behind an approval) |
This applies chapter 34.4 (fewer tools per agent) and chapter 45.1 (least privilegeLeast privilege: Giving each component only the access it needs for its task, and no more.) to MCP.
Key points
- Connecting a server exposes all its tools; you still decide which ones each agent may use.
- MCP tools are named mcp__<server>__<tool>, so allow and deny rules can target them.
- A research subagent might get read-only tools, while a separate agent holds the write tools.
Split MCP tools across agent roles
Give each agent only the MCP tools its role needs, using mcp__server__tool names, allow lists and a deny rule that always wins.
You will have: A permission checker and a printed matrix of which agent may call which tool.
Steps
- Read the list of tools offered by the github, docs and tracker servers.
- Write allowed(agent, tool) using fnmatch so patterns like mcp__docs__* work.
- Make deny rules win over allow rules.
- Fill in allow lists for researcher, triage and release so each gets only what its role needs.
- Print the matrix and check delete_repository is denied for everyone.
Done when
- The researcher has only read tools.
- Triage can get issues and add labels, nothing else.
- mcp__github__delete_repository is denied for every agent.
Open in the Playground No API key needed.
Starter code (Python)
from fnmatch import fnmatch
tools = ["mcp__github__get_pull_request", "mcp__github__create_release", "mcp__github__delete_repository",
"mcp__docs__search", "mcp__docs__get_page", "mcp__tracker__get_issue", "mcp__tracker__add_label"]
deny = ["mcp__github__delete_repository"]
roles = {
"researcher": ["mcp__*"], # TODO: far too wide; read-only tools only
"triage": [], # TODO
"release": [], # TODO
}
def allowed(agent, tool):
# TODO: deny wins; otherwise the tool must match one of the agent's patterns
return True
for agent in roles:
print(agent, [t.split("__", 2)[2] for t in tools if allowed(agent, t)])
Show a solution
from fnmatch import fnmatch
tools = ["mcp__github__get_pull_request", "mcp__github__create_release", "mcp__github__delete_repository",
"mcp__docs__search", "mcp__docs__get_page", "mcp__tracker__get_issue", "mcp__tracker__add_label"]
deny = ["mcp__github__delete_repository"]
roles = {
"researcher": ["mcp__docs__*", "mcp__github__get_pull_request"],
"triage": ["mcp__tracker__get_issue", "mcp__tracker__add_label"],
"release": ["mcp__github__create_release", "mcp__github__get_pull_request"],
}
def allowed(agent, tool):
if any(fnmatch(tool, d) for d in deny):
return False
return any(fnmatch(tool, p) for p in roles[agent])
for agent in roles:
print(agent, [t.split("__", 2)[2] for t in tools if allowed(agent, t)])
print("delete_repository allowed anywhere:", any(allowed(a, "mcp__github__delete_repository") for a in roles))