Your Read-Only MCP Tool Is Not a Security Boundary

Your client reads an MCP tool's readOnlyHint, decides the tool is safe, and auto-approves it. But the annotation is a string the server typed about itself, not a fact anyone enforces, and a tool labeled read-only can still run a command, delete a file, or ship your data off the box.

Viral RuparelNo. 95 of 9511 min read

A team I was helping had an agent wired to about a dozen MCP servers, and like most teams they had a rule for the approval dialog: if a tool was marked read-only, auto-approve it, and only stop the agent for tools that could write. It felt principled. Reads are safe, writes are dangerous, gate the dangerous ones. Then an agent run that was only ever supposed to summarize a repository ended up running a shell command that was sitting in that repository's git config, and the "read-only" label on the tool it used was still sitting there in the logs, perfectly green, while the command executed.

Nothing had gone wrong with their gate. The gate did exactly what they built it to do. The problem was that they had pointed it at the wrong thing. They were enforcing a word the server had typed about itself, and treating that word as if it were a property of the tool.

Two panels: on the left the client reads a tool's readOnlyHint and auto-approves, and an untrusted input steers the read tool into executing a command; on the right a broker ignores the hint, looks up a capability tier the client assigned, and runs the tool inside a sandbox scoped to that tier so the same attempt is denied.
Figure. Hint-based approval versus tier-based enforcement

What the annotation actually promises

The Model Context Protocol lets a server attach annotations to each tool: readOnlyHint, destructiveHint, idempotentHint, openWorldHint. They read like a permission model, and that is exactly how people use them. A client sees readOnlyHint: true and decides the tool is harmless enough to run without asking.

The protocol does not agree with that reading. The MCP specification for tools is blunt about it: for trust and safety, clients must consider tool annotations to be untrusted unless they come from a trusted server. The MCP maintainers made the same point at length in their post on tool annotations as risk vocabulary, where every property in the interface is documented as a hint and the post spells out that a server can label a tool read-only and still delete data. The annotation is a string the server authored to describe its own intentions. It is not a contract the runtime checks, and it is not signed by anyone. It is a label on the box, written by whoever packed the box.

Treating a hint as a boundary is the same category error as the confused-deputy problem, where a trusted component is tricked into using its authority on behalf of someone who should not have it. Here the deputy is your approval policy, and the authority it hands out is "skip the human." The server supplies the words that trigger it.

Why read-only still runs code

The gap is simple once you see it. The annotation describes the tool's name and schema. It says nothing enforceable about the implementation, and nothing in the protocol compares the two. So a tool can be named get_file, carry readOnlyHint: true, and have an implementation that shells out. Usually no one did this on purpose. The more common and more dangerous path is that a read tool processes data it does not control, and that data steers it into an effect its label never mentioned.

The mcp-server-git advisories are the clean example. Security researchers disclosed a set of flaws in Anthropic's reference git MCP server in early 2026, and the pattern that matters here is the one where tools meant to read a repository could execute a command that lived in the repository's own git configuration. One of them, CVE-2025-68143, involved a tool accepting a filesystem path with no validation. Point a "read" tool at a repository an attacker prepared, and the repository's config becomes code the tool runs. The tool is still, in every honest sense, a read tool. It reads. The thing it reads tells it what to do next.

This is why annotations cannot be the control. A read capability plus an untrusted input is frequently enough to get an effect you did not authorize. And annotations are per tool, so they are blind to the combination the MCP maintainers call the lethal trifecta: access to private data, exposure to untrusted content, and the ability to reach outside the box. Each tool can look fine on its own. Held together by one agent, they are an exfiltration path, and no single readOnlyHint describes the path because the path does not live in any one tool.

Assign your own capability tier

The fix starts by moving the decision off the server's word and onto a classification you own. For every (server, tool) pair, you record what effect you have actually confirmed the tool has, and your approval logic reads that, never the annotation. The annotation can still shape the wording of a prompt. It cannot decide anything.

from enum import Enum

class Tier(Enum):
    READ = "read"          # observes only: no writes, no exec, no egress
    WRITE = "write"        # mutates state you own
    EXTERNAL = "external"  # can reach the network or run commands

