MCP security: how sensitive data leaves through tool calls, and how to stop it

Tool calls are where most agent data leaks happen. How over-sharing, recipient hijacks and changed tool definitions leak data through MCP, and how to test and gate every call.

Published
Updated
Reading time
9 minutes
#everytools/callisjudged+---------++-------------++-----------+||tools/call||||agent|--------->|gateway|--------->|server|||||||+---------++-------------++-----------+policy:datatype,recipient,purpose------------------------------------------------------------#allowthecallgoesthroughunchanged#redactonefieldreplaced,thetaskfinishes#blockadenyrulenamestheflow

The Model Context Protocol made it easy to give an agent tools. Each server an agent connects to is also a recipient: whatever the agent puts in a call argument leaves the process and lands in another system’s logs. That is why tool calls are the most common leak channel we measure, ahead of memory and handoffs.

Three ways a tool call leaks

The agent sends more than the tool needs

A calendar tool needs a time and an email. The agent sends the whole customer record because it is in context. Nothing malicious happened, and a health condition is now in a third-party calendar. This is the most frequent case and the easiest to miss in review, because the call succeeds.

The recipient is changed

Injected text in a document, a web page or a tool’s own description tells the model to forward data to another tool or address. The value is ordinary, an email or an order number, so a detector looking for sensitive formats sees nothing wrong. What is wrong is who receives it. The MCPTox pack in the AgentLeak corpus reproduces this: of its 24 recipient-hijack scenarios, the pattern-only tier calls 15 clean.

The tool changes after you approved it

A server can update a tool’s description or schema between sessions. A tool that was reviewed as harmless can start asking for a new field, or two servers can expose tools with the same name so a call reaches the wrong one.

Before merge: let the coding agent check itself

agentleak mcp serves nine local tools to Claude Code, Cursor and any MCP client. The one that matters most is privacy_preflight: before the coding agent says it is done, it scans the project and reports what its change introduced, what it fixed and what is still open. No account, key or network connection is needed.

pip install "agentleak[mcp]"
agentleak mcp   # register this command as an MCP server in your editor

At runtime: a gateway in front of each server

agentleak proxy sits between the agent and an MCP server. The agent launches the proxy, the proxy launches the real server, and every tools/call is judged before it is sent.

agentleak proxy \
  --config agentleak.yaml \
  --evidence evidence.jsonl \
  -- npx -y @modelcontextprotocol/server-github

The policy says which data type may go to which recipient, for which purpose:

privacy_policy:
  flows:
    - data_type: sin
      to: server-github
      for: identity_check
    - data_type: health_condition
      to: "*"
      deny: true
    - data_type: group:credentials
      to: "*"
      deny: true

Each call gets one of three answers.

AnswerWhenWhat the server receives
AllowNothing sensitive, or every flow permittedThe call, unchanged
RedactA flow is not permittedThe call, with only the offending values replaced
BlockA deny rule names the flowNothing; the agent gets a readable refusal

Redaction is the default for a refusal, and that is deliberate. A gateway that blocks whatever it dislikes breaks the agent and gets switched off within a week. One that removes a single field keeps the task working.

Details that decide whether it holds

  • Encoding. Arguments are decoded from base64, hex, URL encoding and letter spacing before they are judged, so an encoded identifier is redacted like a plain one.
  • Tool pinning. Each tool’s definition is fingerprinted on first use. A changed definition is reported, or hidden and refused with --block-changed-tools.
  • Responses. With --inspect-responses, results coming back from a tool are judged too, which catches data a tool returns that the agent should not hold.
  • Evidence. Every decision is written to a hash-chained log, optionally signed with an Ed25519 key, and agentleak evidence verifies it.
  • The model is a recipient too. agentleak llm-proxy applies the same rules to what the agent sends its model, through an OpenAI-compatible endpoint.

What the research measured on tool calls

The AgentLeak paper looked at tool inputs, channel C3, on a sample of 100 scenarios per model. Agents forwarded unfiltered sensitive data to external tools in 62% to 86% of those scenarios, with GPT-4o-mini the most restrained and Llama 3.3 70B at the top of the range. The authors read this as agents treating tool parameters as an internal workspace, not as a trust boundary that needs minimization. In the same study, attacks aimed at the tool surface succeeded in 78.9% of 484 tests.

These are benchmark conditions, so they are not a forecast for your agent. They explain why the gateway’s default of judging every call is the right shape: the common failure is a well-meaning agent that sends too much, not only an attacker.

Treat each server’s text as untrusted input

A tool’s name, description and schema are read by the model as instructions about how to use it. A server you did not write can therefore influence what the agent sends. Review a server’s definitions before approving it, record a fingerprint, and review again when it changes. Prefer servers that expose the narrowest tools for the job, since a tool that cannot send an email cannot be talked into sending one. When two servers expose the same tool name, rename one at the gateway so a call cannot reach the wrong destination.

A short checklist

  1. List every MCP server your agents connect to, and name each one as a recipient.
  2. Write a flow rule for each sensitive data type the agent can reach, and deny credentials everywhere they are not needed.
  3. Replay a recorded run through the CI gate with the same policy before you deploy the gateway.
  4. Put the gateway in front of each server and keep the evidence log.

Questions

What is MCP tool poisoning?

An attack in which a tool’s description or response carries instructions the model follows, for example to add a field to a call or send data to a different tool. The user approved the server, not the instructions hidden in it.

Does an MCP gateway require changes to the agent?

No. The agent launches the gateway instead of the server, and the gateway launches the real server as a child process and forwards JSON-RPC. Only tools/call messages are judged; everything else passes untouched.

Does the gateway need an LLM to decide?

No. Decisions come from the same deterministic detectors and flow rules the CI gate uses, so the same call always gets the same answer and the decision can be audited.

Are credentials blocked by default?

No. A data type no rule names is recorded and forwarded, because a database server legitimately needs its connection string. Add a deny rule for group:credentials on every server that should never receive one.

Sources

  1. AgentLeak software benchmark, 491 scenarios, AgentLeak 0.20.0
  2. Runtime gateway documentation
  3. MCP server for coding agents
  4. MCPTox benchmark, Wang et al., AAAI 2026

Run it on your own agent.

AgentLeak is open source and runs locally. The first scenario takes one command and no key.