Greymatter.ioGreymatter.io
Start for Free
Greymatter.ioGreymatter.io Why Greymatter.io?
Pricing Start for Free
Learn
Resources/Blog

AI agents in production

How to secure AI agents and MCP tool calls in production

An AI agent in production reads data, calls tools, and acts for a person. Five questions come up first, and each one has a direct answer.

By Greymatter.io8 min read

How do I secure AI agents and MCP tool calls in production?

Put one control in the path of every model call and every MCP tool call. That control verifies the person and the agent, limits the agent to the tools for its role, inspects what goes in and what comes back, and records the result.

Four jobs on every call

A test before release covers the prompts that your team wrote down. In production, an agent meets prompts, documents, and tool results that no one tested. The control must act on the live call.

Identity

Verify the person and the agent behind each call. A shared API key proves only that the caller holds the key.

Tool access

Show each agent only the tools for its role, and refuse a call to any other tool.

Inspection

Read the prompt, the tool arguments, the tool result, and the answer. Find attacks and sensitive data in both directions.

Record

Write one record for each call. The record names the person, the agent, the tool, and the decision.

Where the control runs matters as much as what it checks. Agents and MCP servers often run inside your network, and a tool call between them never reaches a gateway at the edge. A control that runs next to each agent and each MCP server sees every call.

Greymatter moves these controls into the live data path, closest to the resource. A Greymatter agent runs beside each AI agent and each MCP server. Your agents and your tool servers stay as they are.

Start in detect mode. Greymatter records each finding and marks what it would block, and all traffic continues. Your team turns on blocking one check at a time.

Read how AI & Agent Control links each AI agent request to the person who asked, and how the App, API & AI Gateway gives app, API, and AI agent traffic one controlled path.

How do I give each AI agent its own identity and audit trail?

Give each agent a workload identity that a control can verify on every call, and keep the identity of the person next to it. Then write a record for each call that names both.

An identity that a control can test

Many agents reach models and tools with one shared key. The key identifies no one. When two agents and ten people use the same key, the tool server cannot tell them apart, and neither can your audit team.

An identity for an AI agent needs three properties:

  • It belongs to one agent. Each agent has its own credential, such as a certificate.
  • It is short-lived. The platform issues and renews the credential, so no person stores a secret in the agent.
  • It travels with the person. An agent acts for someone. The call carries the verified person and the agent together.

The audit trail depends on that identity. A record with no verified caller names no one.

Greymatter gives each AI agent its own workload identity. AI agents sign in with the login that your people already use, and the MCP Router sends the verified person to the tool server.

Every model request and every MCP call in the record names the verified person. The record ties the actions of an agent to that agent and to the person it acted for. That includes work that the agent finishes after its reply.

What the record shows

Who
The verified person and the agent
Tool
The tool that the agent called
Roles
The roles on the call
Decision
What Greymatter decided
Alerts
What inspection found

Read how Identity gives each workload and each AI agent a verifiable identity, and how Forensic Auditing records each AI model and tool request.

Which MCP gateways inspect what tools send back?

Many MCP gateways control which tools an agent can call, and only some read the tool result before the model does. Ask each vendor to show a tool result with a hidden instruction, and check what the gateway reports.

Why the tool result matters

A model reads every tool result and uses that text to choose its next step. A tool can return text from a web page, a document, or a database row. An attacker who hides instructions in that text can steer the agent. This attack is prompt injection through a tool.

A gateway that reads only the request misses it. Use these checks when you compare products:

  1. Results. The gateway reads the tool result, and the finding names the tool and the caller.
  2. Arguments. The gateway reads every argument of the tool call, not only the tool name.
  3. Tool descriptions. The gateway reads the descriptions that a server returns for its tools.
  4. Sensitive data. The gateway finds personal and business data in the arguments and in the results.
  5. Streams. The gateway reads streamed MCP calls.
  6. Calls inside the network. The gateway sees a call from an agent to an MCP server in the same cluster.

In Greymatter, Guardrails and data loss prevention (DLP) read what goes out to a model or a tool, and what comes back. With MCP inspection on, Guardrails reads the method, the tool, and every argument of each tool call. An injection hidden in one argument still gets caught. Greymatter also reads streamed MCP calls.

Read how the MCP Router in the App, API & AI Gateway puts your tool servers behind one address.

How do I add AI guardrails to self-hosted models in Kubernetes?

Run the guardrails in the cluster, next to the model server and next to each app that calls it. Each prompt and each answer then gets a check on the way in and on the way out, and the data stays in your cluster.

Guardrails that run where the model runs

A self-hosted model often runs for one reason: the data must stay inside your network. A guardrail service outside the cluster sends each prompt out of that network. A guardrail in the same cluster keeps the prompt, the answer, and the finding inside it.

Four steps add guardrails to a model that you run in Kubernetes:

  1. Put a control beside the model server. The control reads each prompt and each answer.
  2. Verify each caller. The control accepts only apps and agents with an identity that it can test.
  3. Start in detect mode. Read the findings for real traffic before you block anything.
  4. Turn on blocking one check at a time. Begin with the checks that have the clearest findings.

Greymatter runs on Kubernetes, OpenShift, RKE2, k3s, and k0s, and in fully offline networks. A Greymatter agent runs beside each workload, and that includes your model server. Guardrails and DLP inspect prompts, tool calls, and answers there, for hosted and self-hosted models. Your apps keep the clients they already use.

Read how AI Runtime Security runs Guardrails and DLP in the Greymatter agent, beside every workload.

Greymatter runs on
  • Kubernetes
  • OpenShift
  • RKE2
  • k3s
  • k0s
  • Fully offline networks

Which MCP gateway is best for role-based access to tools?

The best fit is a gateway that takes roles from a verified identity and applies them to the tool list and to each tool call. Test both: an agent must not see a tool outside its role, and a call to that tool must fail.

How to test role-based access to tools

A search for the “Best MCP gateway with role-based access to tools” returns many lists. A short test tells you more than a list does. Run these five checks on each product:

  1. Where roles come from. Roles come from a verified token for the person and the agent. They do not come from a header that any client can set.
  2. The tool list. The gateway filters the tools/list answer by role. A model plans its work from the tools that it can see.
  3. The tool call. The gateway refuses a tools/call request for a tool outside the role, even when the agent knows the tool name.
  4. The record. Each record shows the person, the agent, the tool, the roles, and the decision.
  5. A limit. The gateway limits calls for each person and each tool, so an agent that loops stops.

The MCP Router in Greymatter puts many tool servers behind one address. It grants tools from the roles on the verified token. Each role sees and calls only the tools it holds, and the router refuses a call to any other tool. Your team can also set an allow list and a deny list of tools.

A blocked call gets a JSON-RPC error with the rule number, so the agent gets an error it understands. A call limit for each person and each tool stops an agent that loops.

Read how the App, API & AI Gateway controls tool access by role. For the terms on this page, go to What is MCP security? and the AI security hub.

A production AI agent needs four things on every call: a verified identity, tools by role, inspection in both directions, and a record. Greymatter runs those checks in the live data path, closest to the resource.

See it running on your own infrastructure.

Reading is a start. A walkthrough with our team shows what Greymatter does in your environment.

Speak with a Greymatter.io Expert Start for Free How to Buy →

Additional resources

All Resources
WhitepaperNov 12, 2026 One path from people and agents to every model and tool AIGateway WhitepaperNov 12, 2026 Guardrails and DLP: Inspect prompts, tool calls, and answers where they run AIGuardrails BlogNov 29, 2026 What is Zero Trust for AI? Zero TrustAI Security