# Keyed by (server_id, tool_name), authored by YOU at review time, not read
# from the tool's annotations. A tool is unclassified until a human tiers it.
POLICY: dict[tuple[str, str], Tier] = {
    ("git", "git_log"): Tier.READ,
    ("git", "git_commit"): Tier.WRITE,
    # git_log is tiered READ because we confirmed it reads; we do NOT trust
    # the server's readOnlyHint to tell us that.
}

def tier_of(server_id: str, tool_name: str) -> Tier | None:
    return POLICY.get((server_id, tool_name))  # None means unclassified

The discipline is that tier_of returns None for anything you have not reviewed, and None means deny. A new tool, or a renamed one, is a new decision, the same default-deny stance that makes a policy-as-code authorization gate trustworthy. Auto-approval then keys on your tier and the sensitivity of the data in play, so a READ tool pointed at a customer's private workspace can still require a person even though its tier is the gentlest one.

This also closes the gap that pure definition fingerprinting leaves open. Fingerprinting proves the tool is the one a human approved. It says nothing about whether that human was right to believe the label. Tiering is where you record the judgment that the label was correct, or correct it.

Enforce at the boundary where the effect happens

A tier in a dictionary is still just a word unless something stops a tool from exceeding it. The place to enforce is the boundary where the effect would actually occur: the filesystem, the process table, the network. A tool you tiered READ should run with no write access, no ability to spawn a process, and no network egress, so that even if its implementation or its input tries for more, the attempt fails at the edge rather than at a label you hoped it would respect.

import subprocess

# Each tier maps to a concrete sandbox profile. READ gets a read-only root and
# no network, so a tool that tries to write or phone home is stopped by the OS,
# not by trust. This profile comes from OUR tier, never from the annotation.
SANDBOX = {
    Tier.READ:     ["--ro-bind", "/repo", "/repo", "--unshare-net"],
    Tier.WRITE:    ["--bind", "/repo", "/repo", "--unshare-net"],
    Tier.EXTERNAL: ["--bind", "/repo", "/repo"],  # network allowed, logged
}

def run_tool_sandboxed(tier: Tier, argv: list[str]) -> subprocess.CompletedProcess:
    if tier is None:
        raise PermissionError("unclassified tool: default deny")
    profile = SANDBOX[tier]
    # bwrap is illustrative; the point is the profile is derived from the tier.
    return subprocess.run(["bwrap", *profile, "--", *argv], capture_output=True)

The exact sandbox technology does not matter for the argument. What matters is that a READ tool literally cannot open a socket or write a file, because the kernel refuses, so the git-config-execution pattern has nowhere to land: the command might get invoked, but it runs with no network and a read-only mount, and the exfiltration step fails. This is the same least-privilege reasoning behind running generated code in a locked-down sandbox, applied to every tool call rather than only the obvious one. Pair it with short-lived scoped credentials so a tool that does reach the network holds as little as possible when it gets there.

Make the hint a claim you verify, not a fact you trust

Once you enforce tiers at the boundary, the annotation becomes useful again, not as a decision but as a claim you can check. A tool that declares readOnlyHint: true and then attempts a write, a process spawn, or an egress has told you something false about itself, and that mismatch is a strong signal. Log it, and quarantine the tool.

def check_claim(declared_read_only: bool, attempted: set[str]) -> str | None:
    # attempted is what the sandbox observed the tool TRY to do this call.
    forbidden_for_read = {"write", "exec", "egress"}
    if declared_read_only and (attempted & forbidden_for_read):
        # The server's own annotation is now contradicted by behavior.
        # Do not just allow or deny silently: this is a trust event.
        return f"readOnlyHint violated: attempted {sorted(attempted & forbidden_for_read)}"
    return None

A mismatch is not a crash, it is a review item. Route it to a human-in-the-loop approval gate with the declared annotation and the observed attempt side by side, and let a person decide whether the server is buggy or hostile. The agent keeps running everything else, because the quarantine is per tool. The point is that the annotation has flipped roles. It went from the thing you trusted to the thing you hold the server accountable to.

The parts that bite

Honest servers mislabel too. Most annotation mismatches you see will be mistakes, not attacks: a tool that writes a cache file while swearing it is read-only, a tool that resolves a DNS name and trips your egress check. If your quarantine is too eager, people drown in false trust events and start rubber-stamping them, which is how you end up back where you started. Tune the observed-effect classes so routine, harmless behavior does not read as a violation, and reserve the hard stop for write, exec, and egress that leaves your box.

