MCP tool rules: allow, hold or deny each tool
Updated
Decide, tool by tool, which MCP tools your agent may call: allow a tool, hold each call for a person, or deny it. MCP, the Model Context Protocol, is how many agents call outside tools. Tego's relay sits between the agent and each server, decides every tool call and writes it to the run's record.
On this page
Note
MCP tool rules are a preview. The relay holds an agent that uses its MCP client; it is not yet a boundary against an agent that attacks the relay itself. Security and limits lists what it does not stop.
Allow, hold or deny a tool
Add a tools: key to a server in the contract's mcp: list:
ask:
timeout: 2m # needed for an ask: list
mcp:
- name: files
command: [python3, /opt/fake-mcp/server.py]
tools:
allow: [read_file, list_dir] # present: every tool not listed is denied
deny: [delete_file]
ask: [write_file] # held until a person answers
- name: web
url: https://mcp.example.com/mcp
tools: {deny: [delete_file]}On files, the agent may call read_file and list_dir, each write_file call waits for you, and every other tool is denied. On web, only delete_file is denied.
A call is decided in this order: a live change made during the run, then deny, then ask, then an allow list that does not name the tool (denied), else allowed.
- Names are exact, with no patterns, and a name may be in one list only.
tools: {}puts the server behind the relay with nothing restricted, so you can still change rules live.- A server with no
tools:key runs as before, with no relay.
What else the contract needs
- An
ask:section for anyask:list. Without it a held call is refused. - An enforcing protection level. The relay does not work in a record-only run (
tego watch). - The
tegobinary inexec.allow, if the contract has that list. The agent's MCP client starts each server astego mcp relay …. - A
net:section for aurlserver.net: {allow: []}is enough: the relay is then the agent's only route to the server.
Check it before the first run:
tego compile agent.yamltego compile warns when the tego entry or the net: section is missing.
Point the agent at the relay
For Claude Code, start the run as usual. When the command is claude, Tego passes it the relay's MCP config:
tego run agent.yaml -- claudeAny other MCP client reads the config file named by TEGO_MCP_CONFIG inside the run, for example sh -c 'my-agent --mcp "$TEGO_MCP_CONFIG"'. The agent's client starts each server through the relay; starting the declared server directly is refused.
What the agent sees
- Denied tools are hidden from
tools/list. Held tools stay listed. - A denied call gets an error the model can read and move on from:
{"code": -32001, "message": "Tego refused the MCP tool delete_file on files: the run's rules deny this tool", "data": {"tego": {"rule": "mcp[files].tools.deny[delete_file]", "reason": "mcp-tool-denied"}}}- A held call waits for your answer on the dashboard's Approvals page or with
tego approveortego deny. Other calls keep flowing. If you deny it or nobody answers in time, the agent gets the same kind of error.
Change a rule during a run
A change lasts until the run ends. To keep it, edit tools: in the contract.
tego mcp tools <run> # every tool, its decision now and why
tego mcp deny <run> files read_file # tightens: applies at once
tego mcp allow <run> files delete_file # loosens: asks y/N first (or --yes)
tego mcp ask <run> files write_file
tego mcp reset <run> files delete_file # back to the contractOn the dashboard, start it with tego serve --preview to get the MCP tools page, pick the run, and press Allow, Ask or Deny on a tool. The next call follows the change. A loosening shows what it changes and asks you to confirm.
The agent can tighten its own rules but never loosen them: a loosening from inside any Tego run is refused.
What the record shows
Every decision is a line in the run's record:
- Each tool call: an
mcpline with the server, the transport, the tool, allowed or refused, and the rule that decided it, for examplemcp[files].tools.deny[delete_file]. - Each held call: the request and your answer.
- Each live change: who changed which tool to what, and when.
tego events <run> prints them, and the run's page on the dashboard shows them in its Timeline. The MCP server that blind-copied every email shows where tool rules help and where they don't.
Source: docs/user/mcp-tools.md.