The attacks on AI agents this year share one shape. The agent reads something an attacker wrote — a mail, a web page, a document — and then acts: sends, writes, fetches a URL with your data in it. I wrote about that pattern last week: you won't win the injection fight, so put the control on the action, outside the model.

With MCP, the read and the act usually happen in different servers. The agent fetches a page through a fetch server and writes through a filesystem server. Each server sees one harmless call. No single server can stop the second step, because none of them saw the first.

Read here, act there: the fetch server sees one harmless fetch, the filesystem server never sees the page; cleimesh-mcp in front of both turns the agent tainted at step 2 and refuses the write of the secret at step 4

CleiMesh now does this in one command per server.

One command per server

cleimesh mcp add fetch --taints fetch -- uvx mcp-server-fetch cleimesh mcp add fs --clean-only write_file --clean-only edit_file \ -- npx -y @modelcontextprotocol/server-filesystem ~/work 

Each mcp add creates the keys if they're missing, asks the server which tools it has, issues a signed token for exactly those, and registers the result with Claude Code for every project (--print gives you the JSON for Cursor and other clients). Every server you add runs behind one cleimesh-mcp entry: one enforcement point, one receipt log, and one view of what the agent has read.

Before it grants anything, it shows what each tool tells the model, and it refuses a definition hiding invisible characters (zero-width, Unicode tag characters) that the person approving can't see. It also pins each tool's definition. If a server later changes a tool you approved (a "rug pull": a new description that instructs the model, a wider schema), the wrapper stops offering it until you run mcp add again.

Approved Monday, rewritten Thursday, withheld: the tool definition pinned at mcp add no longer matches the server's new one, so the wrapper does not offer the tool until a human re-runs mcp add

--taints fetch says: whatever comes back from this tool is untrusted, and the agent that received it is now tainted. --clean-only write_file says: this tool acts on the world, so refuse it while the agent is tainted, until a human clears it.

Here it is with the official fetch and filesystem servers, unmodified, in a container. A scripted agent (no model; it does what an injected one would) fetches release notes carrying a hidden instruction, reads a secret, and tries to write it where the instruction says:

1. write_file notes.txt (clean) -> ok 2. fetch the release-notes page -> ok (the page carries the injection) 3. read_text_file secrets.txt -> ok 4. write_file leak.txt (injected) -> REFUSED: holder ... received untrusted content 

Two official MCP servers added with one command each; the agent fetches a poisoned page, reads a secret, and its write of the secret is refused on the other server; the receipts say why

The filesystem server never saw the page; the wrapper in front of both servers did, and refused the write. cleimesh taint list names the receipt that tainted the agent; cleimesh audit verify checks all seven receipts. The Dockerfile and full transcript are in the repo.

Step 3 is allowed on purpose: taint stops the action that would leak the secret, not the read. Reading is what agents are for.

I found the cross-server case by running exactly this test before writing this post. My first version gave each wrapped server its own log, so the taint stayed in the fetch server and the write went through. A control you haven't attacked yourself is a hope.

So before shipping I also reviewed the trust boundaries, and fixed what that turned up: a hand-edited server list could call one server under another server's looser token, the spending cap of an allowance reset whenever the MCP client restarted it, and a few IPv6 forms that embed a private address passed as public. The threat model records them. That review was mine; an outside one is still to come.

Egress is decided on the connection, not the argument

A reader, komopdf, pointed out a hole in the earlier version: an allowlist that checks the URL argument passes a granted host that answers 302 to the attacker. They were right. Now a tool reaches the network only through the host, which follows every redirect itself, re-checks every hop against the signed grant, pins the socket to the address it resolved (no DNS rebinding), and refuses private and link-local answers unless the grant says otherwise:

The URL was granted, the connection was not: an argument allowlist follows the 302 and the key reaches the attacker; CleiMesh re-checks the hop on the connection and refuses it, and the attacker's server sees 0 connections

$ cleimesh token issue <agent> --tool fetch_url --host 127.0.0.1:34185 --allow-private agent> fetch_url http://127.0.0.1:34185/share?doc=q3 (granted API, answers 302 to the attacker with the key in the query) -> REFUSED: address 127.0.0.1:34531 is not a granted host agent> fetch_url http://169.254.169.254/latest/meta-data/iam/ (cloud credentials) -> REFUSED: address 169.254.169.254:80 is not a granted host The attacker's server saw 0 connections. 4 receipts record each hop, refused or not. 

That is cleimesh demo redirect, abridged; it runs from the binary, with both servers on localhost.

Built on the standards, not next to them

The token is an Attenuating Agent Token: each delegation, human to agent to subagent, can only narrow it. CleiMesh is an independent implementation of draft -02 and reaches the expected verdict on all 229 vectors of the draft's conformance suite (54 permit, 175 deny). The receipts reproduce the test vectors of draft-sahu-agent-action-receipts byte for byte, and the receipt log is an RFC 6962 Merkle tree: proving one receipt among a million takes 640 bytes and about 13 µs (BENCHMARKS.md).

For tools that run in its WebAssembly sandbox, the token is the sandbox configuration, and each receipt carries the frozen clock and seeded randomness of the run: an auditor re-executes the call and checks the output byte for byte. Don't trust the receipt, replay it.

What it doesn't do

  • A wrapped MCP server is not sandboxed. It runs natively and reaches whatever its OS user can. CleiMesh decides which of its tools and arguments get through and records every call; containment needs the WASM sandbox, or the server inside an agent sandbox.
  • The labels are yours. mcp add without --taints or --clean-only grants every tool the server lists and marks none of them. Decide which tools bring content in (a file read can carry an injection as well as a web page) and which act.
  • Tool descriptions pass through. What a wrapped server says about its tools reaches the model as written; the token limits which tools and arguments get through, not what their descriptions say.
  • Taint is coarse. Once tainted, the agent loses every clean-only tool until a human clears it. That is deliberate: there is no automatic way back.
  • Egress checks hosts and addresses, not intent. Several sites behind one IP (a CDN) share a grant; the threat model lists this and the other residual cases.
  • It only covers the tools that go through it. An agent that also keeps its own shell can still use it. Turn those tools off, or run the agent in a sandbox.

Try it

curl -fsSL https://github.com/cleitonaugusto/cleimesh/releases/latest/download/install.sh | sh cleimesh demo redirect cleimesh mcp add fetch --taints fetch -- uvx mcp-server-fetch 

Then restart Claude Code and look at what the agent can call, and what it can't.

What your agent reads can't decide what it does. Which MCP server would you put behind a token first? That decides what I test next.

Cleiton Augusto — GitHub