You cannot sandbox a remote server's behavior, only your client's. The profiles above work when the tool runs where you control the kernel. For a hosted MCP server you connect to over the network, the server does whatever it does on its own machine, and your enforcement moves to what you send it and what you let its responses do. There the lever is the tier gating the call at all, scoped credentials, and the prompt-injection defenses you run on tool outputs, because a response from a remote tool is untrusted data no matter how the tool is labeled.

The trifecta is a property of the set, not the tool. Tiering each tool correctly still lets you assemble an agent that holds a READ tool over private data, a tool that ingests untrusted content, and an EXTERNAL tool in the same loop. Each is tiered honestly. Together they are the exfiltration path. You have to review the agent's whole toolset as a unit and cut one leg, usually external reach, for any agent that also touches private data and untrusted input.

A broker adds a hop. Routing every tool call through a classification lookup and a sandbox launch costs latency and operational surface. It is worth it for anything that touches data you would not hand a stranger, and it is overkill for a local toy. Decide per deployment, and be honest that the gate is only real if every tool call goes through it. A tool the agent can reach around the broker is a tool with no tier at all.

The takeaway

MCP made it easy to give an agent capabilities, and it made the safety labels on those capabilities easy to misread as a permission model. They are not one. A readOnlyHint is a sentence a server wrote about itself, the spec tells you to treat it as untrusted, and the mcp-server-git flaws show a tool can read exactly as advertised and still run code, because the data it reads decides what happens next. Enforcing on the label means enforcing on the attacker's input.

The shape of the fix is the same one that works everywhere else trust flows the wrong way by default: move the decision onto something you control, and enforce it at the edge where the effect lands. Assign your own capability tier per tool, auto-approve on that tier and the sensitivity of the data rather than on the hint, sandbox every call to the effects its tier allows, and treat any annotation the behavior contradicts as a trust event, not a log line. If you are wiring MCP servers into an agent and you are not sure which of your tools are gated on a boundary you enforce versus a word a server typed, book a consultation call and we can map where your tool trust actually lives before an input decides it for you.

ShareXLinkedInviralruparel.com/blog/mcp-tool-annotation-readonly-enforcement-gate

Questions this essay answers

01Is the readOnlyHint annotation a security control?

No. In the Model Context Protocol, readOnlyHint and the other tool annotations are hints that describe intended behavior, not guarantees the runtime enforces. The spec itself tells clients to treat annotations as untrusted unless they come from a trusted server. A server can declare a tool read-only and still have that tool write files, run commands, or send data outside the box, either by mistake or on purpose. Use the hint to shape a confirmation prompt if you like, but never let it decide what a tool is allowed to do.

02Why can a read-only MCP tool still execute commands?

Because the annotation describes the tool's name and schema, not its implementation, and nothing in the protocol checks that the two agree. A read tool often processes data it does not control, like a repository's git config or a fetched web page, and that data can steer the tool into an action its label never mentioned. The mcp-server-git advisories are a concrete case: tools meant to read a repository could run a command drawn from the repository's own configuration. Read intent plus untrusted input is enough to get code to run.

03How should I decide which MCP tools to auto-approve?

Decide on a capability tier you assign yourself, keyed by server and tool, not on the annotation the server shipped. Classify each tool by the effect you have confirmed it has, read, write, or external reach, and store that in a policy your client controls. Auto-approve only the tools your own tier marks as safe for the agent and the data in play. When a tool is new or unclassified, default to deny and route it to a person. The server's self-description is an input to your review, never the decision.

04What is the lethal trifecta in MCP tool security?

It is the combination that turns a set of individually reasonable tools into an exfiltration path: access to private data, exposure to untrusted content, and the ability to communicate externally. Any single capability is often fine. Together they let injected instructions read something sensitive and send it somewhere. Tool annotations describe one tool at a time, so they cannot see the combination. You have to reason about the whole set of tools an agent holds at once and cut one leg of the trifecta, usually external reach, at the boundary.

Working on this in production?I help teams make agents like this reliable. Thirty minutes, no pitch.
Viral Ruparel

Generative AI consultant and full-stack architect. Ex-IBM, former Director of Engineering at a YC W20 startup. Writes about what breaks when agents meet reality.