Dev.to Security ๐Ÿ” Cybersecurity ๐Ÿ‘ 0 ๐Ÿ“– 4 min read

Your local MCP tool can still hand originals back to the model

I built a local masking tool because I did not want my own data drifting off everywhere. In today's world, professional secrecy is given up unintentionally, in ways people often do not know about. That is why I documente

Your local MCP tool can still hand originals back to the model

I built a local masking tool because I did not want my own data drifting off everywhere. In today's world, professional secrecy is given up unintentionally, in ways people often do not know about. That is why I documented the boundary below instead of hiding it.

This post is for two groups. If you build MCP servers or AI tools, you get the data flow and a check you can run. If you buy or approve such tools, start with the five questions directly below.

Five questions before you approve an AI tool

  1. Where does the tool run, and where does its output go next?
  2. Can a model call a tool that returns original, unmasked values?
  3. Which outbound requests, logs or synced histories can contain those values?
  4. Has the vendor or your team tested this with fictional values, and can you see the result?
  5. What does the documentation say the tool does not protect?

If an answer is "we don't know", record it as an open point before approval.

"Runs locally" describes where a tool executes. It does not describe where its output goes.

That distinction matters when one tool masks sensitive text and another can restore it. A server can make zero network requests while its calling client receives the original values. Whether those values then reach the model depends on the client and the workflow.

This is not an MCP vulnerability claim. It is a data-flow question worth asking before you rely on a local masking workflow.

What I decided in my own server

I kept the mapping table between placeholders and originals inside the server process. It is never written into a tool response.

The restore tools are different. They return the originals to the calling client โ€” and from there the client may pass them to its model. I decided not to hide that. The README states it as a restoration boundary: if originals must stay exclusively local, restore them in your own application code outside the model context, not through a model-callable tool.

For me, the honest answer to "is it local?" is: the processing is local, the disclosure is a choice.

Code: https://github.com/PromptAudit-SaaS/mcp ยท https://github.com/PromptAudit-SaaS/shield

Follow one fictional email address

Start with a support message:

Please contact [email protected] about project Orion.

A local masking step might produce:

Please contact [EMAIL_1] about project [TERM_1].

The tool keeps a placeholder-to-original mapping in its process. The model receives the masked version and rewrites it:

Could you follow up with [EMAIL_1] regarding [TERM_1]?

Now the design choice: who performs restoration, and who receives the restored result?

Diagram comparing Design A, where a model-callable tool returns restored originals to the client, and Design B, where the local application restores them outside model context

Design A: restoration is a model-callable tool

The model requests restoration, the local tool restores the originals, and the MCP client receives the restored result. The client may then include that result in model context.

The mapping stayed local. The restored values did not stay confined to the masking process. That can be intentional. But "local server" alone does not establish that the model never sees originals.

Design B: restoration happens outside model context

The model returns a masked response, the local application restores it, and the user sees the restored response.

Here restoration is a separate application step rather than a model-callable tool. That only preserves the boundary if the application does not forward the restored result into a later model request, another tool, remote logs or synced conversation history.

A fictional-canary check for your own workflow

You do not need real customer data.

  1. Create a synthetic value such as [email protected]. Never use a real secret.
  2. Supply it directly to the masking step โ€” not first to the assistant, or you have already put the original into the conversation.
  3. Ask the assistant to work only on the masked output.
  4. Restore through the intended path.
  5. Inspect the tool result and, where your client permits it, the next outbound model request. Check conversation history and configured logging or sync destinations too.

If the restored value appears in an outbound model request, it crossed that boundary. Its appearance only in a client-side tool result proves client receipt, not necessarily provider receipt.

If you cannot inspect the outbound request, record that uncertainty. A hidden tool result in the UI is not proof that it was excluded from model context.

This is a proposed diagnostic, not a report of testing every MCP client. One successful check also cannot establish the absence of other disclosure paths.

Separate three questions

Question What it tells you
Where does the tool execute? Execution location
What can the tool read or return? Tool capabilities
What does the client send onward? Data egress and model exposure

"Local" answers the first question only.

Likewise, "no supported pattern detected" is not the same as "safe to share". Pattern matching can miss sensitive values and flag harmless ones. An installed tool also does not necessarily intercept outgoing prompts.

The design question

If the requirement is original values must remain outside model context, keep restoration in the local application and examine every subsequent forwarding path. If a workflow deliberately permits originals in model context, a restoration tool can be convenient โ€” but that permission should be explicit.

Would you expose restoration as a model-callable tool, or keep it application-only? Which concrete workflow would make you choose differently?

If you want to take something from this

Pick whatever fits you, only if you feel comfortable:

  • Approving tools? Use the five questions before your next approval.
  • Building tools? Run the fictional-canary check on your own workflow.
  • Either way: share how you handle it in the comments.

Feedback is very welcome โ€” including disagreement or corrections. If you share an example, describe the data path with fictional values rather than posting sensitive logs.

Disclosure: Written with AI assistance and reviewed by the author. It describes a data-flow distinction and a proposed diagnostic, not an independent security audit or a verified finding about a specific client.

๐Ÿ“ฐ Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.