
Sovereign AI
Agentic AI Governance: Auditing What Your Agents Did
Agentic AI governance belongs at the MCP gateway, not the prompt: per-agent identity, a tool allow-list, a record per tool call, approvals outside the agent.
Most writing on agentic AI governance describes approval workflows: the agent proposes, a person approves, the agent proceeds. When that approval is a flag in the agent's own code — require_approval: true beside the tool definition — a prompt injection, framework bug or config edit can change it. A control that lives inside the thing it constrains is a convention, not a control.
The audit question mirrors it: which agent called which tool, with what arguments, on whose behalf, and who allowed it. If the only record is the agent's context window or framework log, the answer comes from the component under investigation. This article moves both enforcement and record to the gateway every tool call already passes through.
Why approval in the agent is not a control
The Model Context Protocol specification (revision 2026-07-28) says the protocol itself does not mandate any user interaction model, and that for trust and safety there SHOULD always be a human in the loop able to deny tool invocations. Whether a human can say no depends on where the application put the check.
The same page closes a shortcut: clients MUST treat those annotations as untrusted unless they come from trusted servers. An approval rule keyed on a tool calling itself read-only is controlled by the tool's author.
LLM06:2025 Excessive Agency is the vulnerability that lets damaging actions happen in response to unexpected, ambiguous or manipulated model output, whatever caused the malfunction. Its seventh mitigation is complete mediation: implement authorisation in downstream systems rather than relying on the model to decide whether an action is allowed. The OWASP Top 10 for Agentic Applications 2026 adds ASI02 Tool Misuse and Exploitation, where an agent misuses legitimate tools through prompt injection, misalignment or unsafe delegation, and ASI03 Identity and Privilege Abuse, where delegation chains and cached credentials are manipulated to escalate access.
Four controls at the gateway
- A credential per agent. Each agent authenticates to the gateway with its own identity — a JWT whose subject names the agent, or a per-agent virtual key. No shared key, and no token passthrough: MCP's security best practices state that servers MUST NOT accept tokens not explicitly issued for them, and the authorization specification requires servers to validate the token's audience per RFC 8707.
- A tool allow-list evaluated at the gateway. Which identity may call which tool is a policy the gateway evaluates on every
tools/listandtools/call, not a list the agent filters for itself. - A record per tool call. Every
tools/call, allowed or denied, produces a record the gateway emits and ships to a sink the agent cannot write to. - An out-of-process approval for high-impact tools. For the small set of tools whose effect is hard to reverse, the gateway allows the call only if an approval record for that agent, that tool and that exact argument hash already exists in a store the agent cannot reconfigure. Otherwise it denies.
Designs get the fourth control wrong. The human decision happens before the call, out of band: a person reviews the proposed action and the approval service writes a record. When the agent sends the tools/call, the gateway does a fast lookup; nobody waits on the synchronous path. A miss, a store error or a timeout all mean deny.
One network control makes the rest hold: MCP servers reachable only from the gateway. A default-deny network policy admitting only the gateway enforces it — auditing whether default deny is in force is its own discipline.
Three gateways, measured against the four
Three open-source gateways can carry part of this today, measured by what each enforces and records per tools/call.
agentgateway
agentgateway is a Linux Foundation project contributed by Solo.io in August 2025, Apache-2.0 licensed, at v1.8.1 (published 2026-12-01) at the time of writing. Its MCP authorization policies are CEL rules evaluated against MCP method invocations such as tools/list and tools/call. A tool a caller is not allowed to use is filtered out of the list response, and a call to it is answered as if the tool did not exist, with JSON-RPC error -32602. Rules can read JWT claims, so jwt.sub binds the allow-list to the agent's identity.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
# agentgateway (standalone, v1.8.x) in front of one MCP server.
frontendPolicies:
accessLog:
filter: 'mcp.methodName == "tools/call"'
add:
agent: 'jwt.sub'
tool_args: 'mcp.tool.arguments'
tool_error: 'mcp.tool.error'
mcp:
port: 3000
policies:
mcpAuthentication:
issuer: https://idp.example.com/realms/agents
audiences: ["https://mcp-gw.example.com/mcp"]
jwks:
url: https://idp.example.com/realms/agents/protocol/openid-connect/certs
provider:
keycloak: {}
resourceMetadata:
resource: https://mcp-gw.example.com/mcp
bearerMethodsSupported:
- header
mcpAuthorization:
rules:
- allow: 'jwt.sub == "agent-triage" && mcp.tool.name in ["search_issues", "get_issue"]'
- allow: 'jwt.sub == "agent-release" && mcp.tool.name in ["search_issues", "delete_release"]'
- deny: 'has(mcp.tool.name) && mcp.tool.name == "delete_repository"'
extAuthz:
host: opa.governance.svc:9191
includeRequestBody:
maxRequestBytes: 8192
allowPartialMessage: false
policies:
http:
requestTimeout: "500ms" # tighter than the 2s default
protocol:
grpc: {}
targets:
- name: github
mcp:
host: http://github-mcp.tools.svc:8080/mcp
On the record side, agentgateway's MCP observability page lists default structured-log fields including mcp.method.name, mcp.target and gen_ai.tool.name, the last emitted for tool-call requests. Tool arguments and results are not in the default log; an access-log CEL policy adds them (mcp.tool.arguments, mcp.tool.result). The default list names no caller-identity field, so agent: 'jwt.sub' is this article's addition — confirm it against the CEL reference for your version.
LiteLLM
LiteLLM is MIT-licensed outside its litellm/enterprise/ directory (separately licensed); latest release v1.112.2 (2026-12-04). It manages MCP permissions per key, team and organisation, and when a client lists tools it returns only those the entity may access. A virtual key per agent is the identity; object_permission on that key is the allow-list.
#!/usr/bin/env bash
set -euo pipefail
# One LiteLLM virtual key per agent. The master key lives in the operator's
# environment, never in the agent's. The budget figure is illustrative.
curl -sS -X POST "https://llm-gw.example.com/key/generate" \
-H "Authorization: Bearer ${LITELLM_MASTER_KEY}" \
-H "Content-Type: application/json" \
-d '{
"key_alias": "agent-triage",
"max_budget": 25,
"object_permission": {
"mcp_servers": ["github_mcp"],
"mcp_tool_permissions": {
"github_mcp": ["search_issues", "get_issue"]
}
}
}'
LiteLLM's MCP guardrails can run pre_mcp_call, on the input before the call, and post_mcp_call, on the tool result before the model sees it — the hook point where an approval check could live. Its standard logging payload carries an MCP tool-call object with the tool name and its arguments, so arguments are recorded where they are not in agentgateway's default log. The LiteLLM MCP gateway article covers where that payload goes.
IBM ContextForge
ContextForge (Apache-2.0, v1.1.2, 2026-11-25) enforces two layers on every tool operation: the teams claim in the caller's JWT decides which tools are visible, and RBAC decides execution — a caller who can see a tool but lacks tools.execute gets a 403. Its tool_pre_invoke plugin hook can block a call with a violation. Its security policy offers no backported security patches or long-term support branches, and says it is not a standalone product but one layer in a larger architecture: plan to upgrade continuously.
In ContextForge v1.1.2 the tool.invoke span records arguments_count, not argument values; values are written as langfuse.observation.input only when otel_capture_input_spans includes tool.invoke, and that setting defaults to empty.
What none of them ships
- agentgateway: identity and allow-list at the gateway; arguments logged only via access-log CEL; approval via external authorisation you build.
- LiteLLM: identity and allow-list per virtual key; arguments in the logging payload; approval via a
pre_mcp_callguardrail you build. - ContextForge: JWT teams for visibility, RBAC for execution; argument values off by default; approval via a
tool_pre_invokeplugin you build.
None ships a human-approval step. A fourth option, Envoy AI Gateway, has been renamed Agent Router under the Agentic AI Foundation and is not compared here. For routing and fallback rather than tool authorisation, see LiteLLM alternatives.
Building the approval step the gateways do not ship
agentgateway can delegate authorisation to an external service such as Open Policy Agent, and is API-compatible with Envoy's External Authorization gRPC service — so OPA's Envoy plugin can answer it, with its decision path pointed at mcp/authz/allow. The call times out after 2 seconds by default, set with requestTimeout under the extAuthz block's own policies.http. The setup instructions say to keep Deny as the failure mode. And the request body — which carries the tool arguments you need to hash — is sent only if includeRequestBody is configured, buffered up to maxRequestBytes (default 8192); the documented MCP example forwards JWT claims only. Leave allowPartialMessage false: a policy hashing truncated arguments would match the wrong approval, so an oversized body should be refused, not trimmed.
# mcp_authz.rego — OPA decision for agentgateway extAuthz (opa-envoy-plugin, path mcp/authz/allow)
package mcp.authz
import rego.v1
default allow := false
# Hard-to-reverse tools, listed here rather than in the agent's config.
high_impact := {"delete_release", "merge_pull_request", "rotate_deploy_key"}
# mcpAuthentication already verified the token; only the subject is read.
bearer := t if {
auth := input.attributes.request.http.headers.authorization
startswith(auth, "Bearer ")
t := substring(auth, 7, -1)
}
agent := claims.sub if {
[_, claims, _] := io.jwt.decode(bearer)
}
# Undefined if the body is missing or not JSON, so every rule below fails closed.
rpc := json.unmarshal(input.attributes.request.http.body)
tool := rpc.params.name
args_sha256 := crypto.sha256(json.marshal(object.get(rpc.params, "arguments", {})))
# Any method other than tools/call (initialize, tools/list, notifications).
# Safe only because the CEL mcpAuthorization rules still run; not a standalone gate.
allow if {
is_string(rpc.method)
rpc.method != "tools/call"
}
# Low-impact tools: the allow-list already admitted this identity.
allow if {
rpc.method == "tools/call"
not tool in high_impact
}
# High-impact tools: an unexpired approval for this exact call must exist.
allow if {
rpc.method == "tools/call"
tool in high_impact
some a in data.approvals
a.agent == agent
a.tool == tool
a.args_sha256 == args_sha256
time.now_ns() < a.expires_ns
}
The approval service pushes records into data.approvals via OPA's data API or a bundle, on a path the agent cannot reach, and must compute args_sha256 over byte-identical JSON: sorted keys, no whitespace. Go's and Python's encoders escape differently by default; test both against one vector.
In ContextForge the same check is a tool_pre_invoke plugin, with different timing. The 60-second tool_timeout default is only the fallback for the upstream invocation timeout, which a per-tool timeout_ms replaces. The hook does not run under that timer: each plugin execution is wrapped in its own configurable timeout, 30 seconds by default, and a timed-out plugin is treated as an error according to its mode. That is where the fail-open hides. With plugin_settings.fail_on_plugin_error at its default of false, enforce blocks on errors, but enforce_ignore_error continues on plugin errors and permissive lets the request continue. In either mode, a store outage or slow lookup lets the high-impact call through.
# excerpt — plugin class boilerplate elided (packaging, registration)
import hashlib
import json
import time
import httpx
from cpex.framework import (
Plugin,
PluginContext,
PluginViolation,
ToolPreInvokePayload,
ToolPreInvokeResult,
)
HIGH_IMPACT = {"delete_release", "merge_pull_request", "rotate_deploy_key"}
APPROVAL_STORE = "https://approvals.governance.internal"
def args_sha256(args: dict | None) -> str:
# Must match the approval service byte for byte: sorted keys, no spaces.
canonical = json.dumps(args or {}, sort_keys=True, separators=(",", ":"), ensure_ascii=False)
return hashlib.sha256(canonical.encode("utf-8")).hexdigest()
def caller_email(context: PluginContext) -> str | None:
# v1.1.2: MCP tools/call sets user to the caller email string; only the
# REST get_current_user path sets a dict (email, is_admin, full_name).
gc = context.global_context
user = gc.user
email = user.get("email") if isinstance(user, dict) else user
email = email or getattr(getattr(gc, "user_context", None), "email", None)
return email if isinstance(email, str) and email not in ("", "unknown") else None
def is_live_match(record: object, query: dict, now: float) -> bool:
if not isinstance(record, dict):
return False
expires_at = record.get("expires_at") # epoch seconds
return (
record.get("agent") == query["agent"]
and record.get("tool") == query["tool"]
and record.get("args_sha256") == query["args_sha256"]
and isinstance(expires_at, (int, float))
and expires_at > now
)
def deny(code: str, reason: str) -> ToolPreInvokeResult:
return ToolPreInvokeResult(
continue_processing=False,
violation=PluginViolation(code=code, reason=reason, description=reason),
)
class ApprovalGate(Plugin):
async def tool_pre_invoke(
self, payload: ToolPreInvokePayload, context: PluginContext
) -> ToolPreInvokeResult:
if payload.name not in HIGH_IMPACT:
return ToolPreInvokeResult(continue_processing=True)
agent = caller_email(context)
if agent is None:
return deny("NO_IDENTITY", "High-impact tool called without an identity")
query = {"agent": agent, "tool": payload.name, "args_sha256": args_sha256(payload.args)}
try:
# One fast lookup, far inside plugin_timeout. Never poll, never wait for a person.
async with httpx.AsyncClient(timeout=2.0) as client:
r = await client.get(f"{APPROVAL_STORE}/v1/approvals", params=query)
r.raise_for_status() # any non-2xx raises
records = r.json()
except (httpx.HTTPError, ValueError):
return deny("APPROVAL_STORE_ERROR", "Approval store error; failing closed")
# A 200 is not an approval: only an unexpired record matching all three keys is.
now = time.time()
if isinstance(records, list) and any(is_live_match(rec, query, now) for rec in records):
return ToolPreInvokeResult(continue_processing=True)
return deny("NO_APPROVAL", "No unexpired approval for this agent, tool and arguments")
# excerpt — plugins/config.yaml, the approval plugin only
plugins:
- name: "ApprovalGate"
kind: "approval_gate.ApprovalGate"
hooks:
- "tool_pre_invoke"
mode: "sequential" # legacy name: enforce. Never transform/permissive here.
priority: 10 # on_error omitted: its default, fail, blocks on error
plugin_settings:
plugin_timeout: 30 # seconds; the lookup must finish well inside this
fail_on_plugin_error: true # any plugin error reaches the client, whatever the mode
ContextForge v1.1.2 renamed its modes when it moved to the CPEX plugin framework: `enforce` maps to `sequential`, enforce_ignore_error to sequential with on_error: ignore, and permissive to transform. For an approval plugin use sequential without on_error: ignore, and also set fail_on_plugin_error: true, which bubbles any plugin error up to the client regardless of mode.
In both gateways, do not raise requestTimeout or tool_timeout until a person can answer: that puts the person back on the synchronous path. Deny, let the agent surface the request, approve out of band, let it retry. This is also where NIST AI RMF MANAGE 2.4 belongs: mechanisms and assigned responsibilities to supersede, disengage or deactivate AI systems behaving inconsistently with intended use. A fail-closed gateway an operator tightens without touching the agent is one.
The record per tool call
Align the record with the OpenTelemetry GenAI `execute_tool` span: gen_ai.operation.name SHOULD be execute_tool, gen_ai.tool.name is required and gen_ai.tool.call.id conditionally required. The convention is at Development status, so names may change; pin the version you emit, then add the fields an auditor needs.
{
"timestamp": "2026-12-05T09:14:22.418Z",
"trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
"gen_ai.operation.name": "execute_tool",
"gen_ai.tool.name": "delete_release",
"gen_ai.tool.call.id": "call_7Qm2",
"agent.id": "agent-release",
"on_behalf_of": "user:release-manager-on-call",
"args_sha256": "0dc8c18af13b78f48989d79717b89321471bd8d5b0c6d9be9667ef6b045e2a99",
"decision": "allow",
"decision_rule": "mcp.authz high_impact approval",
"approval": {
"id": "apr-2026-12-05-0031",
"approver": "user:platform-lead",
"expires": "2026-12-05T10:00:00Z"
},
"gateway": "agentgateway v1.8.1"
}
Those fields answer the questions NIST's NCCoE asks in its February 2026 concept paper on software and AI agent identity and authorization: how agents can log actions and intent in a tamper-proof, verifiable manner, and how to ensure non-repudiation that binds agent actions back to human authorisation. agent.id and on_behalf_of are the binding; approval.approver is the human authorisation; the hash lets the record prove which arguments were approved without keeping them.
Key the record on trace_id and gen_ai.tool.call.id, not a session: agentgateway logs mcp.session.id by default, but clients on the current MCP protocol revision get no Mcp-Session-Id, stateful or not. Hashing arguments keeps secrets and personal data out of the trail. The Langfuse versus LangSmith comparison covers where full traces should live when you do need them.
Retention, regulators and the audit question
The EU AI Act's logging duties apply only to high-risk systems, which most internal agents are not. Article 12(1) is a capability duty: high-risk systems shall technically allow automatic recording of events over their lifetime, with no retention period set there. Article 19(1) makes providers keep those logs, where under their control, for a period appropriate to the intended purpose, of at least six months, unless Union or national law provides otherwise, in particular data-protection law. Article 26(6) puts the same duty, floor and proviso on deployers, for the automatically generated logs under their control. The EU AI Act deployer summary works through scope.
ISO/IEC 42001 control A.6.2.8 — quoted here from a secondary summary, since the standard is paywalled — lets the organisation choose the life-cycle phases with event logging, but at the minimum when the AI system is in use — so production tool calls cannot go unlogged.
Ship records to a store the agent has no credentials for: a SIEM, as in the Kubernetes audit log to Wazuh pipeline, or an object-lock bucket, as described in immutable backups. Set retention per stream and record who set it — the policy clause an auditor will ask for.
Failure modes
- Gateway bypass. An agent that reaches an MCP server directly skips every control. Enforce reachability with network policy.
- Shared keys. One key for five agents yields a perfect log nobody can attribute.
- Argument logging that leaks. Turning on
mcp.tool.argumentsorotel_capture_input_spanscopies credentials and personal data into the log store. Prefer the hash. - Approval fatigue. If every call needs approval, approvers stop reading. Keep the high-impact set small; make approvals expire.
- Fail-open timeouts. An extAuthz failure mode set to allow, or a ContextForge approval plugin in
enforce_ignore_errororpermissivewithfail_on_plugin_errorfalse, lets a store outage or aplugin_timeoutexpiry run the high-impact call. Test it: stop the approval store and confirm the call is denied. - Spec and convention drift. The MCP spec, OTel conventions and all three gateways move. Re-run bypass and fail-closed tests on every upgrade.
Exit ramps and the long game
Keep policy outside any one gateway. The Rego policy and approval store work behind anything that speaks Envoy ext_authz; the hash and record schema are yours. Records shaped like OTel execute_tool spans stay queryable after you swap gateway, agent framework or model. Agents will be rewritten many times; the trail of what they did has to outlive every version.
§FAQ/Common questions
Frequently asked
What is agentic AI governance?
Agentic AI governance is the set of controls that decide which actions an AI agent may take through its tools, and that record what it actually did. To be enforceable, those controls have to sit outside the agent — typically at an MCP gateway — so that the agent's own prompt, code or configuration cannot switch them off.
Why is a human-approval flag in the agent framework not enough?
Because it lives in the process it is meant to constrain. A prompt injection, a framework bug or a configuration edit can change it. OWASP's LLM06 guidance recommends complete mediation — authorisation in downstream systems rather than relying on the model to decide — and the MCP specification treats a human in the loop as a SHOULD for applications, not something the protocol enforces.
Which open-source MCP gateways support per-agent tool allow-lists?
agentgateway evaluates CEL rules on tools/list and tools/call and can bind them to JWT claims; LiteLLM restricts MCP servers and tools per virtual key, team or organisation; IBM ContextForge combines JWT team scoping for visibility with RBAC on tools.execute. None of the three ships a built-in human-approval step, so that has to be built with external authorisation or a plugin hook.
How should a human approval work without blocking the tool call?
The person approves first, out of band, and the approval service writes a record keyed on agent, tool and a hash of the exact arguments. At call time the gateway only looks that record up and denies on a miss, a store error or a timeout. Do not raise gateway timeouts to wait for a person: agentgateway's ext_authz default is 2 seconds and ContextForge plugins run under a 30-second per-plugin timeout.
How long should agent tool-call logs be kept?
There is no universal figure. Where an agent is part of a high-risk system under the EU AI Act, Article 19(1) requires providers, and Article 26(6) deployers, to keep the logs under their control for a period appropriate to the intended purpose and of at least six months, unless Union or national law, in particular data-protection law, provides otherwise. Outside that scope, your policy owner decides and records retention.
Further reading
- LiteLLM as an MCP Gateway: Sovereign AI Data Residency
- LiteLLM Alternatives: Where Your LLM Gateway Should Live
- Kubernetes Audit Logs Into a SIEM You Operate: Wazuh
- Langfuse vs LangSmith: Where Your Prompts and Traces Live
- AI Governance Policies for Teams That Run Their Own Models
- Immutable Backups: Object Lock and Proving You Can Restore
- EU AI Act Summary: What Actually Binds a Deployer
- Default Deny, Actually: Auditing Kubernetes Network Policy
Executive Briefing
Thirty minutes to clarify your infrastructure risk
Walk us through your vendor footprint and regulatory constraints. We will tell you honestly where sovereignty creates leverage — and where it does not. No pitch deck. No obligation.