<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Neurouter blog</title>
  <subtitle>Governing AI agents' tool access with a self-hosted MCP gateway.</subtitle>
  <link rel="self" type="application/atom+xml" href="https://neurouter.com/blog/feed.xml"/>
  <link rel="alternate" type="text/html" href="https://neurouter.com/blog"/>
  <id>https://neurouter.com/blog</id>
  <updated>2026-11-25T00:00:00Z</updated>
  <icon>https://neurouter.com/favicon.svg</icon>
  <logo>https://neurouter.com/icon-512.png</logo>
  <entry>
    <title>Tool poisoning and MCP rug pulls: pin tool definitions like dependencies</title>
    <link rel="alternate" type="text/html" href="https://neurouter.com/blog/mcp-tool-poisoning-rug-pulls"/>
    <id>https://neurouter.com/blog/mcp-tool-poisoning-rug-pulls</id>
    <published>2026-11-25T00:00:00Z</published>
    <updated>2026-11-25T00:00:00Z</updated>
    <author><name>Neurouter team</name><uri>https://neurouter.com/</uri></author>
    <summary>An MCP tool's description is text the model treats as instructions, and the server can change it at any time. Why definitions should be hashed, pinned and reviewed like dependencies, and how Neurouter does it.</summary>
    <content type="html">&lt;p&gt;When an AI client connects to an MCP server, the server sends a list of tools. Each tool has a name, a natural-language description and a JSON Schema for its arguments. The client puts that text into the model&amp;#39;s context, and the model decides what to call based on it.&lt;/p&gt;
&lt;p&gt;That makes a tool description a prompt written by whoever runs the server. Nobody reviews it before the model reads it, and nothing stops the server from changing it next week. This post is about that second part, why we think tool definitions should be treated like dependencies (hashed, pinned and reviewed on change), and where that stops helping.&lt;/p&gt;
&lt;h2 id=&quot;tool-poisoning-instructions-hidden-in-a-description&quot;&gt;Tool poisoning: instructions hidden in a description&lt;/h2&gt;
&lt;p&gt;In April 2025, Invariant Labs published a demonstration they called a &lt;a href=&quot;https://invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks&quot;&gt;tool poisoning attack&lt;/a&gt;. A malicious server offered an &lt;code&gt;add&lt;/code&gt; tool that, as far as the user could tell, added two numbers. Its description also contained an &lt;code&gt;&amp;lt;IMPORTANT&amp;gt;&lt;/code&gt; block telling the model to read &lt;code&gt;~/.cursor/mcp.json&lt;/code&gt; and &lt;code&gt;~/.ssh/id_rsa&lt;/code&gt; and pass their contents in a &lt;code&gt;sidenote&lt;/code&gt; argument, without mentioning it to the user. The model complied; the user saw an explanation of arithmetic.&lt;/p&gt;
&lt;p&gt;The same post described &lt;strong&gt;shadowing&lt;/strong&gt;: a description on one server can change how the agent uses tools on &lt;em&gt;another&lt;/em&gt;, trusted server. Their example told the agent to redirect email sent with a separate &lt;code&gt;send_email&lt;/code&gt; tool to an attacker&amp;#39;s address. The malicious tool never had to be called.&lt;/p&gt;
&lt;h2 id=&quot;rug-pulls-approved-today-changed-tomorrow&quot;&gt;Rug pulls: approved today, changed tomorrow&lt;/h2&gt;
&lt;p&gt;The Invariant post also noted that &amp;quot;a malicious server can change the tool description after the client has already approved it&amp;quot;. A week later they showed it against a WhatsApp MCP server: a second server first advertised a harmless &amp;quot;random fact of the day&amp;quot; tool, then &lt;a href=&quot;https://invariantlabs.ai/blog/whatsapp-mcp-exploited&quot;&gt;changed its description on the second launch&lt;/a&gt; to make the agent send the user&amp;#39;s chat history through WhatsApp&amp;#39;s own &lt;code&gt;send_message&lt;/code&gt; tool. They observed that some clients don&amp;#39;t tell users when a description changes.&lt;/p&gt;
&lt;p&gt;The protocol has a notification for changed tool lists, &lt;code&gt;notifications/tools/list_changed&lt;/code&gt;, but the &lt;a href=&quot;https://modelcontextprotocol.io/specification/2026-07-28/server/tools&quot;&gt;tools section of the MCP specification&lt;/a&gt; defines no versioning or integrity check for an individual definition. It does say that clients &amp;quot;MUST consider tool annotations to be untrusted unless they come from trusted servers&amp;quot;, and that clients should show tool inputs to the user before calling the server. Both are good advice. Neither tells you that the text your model reads today is the text someone reviewed last month.&lt;/p&gt;
&lt;h2 id=&quot;treat-definitions-like-dependencies&quot;&gt;Treat definitions like dependencies&lt;/h2&gt;
&lt;p&gt;Package managers solved a similar problem with lockfiles: you record exactly what you reviewed, and a change has to be accepted on purpose. Invariant&amp;#39;s own recommendation was the same idea: &amp;quot;Clients should pin the version of the MCP server and its tools&amp;quot;, using a hash or checksum. For tool definitions, we think that means six things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Hash a canonical form&lt;/strong&gt; of everything the model reads, so formatting and key order don&amp;#39;t cause false alarms.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Serve the pinned copy&lt;/strong&gt;, not whatever the server sent on the last sync, so a changed description never reaches the model unreviewed.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Block the tool&lt;/strong&gt; when the hash changes, until a person decides.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Show a diff&lt;/strong&gt;, because a reviewer can&amp;#39;t approve what they can&amp;#39;t see.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validate arguments against the pinned schema&lt;/strong&gt;, because new parameters are how data gets out.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Keep every version&lt;/strong&gt; and who approved it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Doing this in each client means doing it on every laptop, for every client product, with every user as the reviewer. Doing it in a gateway that all clients go through means one review covers the whole organization.&lt;/p&gt;
&lt;h2 id=&quot;how-neurouter-pins-tool-definitions&quot;&gt;How Neurouter pins tool definitions&lt;/h2&gt;
&lt;p&gt;Neurouter syncs each upstream server&amp;#39;s tools on a schedule (every 15 minutes by default, configurable per server) and on demand. For every tool it computes:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;definition  = { name, title, description, inputSchema, outputSchema, annotations, execution }
pinned_hash = sha256( JCS(definition) )      # RFC 8785 canonical JSON&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8785&quot;&gt;JCS (RFC 8785)&lt;/a&gt; is a canonical JSON serialization, so whitespace and key order don&amp;#39;t change the hash. What happens next depends on what the sync finds:&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table class=&quot;stack&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th scope=&quot;col&quot;&gt;Upstream sends&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;Tool state&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;Can agents call it?&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td data-label=&quot;Upstream sends&quot;&gt;A tool Neurouter hasn&amp;#39;t seen&lt;/td&gt;&lt;td data-label=&quot;Tool state&quot;&gt;&lt;code&gt;pending_review&lt;/code&gt;&lt;/td&gt;&lt;td data-label=&quot;Can agents call it?&quot;&gt;No, until an owner approves it (or the server has &lt;em&gt;auto-approve new tools&lt;/em&gt; turned on)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Upstream sends&quot;&gt;A definition matching the pinned hash&lt;/td&gt;&lt;td data-label=&quot;Tool state&quot;&gt;&lt;code&gt;active&lt;/code&gt;&lt;/td&gt;&lt;td data-label=&quot;Can agents call it?&quot;&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Upstream sends&quot;&gt;A definition with a different hash&lt;/td&gt;&lt;td data-label=&quot;Tool state&quot;&gt;&lt;code&gt;changed&lt;/code&gt;&lt;/td&gt;&lt;td data-label=&quot;Can agents call it?&quot;&gt;No. Auto-approve never applies to changes (see &lt;em&gt;monitor mode&lt;/em&gt; below)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Upstream sends&quot;&gt;A changed definition that later reverts to the pinned one&lt;/td&gt;&lt;td data-label=&quot;Tool state&quot;&gt;back to &lt;code&gt;active&lt;/code&gt;&lt;/td&gt;&lt;td data-label=&quot;Can agents call it?&quot;&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Upstream sends&quot;&gt;Nothing (tool removed)&lt;/td&gt;&lt;td data-label=&quot;Tool state&quot;&gt;&lt;code&gt;removed&lt;/code&gt;&lt;/td&gt;&lt;td data-label=&quot;Can agents call it?&quot;&gt;No&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;Two details matter more than they look:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The gateway keeps serving the pinned text.&lt;/strong&gt; When a definition changes, Neurouter stores the new one as &lt;em&gt;pending&lt;/em&gt; and leaves the pinned title, description and schemas in place. Clients only see tools through Neurouter&amp;#39;s &lt;code&gt;search_tools&lt;/code&gt; meta-tool, which returns the pinned definition. The new description isn&amp;#39;t shown to any model before someone approves it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Blocked looks like missing.&lt;/strong&gt; While a tool is &lt;code&gt;changed&lt;/code&gt;, a call to it gets the same answer as a call to a tool that doesn&amp;#39;t exist or that the caller isn&amp;#39;t allowed to use. The agent can&amp;#39;t learn from the error that something changed; the server&amp;#39;s owners see it in the console.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure class=&quot;shot&quot;&gt;&lt;a href=&quot;https://neurouter.com/screens/tool-pinning.png&quot; title=&quot;Open full size&quot;&gt;&lt;picture&gt;&lt;source srcset=&quot;https://neurouter.com/screens/tool-pinning-dark.png&quot; media=&quot;(prefers-color-scheme: dark)&quot;&gt;&lt;img src=&quot;https://neurouter.com/screens/tool-pinning.png&quot; alt=&quot;Tool definition diff showing a changed description that adds a hidden instruction&quot; width=&quot;1440&quot; height=&quot;900&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/picture&gt;&lt;/a&gt;&lt;figcaption&gt;Review of a changed tool (live demo, simulated data): the new description asks the agent to post the full conversation to Slack, a new include_drafts parameter defaults to true, the limit maximum grows from 50 to 500 and readOnlyHint flips to false. The tool stays disabled until an owner decides.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;the-review&quot;&gt;The review&lt;/h3&gt;
&lt;p&gt;The owner of the server (or an admin) opens the tool and gets a diff: a word diff of the description, a line diff of the input schema with keys sorted (so reordering isn&amp;#39;t shown as a change), the annotations, and a one-line summary of what changed, such as &lt;code&gt;readOnlyHint&lt;/code&gt; going from &lt;code&gt;true&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt;. The full pinned and pending definitions, output schema included, are available from &lt;code&gt;GET /api/tools/{id}/definition-diff&lt;/code&gt;. Annotations are labelled &lt;em&gt;untrusted&lt;/em&gt; unless an admin has marked the server as trusted, and Neurouter doesn&amp;#39;t derive any policy from them.&lt;/p&gt;
&lt;p&gt;Approval is a compare-and-set on the exact hash the reviewer looked at:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-http&quot;&gt;POST /api/tools/{id}/approve-definition
Content-Type: application/json

{ &amp;quot;hash&amp;quot;: &amp;quot;b7d04e…94af&amp;quot; }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the server changed the definition again while the reviewer was reading, the request fails with &lt;code&gt;409&lt;/code&gt; and &amp;quot;The definition changed since you reviewed it; reload and review again&amp;quot;. You can&amp;#39;t approve a version you didn&amp;#39;t see. Rejecting keeps the tool blocked until a new definition appears.&lt;/p&gt;
&lt;p&gt;Every version is kept with its decision (&lt;code&gt;pending&lt;/code&gt;, &lt;code&gt;approved&lt;/code&gt;, &lt;code&gt;rejected&lt;/code&gt; or &lt;code&gt;superseded&lt;/code&gt;), who decided and when. The detection (&lt;code&gt;tool.definition_changed&lt;/code&gt;) and each decision (&lt;code&gt;tool.definition.approve&lt;/code&gt;, &lt;code&gt;tool.definition.reject&lt;/code&gt;) are written to the &lt;a href=&quot;https://neurouter.com/features/audit-log&quot;&gt;audit log&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id=&quot;strict-and-monitor-modes&quot;&gt;Strict and monitor modes&lt;/h3&gt;
&lt;p&gt;Everything above describes &lt;strong&gt;strict&lt;/strong&gt; mode, the default for every server. It&amp;#39;s the right setting for servers you didn&amp;#39;t write. For MCP servers your own teams build, blocking every description tweak until someone clicks approve is friction that teams will route around. An admin can put such a server in &lt;strong&gt;monitor&lt;/strong&gt; mode: new and changed definitions apply on the next sync, and each one is still hashed, kept as a version, audited as &lt;code&gt;tool.definition_auto_applied&lt;/code&gt; and marked &lt;em&gt;Applied automatically&lt;/em&gt; on the tool. The review moves from before the change to after it, and to the code review of the server itself.&lt;/p&gt;
&lt;p&gt;When a sync in strict mode changes many tools at once, owners can review them together from the server&amp;#39;s Tools tab. The bulk approval sends the exact hashes shown, so a tool that changed again meanwhile is reported back rather than approved.&lt;/p&gt;
&lt;h3 id=&quot;arguments-are-checked-against-the-pinned-schema&quot;&gt;Arguments are checked against the pinned schema&lt;/h3&gt;
&lt;p&gt;On every call, Neurouter validates the arguments against the &lt;strong&gt;pinned&lt;/strong&gt; input schema (JSON Schema 2020-12, compiled once per pinned hash, with no remote &lt;code&gt;$ref&lt;/code&gt; resolution). In the example above, until the change is approved, a call with &lt;code&gt;limit: 500&lt;/code&gt; or an &lt;code&gt;include_drafts&lt;/code&gt; argument is rejected by the gateway before it reaches the server. The call is audited as &lt;code&gt;invalid_args&lt;/code&gt;, and the agent gets the validation errors so it can correct itself.&lt;/p&gt;
&lt;h2 id=&quot;what-a-reviewer-should-look-for&quot;&gt;What a reviewer should look for&lt;/h2&gt;
&lt;p&gt;A diff is only as good as the person reading it. When we review changed definitions, these are the patterns we stop at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Imperative text aimed at the model&lt;/strong&gt;: &amp;quot;always&amp;quot;, &amp;quot;before answering&amp;quot;, &amp;quot;do not mention&amp;quot;, or anything that refers to &lt;em&gt;other&lt;/em&gt; tools or servers. A description should say what the tool does, not what the agent must do elsewhere.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New free-text parameters&lt;/strong&gt; like &lt;code&gt;notes&lt;/code&gt;, &lt;code&gt;context&lt;/code&gt; or &lt;code&gt;sidenote&lt;/code&gt;, especially optional ones with permissive types. They are the easiest way to carry data out.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Changed defaults and limits&lt;/strong&gt;: a new parameter that defaults to &lt;code&gt;true&lt;/code&gt;, a page size that grows tenfold.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Annotation flips&lt;/strong&gt; from read-only to not read-only, or from closed-world to open-world.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Churn without a release note.&lt;/strong&gt; If the server&amp;#39;s maintainers can&amp;#39;t explain the change, don&amp;#39;t approve it.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-pinning-doesn-39-t-do&quot;&gt;What pinning doesn&amp;#39;t do&lt;/h2&gt;
&lt;p&gt;We&amp;#39;d rather you hear the limits from us:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;It pins what a server says, not what it does.&lt;/strong&gt; A server can change its behaviour behind an unchanged definition. Pinning doesn&amp;#39;t replace trusting the operator, least-privilege &lt;a href=&quot;https://neurouter.com/features/access-control&quot;&gt;access control&lt;/a&gt;, &lt;a href=&quot;https://neurouter.com/blog/human-approval-for-agent-tool-calls&quot;&gt;human approval&lt;/a&gt; for writes, and an audit trail.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A malicious definition can be approved.&lt;/strong&gt; Pinning makes a change visible and forces a decision; it doesn&amp;#39;t make the decision. Turning on &lt;em&gt;auto-approve new tools&lt;/em&gt; for a server skips review of new tools on it (never of changes), and &lt;em&gt;monitor&lt;/em&gt; mode skips review of changes for that server altogether. Keep both for servers you control.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It doesn&amp;#39;t stop prompt injection in tool &lt;em&gt;results&lt;/em&gt;.&lt;/strong&gt; Invariant&amp;#39;s second WhatsApp experiment needed no malicious server at all: the injection arrived in a chat message the agent read. Output-side defences are a separate problem.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It only covers servers behind the gateway.&lt;/strong&gt; Neurouter proxies remote MCP servers over Streamable HTTP and SSE; it doesn&amp;#39;t host local stdio servers yet. A server someone runs on their laptop, outside the gateway, isn&amp;#39;t pinned by anything we do. Client-side policy is how you close that gap; see our &lt;a href=&quot;https://neurouter.com/blog/mcp-gateway-guide-for-it-leaders&quot;&gt;guide for IT leaders&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;A hash isn&amp;#39;t a signature.&lt;/strong&gt; It tells you &lt;em&gt;that&lt;/em&gt; something changed, not who authored it. The tools section of the specification defines no way for a publisher to sign a definition, so the gateway can only compare against what you approved.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Review fatigue is real.&lt;/strong&gt; A server that rewrites its descriptions on every release will fill the queue. That&amp;#39;s useful information about the server, but plan for who does the reviews.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;try-it&quot;&gt;Try it&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://neurouter-demo.web.app&quot;&gt;live demo&lt;/a&gt; has the review screen above with simulated data; it runs entirely in your browser. The code is in &lt;a href=&quot;https://github.com/neurouter/neurouter/tree/master/apps/server/src/catalog&quot;&gt;&lt;code&gt;apps/server/src/catalog&lt;/code&gt;&lt;/a&gt; in the &lt;a href=&quot;https://github.com/neurouter/neurouter&quot;&gt;GitHub repository&lt;/a&gt; (Apache-2.0). For the short version of the feature, see &lt;a href=&quot;https://neurouter.com/features/tool-pinning&quot;&gt;Tool pinning&lt;/a&gt;; for how it fits with the rest of the gateway, the &lt;a href=&quot;https://neurouter.com/docs/security-model#tool-pinning&quot;&gt;security model&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Governing AI agents' tool access: what an MCP gateway is for, and how to pilot one</title>
    <link rel="alternate" type="text/html" href="https://neurouter.com/blog/mcp-gateway-guide-for-it-leaders"/>
    <id>https://neurouter.com/blog/mcp-gateway-guide-for-it-leaders</id>
    <published>2026-11-25T00:00:00Z</published>
    <updated>2026-11-25T00:00:00Z</updated>
    <author><name>Neurouter team</name><uri>https://neurouter.com/</uri></author>
    <summary>AI clients now reach company systems through MCP. A practical guide for IT and security leaders to the risks (shadow servers, credentials on laptops, no audit), the options (build, vendor admin controls, a gateway) and a two-to-four-week pilot.</summary>
    <content type="html">&lt;p&gt;A year ago, &amp;quot;the AI tool&amp;quot; in most companies was a chat window. Today Claude Code, Cursor, VS Code and ChatGPT can open pull requests, query databases, file tickets and post to Slack. They do it through the &lt;a href=&quot;https://modelcontextprotocol.io&quot;&gt;Model Context Protocol&lt;/a&gt; (MCP): an AI client connects to an MCP server, the server offers tools, and the model decides which ones to call.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s useful, and it moves a governance question onto your desk. For every agent in your organization you should be able to answer three things: &lt;strong&gt;which tools can it reach, whose credentials does it use, and what did it actually do?&lt;/strong&gt; This post is about how to answer them without banning the tools your engineers already rely on.&lt;/p&gt;
&lt;h2 id=&quot;what-changes-when-agents-call-tools&quot;&gt;What changes when agents call tools&lt;/h2&gt;
&lt;p&gt;Adding an MCP server is usually one line of client configuration. Claude Code&amp;#39;s own administrator documentation is direct about the default: &lt;a href=&quot;https://code.claude.com/docs/en/managed-mcp&quot;&gt;&amp;quot;By default, anyone running Claude Code can connect any MCP server they choose.&amp;quot;&lt;/a&gt; Unless someone configures otherwise, that leads to five problems:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Shadow MCP servers.&lt;/strong&gt; Servers nobody in IT knows about, from sources nobody reviewed. A server&amp;#39;s tool descriptions go straight into the model&amp;#39;s context, which is how &lt;a href=&quot;https://neurouter.com/blog/mcp-tool-poisoning-rug-pulls&quot;&gt;tool poisoning and rug pulls&lt;/a&gt; work.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Credentials on laptops.&lt;/strong&gt; Each server needs access to something: a GitHub token, a database password, a SaaS API key. Those end up in config files and environment variables on developer machines, often long-lived and personal, and they don&amp;#39;t leave when the person does.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No audit trail.&lt;/strong&gt; The &lt;a href=&quot;https://modelcontextprotocol.io/specification/2026-07-28/server/tools&quot;&gt;MCP specification&lt;/a&gt; says clients &lt;em&gt;should&lt;/em&gt; &amp;quot;log tool usage for audit purposes&amp;quot;. Where they do, the logs are per client and per device. Nobody can answer &amp;quot;what did agents do in the payments repository last Tuesday, and on whose behalf?&amp;quot;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Over-broad access.&lt;/strong&gt; An agent typically gets everything its human can reach through a server, even when the job needs two tools.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;No brakes on writes.&lt;/strong&gt; Clients can ask the user to confirm a call, but the person confirming is the person who started the agent, and clients let users turn confirmations off.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;what-an-mcp-gateway-is&quot;&gt;What an MCP gateway is&lt;/h2&gt;
&lt;p&gt;An MCP gateway is a server that sits between AI clients and your MCP servers. Clients connect to one endpoint; behind it, the gateway connects to the upstream servers. Every call passes through a policy point you control. In Neurouter, a tool call goes through these steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The client sends the request to &lt;code&gt;/mcp&lt;/code&gt; over Streamable HTTP.&lt;/li&gt;
&lt;li&gt;The gateway checks the caller&amp;#39;s OAuth access token or API key.&lt;/li&gt;
&lt;li&gt;It resolves the tool and applies access control. A tool the caller may not use looks exactly like a tool that doesn&amp;#39;t exist.&lt;/li&gt;
&lt;li&gt;It validates the arguments against the tool&amp;#39;s &lt;a href=&quot;https://neurouter.com/features/tool-pinning&quot;&gt;pinned&lt;/a&gt; schema.&lt;/li&gt;
&lt;li&gt;It applies rate limits per agent and per agent and tool.&lt;/li&gt;
&lt;li&gt;If the tool requires &lt;a href=&quot;https://neurouter.com/blog/human-approval-for-agent-tool-calls&quot;&gt;human approval&lt;/a&gt;, it holds the call until someone decides.&lt;/li&gt;
&lt;li&gt;It calls the upstream server with credentials the gateway holds. The client&amp;#39;s token is never forwarded; the MCP specification &lt;a href=&quot;https://modelcontextprotocol.io/specification/2025-11-25/basic/security_best_practices&quot;&gt;forbids that &amp;quot;token passthrough&amp;quot;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;It returns the result and writes the &lt;a href=&quot;https://neurouter.com/blog/tamper-evident-audit-log-for-ai-agents&quot;&gt;audit record&lt;/a&gt; and metrics.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The point isn&amp;#39;t the proxy. It&amp;#39;s that identity, credentials, policy and evidence live in one place, for every client.&lt;/p&gt;
&lt;figure class=&quot;shot&quot;&gt;&lt;a href=&quot;https://neurouter.com/screens/access-control.png&quot; title=&quot;Open full size&quot;&gt;&lt;picture&gt;&lt;source srcset=&quot;https://neurouter.com/screens/access-control-dark.png&quot; media=&quot;(prefers-color-scheme: dark)&quot;&gt;&lt;img src=&quot;https://neurouter.com/screens/access-control.png&quot; alt=&quot;Access control list showing allow and deny grants for groups, users and agents&quot; width=&quot;1440&quot; height=&quot;900&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/picture&gt;&lt;/a&gt;&lt;figcaption&gt;Grants in Neurouter (live demo, simulated data): a user, group or agent, a server or single tool, allow or deny. Deny always wins.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;three-ways-to-govern-it&quot;&gt;Three ways to govern it&lt;/h2&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table class=&quot;stack&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th scope=&quot;col&quot;&gt;&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;Build your own&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;Client admin controls&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;A gateway&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td data-label=&quot;&quot;&gt;Decides which servers a client loads&lt;/td&gt;&lt;td data-label=&quot;Build your own&quot;&gt;No&lt;/td&gt;&lt;td data-label=&quot;Client admin controls&quot;&gt;&lt;strong&gt;Yes&lt;/strong&gt;, enforced on the device&lt;/td&gt;&lt;td data-label=&quot;A gateway&quot;&gt;No (it can&amp;#39;t see clients that bypass it)&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;&quot;&gt;Covers every client product&lt;/td&gt;&lt;td data-label=&quot;Build your own&quot;&gt;Yes&lt;/td&gt;&lt;td data-label=&quot;Client admin controls&quot;&gt;No, one product at a time&lt;/td&gt;&lt;td data-label=&quot;A gateway&quot;&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;&quot;&gt;Upstream credentials off laptops&lt;/td&gt;&lt;td data-label=&quot;Build your own&quot;&gt;If you build it&lt;/td&gt;&lt;td data-label=&quot;Client admin controls&quot;&gt;No&lt;/td&gt;&lt;td data-label=&quot;A gateway&quot;&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;&quot;&gt;Per-tool access for users, groups and agents&lt;/td&gt;&lt;td data-label=&quot;Build your own&quot;&gt;If you build it&lt;/td&gt;&lt;td data-label=&quot;Client admin controls&quot;&gt;Varies by client&lt;/td&gt;&lt;td data-label=&quot;A gateway&quot;&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;&quot;&gt;Human approval of specific calls&lt;/td&gt;&lt;td data-label=&quot;Build your own&quot;&gt;If you build it&lt;/td&gt;&lt;td data-label=&quot;Client admin controls&quot;&gt;The user confirms their own calls&lt;/td&gt;&lt;td data-label=&quot;A gateway&quot;&gt;Yes, by someone else&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;&quot;&gt;Central, per-call audit trail&lt;/td&gt;&lt;td data-label=&quot;Build your own&quot;&gt;If you build it&lt;/td&gt;&lt;td data-label=&quot;Client admin controls&quot;&gt;Usage telemetry per client&lt;/td&gt;&lt;td data-label=&quot;A gateway&quot;&gt;Yes&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;&quot;&gt;Ongoing cost&lt;/td&gt;&lt;td data-label=&quot;Build your own&quot;&gt;A team, indefinitely&lt;/td&gt;&lt;td data-label=&quot;Client admin controls&quot;&gt;Low&lt;/td&gt;&lt;td data-label=&quot;A gateway&quot;&gt;Running one more service&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Client admin controls&lt;/strong&gt; are worth turning on whatever else you do. Claude Code, for example, supports a &lt;a href=&quot;https://code.claude.com/docs/en/managed-mcp#exclusive-control-with-managed-mcp-json&quot;&gt;&lt;code&gt;managed-mcp.json&lt;/code&gt;&lt;/a&gt; file deployed by MDM that fixes the set of servers users get, and &lt;code&gt;allowedMcpServers&lt;/code&gt; / &lt;code&gt;deniedMcpServers&lt;/code&gt; lists that match servers by URL or exact command. With &lt;code&gt;OTEL_LOG_TOOL_DETAILS=1&lt;/code&gt; it can export which MCP servers and tools people use. GitHub offers a private MCP registry for Copilot, which its own documentation describes as a public preview and &lt;a href=&quot;https://docs.github.com/en/copilot/how-tos/administer-copilot/manage-mcp-usage/configure-mcp-registry&quot;&gt;&amp;quot;not the recommended method for restricting access to MCP servers&amp;quot;&lt;/a&gt;. These controls decide what a client may connect to. They don&amp;#39;t hold credentials, check individual tool calls or produce one audit trail across clients, and every vendor&amp;#39;s controls are different.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Building your own&lt;/strong&gt; looks easy because the proxy part is easy. The work is in the rest: an OAuth 2.1 authorization server that MCP clients can discover (RFC 9728 and RFC 8414 metadata, audience-bound tokens per RFC 8707, client registration), per-user OAuth to upstream SaaS with the &lt;a href=&quot;https://modelcontextprotocol.io/specification/2025-11-25/basic/security_best_practices&quot;&gt;confused-deputy protections&lt;/a&gt; the spec requires, SSRF guards, two protocol versions in use at once (2025-11-25 and 2026-07-28, which removed protocol sessions), an audit log you can defend, and a review UI. If you have a platform team that wants to own that indefinitely, it&amp;#39;s a legitimate choice.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;A gateway&lt;/strong&gt; gives you those pieces off the shelf. There are several, open source and commercial; we keep a &lt;a href=&quot;https://neurouter.com/compare&quot;&gt;sourced comparison&lt;/a&gt; that includes where others are stronger than Neurouter.&lt;/p&gt;
&lt;h3 id=&quot;use-them-together&quot;&gt;Use them together&lt;/h3&gt;
&lt;p&gt;The two kinds of control fit together well. Use client policy to make the gateway the only server a client loads, and let the gateway decide everything behind it. For Claude Code, that&amp;#39;s a &lt;code&gt;managed-mcp.json&lt;/code&gt; with one entry, deployed to &lt;code&gt;/Library/Application Support/ClaudeCode/&lt;/code&gt; on macOS, &lt;code&gt;/etc/claude-code/&lt;/code&gt; on Linux or &lt;code&gt;C:\Program Files\ClaudeCode\&lt;/code&gt; on Windows:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &amp;quot;mcpServers&amp;quot;: {
    &amp;quot;neurouter&amp;quot;: { &amp;quot;type&amp;quot;: &amp;quot;http&amp;quot;, &amp;quot;url&amp;quot;: &amp;quot;https://mcp.example.com/mcp&amp;quot; }
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;People then authenticate once from Claude Code&amp;#39;s &lt;code&gt;/mcp&lt;/code&gt; menu, which opens your identity provider&amp;#39;s sign-in through Neurouter. No credential is in the file. Note the trade-off: exclusive control also blocks local stdio servers, which Neurouter can&amp;#39;t host yet. If your teams depend on some, allowlist those exact commands instead of deploying exclusive control.&lt;/p&gt;
&lt;h2 id=&quot;how-to-run-a-pilot&quot;&gt;How to run a pilot&lt;/h2&gt;
&lt;p&gt;A pilot should take two to four weeks and answer a specific question, not demonstrate that a proxy works.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. Choose the scope.&lt;/strong&gt; Two or three remote MCP servers with clear owners: one read-mostly (internal docs search), one that writes (your Git host or ticketing system). Five to twenty people who already use AI clients, plus one CI job.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. Evaluate locally first.&lt;/strong&gt; The &lt;a href=&quot;https://neurouter.com/docs/quickstart&quot;&gt;quickstart&lt;/a&gt; runs Neurouter on one machine with SQLite or Docker Compose and a development-only login. Half a day is enough to see the console and connect a client.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;3. Deploy the pilot properly.&lt;/strong&gt; Use the Helm chart or a container with PostgreSQL, an &lt;code&gt;https&lt;/code&gt; URL, your OIDC provider (&lt;a href=&quot;https://neurouter.com/integrations/entra-id&quot;&gt;Entra ID&lt;/a&gt;, &lt;a href=&quot;https://neurouter.com/integrations/okta&quot;&gt;Okta&lt;/a&gt;, &lt;a href=&quot;https://neurouter.com/integrations/google-workspace&quot;&gt;Google Workspace&lt;/a&gt; or &lt;a href=&quot;https://neurouter.com/integrations/keycloak&quot;&gt;Keycloak&lt;/a&gt;) and three generated secrets. Map an IdP group to the Admin and Auditor roles. See &lt;a href=&quot;https://neurouter.com/docs/deployment&quot;&gt;Deployment&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;4. Set policy before inviting anyone.&lt;/strong&gt; Register the servers and review their tools; a new tool isn&amp;#39;t callable until it&amp;#39;s approved (unless you turn on auto-approve for that server). Grant tools to the pilot group (there is no access without a grant, including for admins). Flag the write tools as &lt;em&gt;requires approval&lt;/em&gt;. Give the CI job its own agent with an API key, narrowed to the two tools it needs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;5. Send the evidence somewhere else.&lt;/strong&gt; Configure the audit webhook or OpenTelemetry logs export to your SIEM, and set retention to what your policy requires.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;6. Measure.&lt;/strong&gt; At the end, look at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Blocked calls&lt;/strong&gt; (&lt;code&gt;neurouter_tool_calls_total&lt;/code&gt; by decision): denials point at missing grants or at agents reaching for things they shouldn&amp;#39;t.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Approval wait times and outcomes&lt;/strong&gt; (&lt;code&gt;neurouter_approval_wait_seconds&lt;/code&gt;): if people wait minutes for routine calls, you flagged too much.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Definition changes&lt;/strong&gt; your servers made during the pilot, and how long reviews took.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tools nobody used&lt;/strong&gt;: candidates to stop granting.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The question you started with&lt;/strong&gt;: pick a day and an agent, and time how long it takes to say what it did and on whose behalf.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-a-gateway-doesn-39-t-solve&quot;&gt;What a gateway doesn&amp;#39;t solve&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;It sees &lt;strong&gt;tool calls&lt;/strong&gt;, not the conversation. Prompts and answers that never become a tool call aren&amp;#39;t logged.&lt;/li&gt;
&lt;li&gt;It only governs traffic that goes through it. Client policy, network egress rules and credential hygiene still matter.&lt;/li&gt;
&lt;li&gt;Specific to Neurouter today (v0.1.1): it proxies remote servers (Streamable HTTP and SSE) but &lt;strong&gt;doesn&amp;#39;t host stdio servers&lt;/strong&gt; yet; it supports &lt;strong&gt;tools only&lt;/strong&gt;, not MCP resources or prompts; clients see two meta-tools (&lt;code&gt;search_tools&lt;/code&gt; and &lt;code&gt;call_tool&lt;/code&gt;) instead of the full tool list; there&amp;#39;s no SCIM or SAML yet; one deployment serves one organization; and the managed Neurouter Cloud isn&amp;#39;t available. It&amp;#39;s a new project from a small company, which matters for your vendor assessment.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;try-it&quot;&gt;Try it&lt;/h2&gt;
&lt;p&gt;Click through a simulated company in the &lt;a href=&quot;https://neurouter-demo.web.app&quot;&gt;live demo&lt;/a&gt;, which runs entirely in your browser, or read the code on &lt;a href=&quot;https://github.com/neurouter/neurouter&quot;&gt;GitHub&lt;/a&gt;. Everything described here is in the Apache-2.0 edition; there&amp;#39;s no paid tier for SSO, access control or audit. To go deeper: &lt;a href=&quot;https://neurouter.com/features/access-control&quot;&gt;access control&lt;/a&gt;, the &lt;a href=&quot;https://neurouter.com/docs/security-model&quot;&gt;security model&lt;/a&gt; and the &lt;a href=&quot;https://neurouter.com/compliance&quot;&gt;compliance mapping&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>Human-in-the-loop for agent tool calls: designing approvals people will actually use</title>
    <link rel="alternate" type="text/html" href="https://neurouter.com/blog/human-approval-for-agent-tool-calls"/>
    <id>https://neurouter.com/blog/human-approval-for-agent-tool-calls</id>
    <published>2026-11-25T00:00:00Z</published>
    <updated>2026-11-25T00:00:00Z</updated>
    <author><name>Neurouter team</name><uri>https://neurouter.com/</uri></author>
    <summary>What to hold for approval, who may approve, what the reviewer and the agent see, how long to wait, how a live review page stays correct across replicas, and how every decision is audited. Design notes from Neurouter's MCP gateway.</summary>
    <content type="html">&lt;p&gt;The MCP specification is clear about intent: &lt;a href=&quot;https://modelcontextprotocol.io/specification/2026-07-28/server/tools&quot;&gt;&amp;quot;there SHOULD always be a human in the loop with the ability to deny tool invocations&amp;quot;&lt;/a&gt;. Clients implement this as a confirmation prompt, shown to the person who started the agent. That&amp;#39;s consent, and it&amp;#39;s useful. It isn&amp;#39;t oversight: the person approving is the person who wants the result, the prompt arrives in the middle of their flow, and they can turn it off.&lt;/p&gt;
&lt;p&gt;For a small set of actions, organizations want something else: a different person, with the authority to say no, looking at the exact call before it runs. That&amp;#39;s what approvals in Neurouter are for. This post walks through the design decisions, including the ones we&amp;#39;re not finished with.&lt;/p&gt;
&lt;h2 id=&quot;1-what-to-hold&quot;&gt;1. What to hold&lt;/h2&gt;
&lt;p&gt;Approval is expensive: it costs a person&amp;#39;s attention and stalls an agent. Hold as few tools as you can, and choose them by consequence and reversibility, not by how dangerous they sound.&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table class=&quot;stack&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th scope=&quot;col&quot;&gt;Good candidates&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;Usually not worth holding&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td data-label=&quot;Good candidates&quot;&gt;Merging or deploying to production&lt;/td&gt;&lt;td data-label=&quot;Usually not worth holding&quot;&gt;Reading code, docs or tickets&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Good candidates&quot;&gt;Writing to production databases&lt;/td&gt;&lt;td data-label=&quot;Usually not worth holding&quot;&gt;Queries against analytics replicas&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Good candidates&quot;&gt;Sending email or messages to people outside the team&lt;/td&gt;&lt;td data-label=&quot;Usually not worth holding&quot;&gt;Posting to the agent&amp;#39;s own scratch channel&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Good candidates&quot;&gt;Changing permissions, users or secrets&lt;/td&gt;&lt;td data-label=&quot;Usually not worth holding&quot;&gt;Creating a draft that a person reviews anyway&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Good candidates&quot;&gt;Moving money; bulk exports of personal data&lt;/td&gt;&lt;td data-label=&quot;Usually not worth holding&quot;&gt;Anything an agent calls dozens of times an hour&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;In Neurouter an admin, or the owner of the server, flags a tool as &lt;strong&gt;requires approval&lt;/strong&gt;. We deliberately don&amp;#39;t infer this from the tool&amp;#39;s own annotations, such as &lt;code&gt;destructiveHint&lt;/code&gt;: the specification says clients &amp;quot;MUST consider tool annotations to be untrusted unless they come from trusted servers&amp;quot;, and a server that wants to avoid review would simply not set them.&lt;/p&gt;
&lt;p&gt;The hold happens &lt;strong&gt;after&lt;/strong&gt; access control, argument validation against the &lt;a href=&quot;https://neurouter.com/blog/mcp-tool-poisoning-rug-pulls&quot;&gt;pinned schema&lt;/a&gt; and rate limits. A reviewer never sees a call that would have been refused anyway.&lt;/p&gt;
&lt;h2 id=&quot;2-who-may-approve&quot;&gt;2. Who may approve&lt;/h2&gt;
&lt;p&gt;Admins and the owners of the tool&amp;#39;s server. Auditors can see approvals but not decide. By default, the user an agent acts for &lt;strong&gt;cannot&lt;/strong&gt; approve calls made by their own agents, including a CI agent they own; an admin can change that with &lt;em&gt;Allow self-approval&lt;/em&gt; in the gateway settings.&lt;/p&gt;
&lt;p&gt;A decision is a single atomic update: it succeeds only if the approval is still pending and hasn&amp;#39;t expired. A second reviewer clicking a moment later gets &lt;code&gt;409&lt;/code&gt; (&amp;quot;already approved&amp;quot;); a reviewer clicking after expiry gets &lt;code&gt;410&lt;/code&gt;. Denying requires a reason.&lt;/p&gt;
&lt;h2 id=&quot;3-what-the-reviewer-sees&quot;&gt;3. What the reviewer sees&lt;/h2&gt;
&lt;figure class=&quot;shot&quot;&gt;&lt;a href=&quot;https://neurouter.com/screens/approvals.png&quot; title=&quot;Open full size&quot;&gt;&lt;picture&gt;&lt;source srcset=&quot;https://neurouter.com/screens/approvals-dark.png&quot; media=&quot;(prefers-color-scheme: dark)&quot;&gt;&lt;img src=&quot;https://neurouter.com/screens/approvals.png&quot; alt=&quot;Approvals queue with pending tool calls, redacted input and countdowns&quot; width=&quot;1440&quot; height=&quot;900&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/picture&gt;&lt;/a&gt;&lt;figcaption&gt;The approvals page (live demo, simulated data): tool, agent, the user it acts for, the client or API key, the redacted input and the time left. A connection string is hidden by a redaction rule.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;Each held call shows the agent, the user it acts for, the client and version or the API key, the qualified tool name, the arguments, and a countdown. Two choices here are worth explaining:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Arguments are redacted with the audit log&amp;#39;s rules&lt;/strong&gt; before they&amp;#39;re stored or shown. The reviewer sees what the &lt;a href=&quot;https://neurouter.com/blog/tamper-evident-audit-log-for-ai-agents&quot;&gt;audit log&lt;/a&gt; will contain, never a raw secret. The trade-off: if a rule hides a value the reviewer needed, they have to deny and ask.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The arguments are frozen.&lt;/strong&gt; When a call is held, Neurouter stores the redacted arguments for display and a SHA-256 hash of the full arguments. On approval, the gateway executes the arguments it has been holding in memory for that request. Nothing can be swapped in between the review and the execution.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;4-how-long-to-wait&quot;&gt;4. How long to wait&lt;/h2&gt;
&lt;p&gt;The default timeout is &lt;strong&gt;5 minutes&lt;/strong&gt;, the maximum is &lt;strong&gt;15&lt;/strong&gt;, and a tool can override the default within that maximum. Holding a call means holding an HTTP request open while an agent session waits, and a decision made an hour later is a decision about a stale context. If an action genuinely needs a next-day sign-off, a held tool call is the wrong shape; make the agent create a request in the system where approvals already live.&lt;/p&gt;
&lt;p&gt;Clients have their own timeouts. The &lt;a href=&quot;https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle#timeouts&quot;&gt;MCP lifecycle&lt;/a&gt; says implementations &amp;quot;MAY choose to reset the timeout clock when receiving a progress notification&amp;quot;, while still enforcing a maximum. So if the client sends a &lt;code&gt;progressToken&lt;/code&gt;, Neurouter sends a &lt;a href=&quot;https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/progress&quot;&gt;progress notification&lt;/a&gt; every 10 seconds while the call is held:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &amp;quot;method&amp;quot;: &amp;quot;notifications/progress&amp;quot;,
  &amp;quot;params&amp;quot;: {
    &amp;quot;progressToken&amp;quot;: &amp;quot;call-17&amp;quot;,
    &amp;quot;progress&amp;quot;: 40,
    &amp;quot;total&amp;quot;: 300,
    &amp;quot;message&amp;quot;: &amp;quot;Waiting for human approval (id 01a2…); times out in 5m&amp;quot;
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the client gives up anyway, the cancellation reaches the gateway, the approval is marked &lt;em&gt;cancelled&lt;/em&gt;, and nothing runs.&lt;/p&gt;
&lt;h2 id=&quot;5-what-the-agent-sees&quot;&gt;5. What the agent sees&lt;/h2&gt;
&lt;p&gt;The agent learns about approvals early: &lt;code&gt;search_tools&lt;/code&gt; marks such tools &amp;quot;(requires approval)&amp;quot;, so a well-behaved agent can tell its user before it calls one. When the hold ends without approval, the agent gets a tool error result (&lt;code&gt;isError: true&lt;/code&gt;), which the specification says clients should pass to the model &amp;quot;to enable self-correction&amp;quot;:&lt;/p&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table class=&quot;stack&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th scope=&quot;col&quot;&gt;Outcome&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;Result text&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td data-label=&quot;Outcome&quot;&gt;Denied&lt;/td&gt;&lt;td data-label=&quot;Result text&quot;&gt;&lt;code&gt;Denied by Marco Ruiz: use the staging replica for this query&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Outcome&quot;&gt;Timed out&lt;/td&gt;&lt;td data-label=&quot;Result text&quot;&gt;&lt;code&gt;Approval timed out after 5m; nobody approved the call to postgres-analytics__run_query&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Outcome&quot;&gt;Cancelled&lt;/td&gt;&lt;td data-label=&quot;Result text&quot;&gt;&lt;code&gt;The client cancelled the request while it was waiting for approval&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;The denial reason goes back to the model. Write it for the model: &amp;quot;use the staging replica&amp;quot; lets the agent recover; &amp;quot;no&amp;quot; makes it guess.&lt;/p&gt;
&lt;h2 id=&quot;6-a-live-review-page-that-stays-correct&quot;&gt;6. A live review page that stays correct&lt;/h2&gt;
&lt;p&gt;The approvals page is fed by server-sent events from &lt;code&gt;GET /api/approvals/stream&lt;/code&gt;, with three event types: &lt;code&gt;approval.created&lt;/code&gt;, &lt;code&gt;approval.resolved&lt;/code&gt; and &lt;code&gt;approval.expired&lt;/code&gt;. A few details make it reliable rather than just live:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Each event&amp;#39;s id is &lt;code&gt;&amp;lt;updatedAtMs&amp;gt;:&amp;lt;approvalId&amp;gt;&lt;/code&gt;. When the browser reconnects, it sends &lt;code&gt;Last-Event-ID&lt;/code&gt; and the server replays every change the viewer is allowed to see since then, so a dropped connection doesn&amp;#39;t lose an approval.&lt;/li&gt;
&lt;li&gt;A keep-alive comment every 15 seconds survives load balancers with 60-second idle timeouts, and the response sets &lt;code&gt;X-Accel-Buffering: no&lt;/code&gt;. Your ingress still needs buffering off and long read timeouts; the Helm chart&amp;#39;s NGINX annotations do both.&lt;/li&gt;
&lt;li&gt;Each replica keeps one subscription and filters per viewer: owners see their servers&amp;#39; approvals, people see their own agents&amp;#39; calls, admins and auditors see everything.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Behind the page, a held call can be decided on any replica. The holding replica waits for a signal on a per-approval channel, with a database poll every two seconds as the correctness fallback, and heart-beats the row every 15 seconds. If a replica dies, a janitor marks its held approvals &lt;em&gt;abandoned&lt;/em&gt; after 60 seconds without a heartbeat, and nothing runs. During rolling updates, the Helm chart sets the pod&amp;#39;s termination grace period to the maximum approval timeout plus 30 seconds.&lt;/p&gt;
&lt;h2 id=&quot;7-every-decision-is-evidence&quot;&gt;7. Every decision is evidence&lt;/h2&gt;
&lt;p&gt;One approved call produces three audit records:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;the &lt;code&gt;tool_call&lt;/code&gt; row with decision &lt;code&gt;approval_pending&lt;/code&gt;, written when the hold starts;&lt;/li&gt;
&lt;li&gt;the reviewer&amp;#39;s decision (&lt;code&gt;approval.approve&lt;/code&gt; or &lt;code&gt;approval.deny&lt;/code&gt;, with the note or reason, their IP and user agent);&lt;/li&gt;
&lt;li&gt;the final &lt;code&gt;tool_call&lt;/code&gt; row with decision &lt;code&gt;approved&lt;/code&gt;, &lt;code&gt;approval_denied&lt;/code&gt;, &lt;code&gt;approval_timeout&lt;/code&gt; or &lt;code&gt;approval_cancelled&lt;/code&gt;, and the call&amp;#39;s outcome.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The two &lt;code&gt;tool_call&lt;/code&gt; rows share the call&amp;#39;s request and trace IDs, the decision row names the approval (which records the same request ID), and all three sit in the same hash-chained log. Prometheus gets &lt;code&gt;neurouter_approvals_pending&lt;/code&gt; and &lt;code&gt;neurouter_approval_wait_seconds&lt;/code&gt; by outcome, which tells you whether approvals are slowing people down.&lt;/p&gt;
&lt;h2 id=&quot;what-we-haven-39-t-solved&quot;&gt;What we haven&amp;#39;t solved&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No notifications yet.&lt;/strong&gt; In v0.1.1 there are no email, Slack or push notifications for new approvals; reviewers see them on the live page and as a badge in the console. Until that changes, alert on the gauge with Alertmanager:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;- alert: NeurouterApprovalWaiting
  expr: max(neurouter_approvals_pending) &amp;gt; 0
  for: 30s&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Synchronous only.&lt;/strong&gt; Fifteen minutes is the ceiling. There&amp;#39;s no queue that survives the agent&amp;#39;s session.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Per tool, not per argument.&lt;/strong&gt; You can&amp;#39;t yet say &amp;quot;hold &lt;code&gt;run_query&lt;/code&gt; only when it touches the &lt;code&gt;payments&lt;/code&gt; schema&amp;quot;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rubber-stamping.&lt;/strong&gt; A reviewer who approves everything adds latency, not safety. Watch the approve/deny ratio and the wait times, and remove holds that never get denied.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reviewers see the call, not the conversation.&lt;/strong&gt; They judge the action on its arguments and the agent&amp;#39;s identity, not on the prompt that led to it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;try-it&quot;&gt;Try it&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://neurouter-demo.web.app&quot;&gt;live demo&lt;/a&gt; simulates held calls arriving and timing out in your browser. The implementation is in &lt;a href=&quot;https://github.com/neurouter/neurouter/tree/master/apps/server/src/policy/approvals&quot;&gt;&lt;code&gt;apps/server/src/policy/approvals&lt;/code&gt;&lt;/a&gt; in the &lt;a href=&quot;https://github.com/neurouter/neurouter&quot;&gt;GitHub repository&lt;/a&gt;. Setup details are in the &lt;a href=&quot;https://neurouter.com/docs/approvals&quot;&gt;approvals documentation&lt;/a&gt;, and the feature summary is at &lt;a href=&quot;https://neurouter.com/features/approvals&quot;&gt;Human approvals&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
  <entry>
    <title>A tamper-evident audit log for AI agent actions: hash chains, checkpoints and their limits</title>
    <link rel="alternate" type="text/html" href="https://neurouter.com/blog/tamper-evident-audit-log-for-ai-agents"/>
    <id>https://neurouter.com/blog/tamper-evident-audit-log-for-ai-agents</id>
    <published>2026-11-25T00:00:00Z</published>
    <updated>2026-11-25T00:00:00Z</updated>
    <author><name>Neurouter team</name><uri>https://neurouter.com/</uri></author>
    <summary>How Neurouter records every MCP tool call in a hash-chained log with HMAC checkpoints, how to verify it with 40 lines of code you control, what redaction and retention do, what an attacker with database access can still do, and how it relates to EU AI Act, ISO 27001 and SOC 2 logging.</summary>
    <content type="html">&lt;p&gt;When an AI agent changes something in your systems, you&amp;#39;ll be asked three questions: what happened, on whose behalf, and how do you know the record is complete and unaltered? Ordinary application logs answer the first two. The third needs design, because the people who can change a database include the people whose actions you may need to examine.&lt;/p&gt;
&lt;p&gt;Neurouter&amp;#39;s audit log is built to make tampering &lt;strong&gt;detectable&lt;/strong&gt;, to get the evidence out of the database it protects, and to be explicit about what it can&amp;#39;t prove. We say &lt;em&gt;tamper-evident&lt;/em&gt;, never &lt;em&gt;tamper-proof&lt;/em&gt;. This post explains the construction, shows how to check it without our code, and maps it, carefully, to the logging expectations in the EU AI Act, ISO/IEC 27001 and SOC 2.&lt;/p&gt;
&lt;h2 id=&quot;what-one-record-contains&quot;&gt;What one record contains&lt;/h2&gt;
&lt;p&gt;Every tool call through the gateway produces one row: time, user, agent, OAuth client or API key, client name and version, protocol version, server and tool, the decision (allowed; denied with a reason; approval pending, approved, denied or timed out), the input parameters after redaction, output size and hash, status, latency, error, trace ID and session. Tool searches, admin and configuration changes, sign-ins and verification runs are recorded in the same log.&lt;/p&gt;
&lt;figure class=&quot;shot&quot;&gt;&lt;a href=&quot;https://neurouter.com/screens/audit-log.png&quot; title=&quot;Open full size&quot;&gt;&lt;picture&gt;&lt;source srcset=&quot;https://neurouter.com/screens/audit-log-dark.png&quot; media=&quot;(prefers-color-scheme: dark)&quot;&gt;&lt;img src=&quot;https://neurouter.com/screens/audit-log.png&quot; alt=&quot;Audit event detail with redacted input parameters, output hash and hash-chain fields&quot; width=&quot;1440&quot; height=&quot;900&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/picture&gt;&lt;/a&gt;&lt;figcaption&gt;An audit event in the live demo (simulated data): who, which agent and client, the decision, the redacted input, the output size and hash, and the row's place in the hash chain.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h2 id=&quot;redaction-happens-before-hashing&quot;&gt;Redaction happens before hashing&lt;/h2&gt;
&lt;p&gt;Tool arguments contain secrets surprisingly often. Neurouter applies redaction rules &lt;strong&gt;before&lt;/strong&gt; a row is stored or hashed, so the chain covers exactly what&amp;#39;s stored, and a redacted value can&amp;#39;t be found by search later. The built-in rules match sensitive key names (&lt;code&gt;password&lt;/code&gt;, &lt;code&gt;token&lt;/code&gt;, &lt;code&gt;api_key&lt;/code&gt;, &lt;code&gt;authorization&lt;/code&gt;, &lt;code&gt;cookie&lt;/code&gt;, &lt;code&gt;session&lt;/code&gt;, &lt;code&gt;iban&lt;/code&gt; and similar) and value patterns: JWTs, &lt;code&gt;Bearer&lt;/code&gt; headers, PEM blocks, AWS access key IDs, GitHub and Slack tokens, Neurouter&amp;#39;s own &lt;code&gt;nr_&lt;/code&gt; tokens, and card numbers that pass a Luhn check. An e-mail rule exists but is off by default. A matched key becomes &lt;code&gt;{&amp;quot;$redacted&amp;quot;: &amp;quot;&amp;lt;rule&amp;gt;&amp;quot;}&lt;/code&gt;; a partial match inside a string becomes &lt;code&gt;[REDACTED:&amp;lt;rule&amp;gt;]&lt;/code&gt;. Admins can add their own rules.&lt;/p&gt;
&lt;p&gt;Outputs are stored as their size and a SHA-256 hash of the canonical JSON by default, so you can later prove that a given output was the one returned without keeping it. Storing full outputs (redacted, up to 64 KiB per call by default) is an opt-in setting.&lt;/p&gt;
&lt;p&gt;Pattern-based redaction has two failure modes, and you&amp;#39;ll meet both. It misses secrets in shapes it doesn&amp;#39;t know, such as a password passed in a field called &lt;code&gt;q&lt;/code&gt;. And it over-matches: in our own test run, a settings change was recorded with &lt;code&gt;&amp;quot;sessions&amp;quot;: {&amp;quot;$redacted&amp;quot;: &amp;quot;sensitive-key&amp;quot;}&lt;/code&gt; because the key name contains &lt;code&gt;session&lt;/code&gt;. Review the rules against the tools you actually expose.&lt;/p&gt;
&lt;h2 id=&quot;the-chain&quot;&gt;The chain&lt;/h2&gt;
&lt;p&gt;Rows get a contiguous sequence number and are linked by hash:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;genesis_prev = sha256(&amp;quot;neurouter-audit-genesis:&amp;quot; + install_id)
entry_body   = JCS({ seq, id, ts, kind, …, session_id, ip, user_agent })   # 36 fields, nulls explicit
hash(n)      = sha256( bytes(prev_hash) ‖ 0x1E ‖ utf8(entry_body) )&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;JCS is &lt;a href=&quot;https://www.rfc-editor.org/rfc/rfc8785&quot;&gt;RFC 8785&lt;/a&gt; canonical JSON, so the hash doesn&amp;#39;t depend on key order or on how a database returns JSON. There&amp;#39;s one chain per deployment, across all replicas: events are queued in memory and written in batches (every 200 ms or 200 events) under a PostgreSQL advisory lock, or a write transaction on SQLite, which assigns &lt;code&gt;seq&lt;/code&gt; and computes the hashes.&lt;/p&gt;
&lt;p&gt;Changing a field in any row changes its hash, which breaks the link from the next row. Deleting a row leaves a gap in &lt;code&gt;seq&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;checkpoints&quot;&gt;Checkpoints&lt;/h2&gt;
&lt;p&gt;A chain alone doesn&amp;#39;t stop someone with database write access: they can edit a row and recompute every hash after it. So Neurouter periodically writes a &lt;strong&gt;checkpoint&lt;/strong&gt; that seals the current head:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;mac_key    = HKDF-SHA256(KEK, salt = &amp;quot;&amp;quot;, info = &amp;quot;neurouter:audit-checkpoint-mac&amp;quot;)
checkpoint = { seq, hash, kind, key_id, mac = HMAC-SHA256(mac_key, &amp;quot;ckpt|seq|hash|kind&amp;quot;) }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The KEK is one of your key-encryption keys (&lt;code&gt;NEUROUTER_MASTER_KEYS&lt;/code&gt;), which never live in the database. A checkpoint is written once 10,000 rows or 5 minutes have passed since the last one (checked every minute), before every key rotation and before every retention cut. Without the KEK, a forger can recompute hashes but not MACs, so a rewritten history stops matching at the next checkpoint.&lt;/p&gt;
&lt;p&gt;&amp;quot;Signed checkpoint&amp;quot; means an HMAC, a symmetric MAC, not a public-key signature. Verifying one requires the same key material that creates it, so you can&amp;#39;t hand a checkpoint to an outside party and have them verify it without trusting them with a secret derived from your KEK. Keep retired KEKs configured for as long as you want to verify the checkpoints they sealed.&lt;/p&gt;
&lt;h2 id=&quot;verifying-it&quot;&gt;Verifying it&lt;/h2&gt;
&lt;p&gt;In the console, &lt;em&gt;Audit log → Verify integrity&lt;/em&gt; recomputes the chain over the retained log and checks every checkpoint. Through the API, an Auditor or Admin starts a job:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-http&quot;&gt;POST /api/audit/verify
Content-Type: application/json

{ &amp;quot;from&amp;quot;: &amp;quot;2026-11-01T00:00:00Z&amp;quot;, &amp;quot;to&amp;quot;: &amp;quot;2026-11-25T00:00:00Z&amp;quot; }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Both fields are optional; without them the whole retained log is checked. The response is &lt;code&gt;202 {&amp;quot;jobId&amp;quot;: &amp;quot;…&amp;quot;}&lt;/code&gt;; poll &lt;code&gt;GET /api/jobs/:id&lt;/code&gt;. To test it, we edited the &lt;code&gt;action&lt;/code&gt; column of one row directly in a local SQLite database and ran it again:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;{ &amp;quot;ok&amp;quot;: false, &amp;quot;checked&amp;quot;: 2, &amp;quot;firstSeq&amp;quot;: 1, &amp;quot;lastSeq&amp;quot;: 8, &amp;quot;checkpointsVerified&amp;quot;: 0,
  &amp;quot;brokenAt&amp;quot;: { &amp;quot;seq&amp;quot;: 3, &amp;quot;reason&amp;quot;: &amp;quot;hash_mismatch&amp;quot;,
                &amp;quot;expected&amp;quot;: &amp;quot;0508a0fa…5182&amp;quot;, &amp;quot;actual&amp;quot;: &amp;quot;1cffc100…7835&amp;quot; } }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;reason&lt;/code&gt; is one of &lt;code&gt;hash_mismatch&lt;/code&gt;, &lt;code&gt;broken_link&lt;/code&gt;, &lt;code&gt;gap&lt;/code&gt;, &lt;code&gt;bad_checkpoint_mac&lt;/code&gt; or &lt;code&gt;checkpoint_mismatch&lt;/code&gt;. Each verification run is itself written to the log.&lt;/p&gt;
&lt;figure class=&quot;shot&quot;&gt;&lt;a href=&quot;https://neurouter.com/screens/audit-verify.png&quot; title=&quot;Open full size&quot;&gt;&lt;picture&gt;&lt;source srcset=&quot;https://neurouter.com/screens/audit-verify-dark.png&quot; media=&quot;(prefers-color-scheme: dark)&quot;&gt;&lt;img src=&quot;https://neurouter.com/screens/audit-verify.png&quot; alt=&quot;Audit chain verification dialog reporting every entry verified&quot; width=&quot;1440&quot; height=&quot;900&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot;&gt;&lt;/picture&gt;&lt;/a&gt;&lt;figcaption&gt;The Verify dialog in the live demo. The entry count and duration come from simulated data and are not a benchmark.&lt;/figcaption&gt;&lt;/figure&gt;
&lt;h3 id=&quot;offline-with-your-own-code&quot;&gt;Offline, with your own code&lt;/h3&gt;
&lt;p&gt;You shouldn&amp;#39;t have to trust our verifier to trust our log. The NDJSON export (&lt;em&gt;Export&lt;/em&gt; in the console, or &lt;code&gt;GET /api/audit/export?format=json&amp;amp;from=…&amp;amp;to=…&lt;/code&gt;, up to 31 days per request) and the audit webhook carry every chained field plus &lt;code&gt;prev_hash&lt;/code&gt; and &lt;code&gt;hash&lt;/code&gt;; the webhook also sends checkpoints as &lt;code&gt;{&amp;quot;type&amp;quot;:&amp;quot;checkpoint&amp;quot;, …}&lt;/code&gt; lines. This script uses only Node.js built-ins and shares no code with Neurouter:&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;// node verify-audit.mjs export.ndjson [KEK_BASE64]
import { createHash, createHmac, hkdfSync } from 'node:crypto';
import { readFileSync } from 'node:fs';

const FIELDS = ['seq', 'id', 'ts', 'kind', 'request_id', 'user_id', 'agent_id', 'api_key_id',
  'oauth_client_id', 'client_name', 'client_version', 'protocol_version', 'client_era', 'server_id',
  'tool_id', 'tool_name', 'action', 'target_type', 'target_id', 'decision', 'decision_reason',
  'status', 'params_redacted', 'changes', 'output_size', 'output_hash', 'output_full', 'latency_ms',
  'upstream_latency_ms', 'error_code', 'error_message', 'trace_id', 'span_id', 'session_id', 'ip',
  'user_agent'];

// RFC 8785 for the values Neurouter stores (strings, integers, booleans, null, objects, arrays)
const jcs = (v) =&amp;gt; v === null || typeof v !== 'object' ? JSON.stringify(v)
  : Array.isArray(v) ? `[${v.map(jcs).join(',')}]`
  : `{${Object.keys(v).sort().map((k) =&amp;gt; `${JSON.stringify(k)}:${jcs(v[k])}`).join(',')}}`;

const rowHash = (r) =&amp;gt; {
  const entry = Object.fromEntries(FIELDS.map((f) =&amp;gt; [f, f === 'ts' ? r.ts_ms : (r[f] ?? null)]));
  return createHash('sha256').update(Buffer.from(r.prev_hash, 'hex'))
    .update(Buffer.from([0x1e])).update(jcs(entry), 'utf8').digest('hex');
};

const lines = readFileSync(process.argv[2], 'utf8').split('\n').filter(Boolean).map((l) =&amp;gt; JSON.parse(l));
const rows = lines.filter((x) =&amp;gt; x.type !== 'checkpoint').sort((a, b) =&amp;gt; a.seq - b.seq);
const checkpoints = lines.filter((x) =&amp;gt; x.type === 'checkpoint');
const bySeq = new Map(rows.map((r) =&amp;gt; [r.seq, r]));

for (const [i, r] of rows.entries()) {
  const prev = rows[i - 1];
  if (prev &amp;amp;&amp;amp; r.seq !== prev.seq + 1) throw new Error(`gap before seq ${r.seq}`);
  if (prev &amp;amp;&amp;amp; r.prev_hash !== prev.hash) throw new Error(`broken link at seq ${r.seq}`);
  if (rowHash(r) !== r.hash) throw new Error(`hash mismatch at seq ${r.seq}`);
}

const kek = process.argv[3] &amp;amp;&amp;amp; Buffer.from(process.argv[3], 'base64');
const macKey = kek &amp;amp;&amp;amp; Buffer.from(hkdfSync('sha256', kek, Buffer.alloc(0), 'neurouter:audit-checkpoint-mac', 32));
for (const c of checkpoints) {
  const r = bySeq.get(c.seq);
  if (r &amp;amp;&amp;amp; r.hash !== c.hash) throw new Error(`checkpoint ${c.seq} does not match the row hash`);
  if (macKey &amp;amp;&amp;amp; createHmac('sha256', macKey).update(`ckpt|${c.seq}|${c.hash}|${c.kind}`).digest('hex') !== c.mac)
    throw new Error(`bad MAC on checkpoint ${c.seq}`);
}
console.log(`ok: ${rows.length} rows (seq ${rows[0]?.seq}–${rows.at(-1)?.seq}), ${checkpoints.length} checkpoints`);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We ran it against exports from Neurouter 0.1.1: it accepted an untouched export and a checkpoint with the right KEK, and rejected a copy with one field changed (&lt;code&gt;hash mismatch at seq 3&lt;/code&gt;) and the checkpoint under a wrong key (&lt;code&gt;bad MAC on checkpoint 5&lt;/code&gt;). Two caveats: the export doesn&amp;#39;t include the install ID, so this checks the continuity of the range you exported rather than the link back to genesis; and the shortcut JCS above is correct for the values Neurouter stores, not for arbitrary floating-point JSON. A packaged verifier is on our list; this script is the specification in the meantime.&lt;/p&gt;
&lt;h2 id=&quot;the-threat-model&quot;&gt;The threat model&lt;/h2&gt;
&lt;div class=&quot;table-wrap&quot;&gt;&lt;table class=&quot;stack&quot;&gt;&lt;thead&gt;&lt;tr&gt;&lt;th scope=&quot;col&quot;&gt;Someone…&lt;/th&gt;&lt;th scope=&quot;col&quot;&gt;Detected?&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td data-label=&quot;Someone…&quot;&gt;edits a row in the database&lt;/td&gt;&lt;td data-label=&quot;Detected?&quot;&gt;Yes: &lt;code&gt;hash_mismatch&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Someone…&quot;&gt;edits a row and recomputes every later hash&lt;/td&gt;&lt;td data-label=&quot;Detected?&quot;&gt;Yes, at the next checkpoint, unless they also hold your KEK&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Someone…&quot;&gt;deletes rows in the middle&lt;/td&gt;&lt;td data-label=&quot;Detected?&quot;&gt;Yes: &lt;code&gt;gap&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Someone…&quot;&gt;deletes the newest rows, after the last checkpoint&lt;/td&gt;&lt;td data-label=&quot;Detected?&quot;&gt;&lt;strong&gt;Not from the database alone.&lt;/strong&gt; Only a copy outside it shows what&amp;#39;s missing&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Someone…&quot;&gt;deletes the log and the checkpoints&lt;/td&gt;&lt;td data-label=&quot;Detected?&quot;&gt;Only external copies help&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td data-label=&quot;Someone…&quot;&gt;holds the database and the KEK&lt;/td&gt;&lt;td data-label=&quot;Detected?&quot;&gt;They can rewrite history; only external copies help&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;
&lt;p&gt;The conclusion is the same in every bad case: &lt;strong&gt;send the events somewhere your database administrators don&amp;#39;t control.&lt;/strong&gt; The webhook sink posts NDJSON batches signed with &lt;code&gt;X-Neurouter-Signature&lt;/code&gt; (HMAC-SHA256 over timestamp and body); the OpenTelemetry sink exports events and checkpoints as OTLP logs to your SIEM.&lt;/p&gt;
&lt;p&gt;One more property to know: writes are asynchronous. A tool call doesn&amp;#39;t wait for its own row to commit. If the queue of unwritten events reaches 10,000, new tool calls are refused until it drains (fail-closed is the default and a setting), and the depth is exported as &lt;code&gt;neurouter_audit_queue_depth&lt;/code&gt;. A crash can lose events still in the queue, which is normally well under a second&amp;#39;s worth.&lt;/p&gt;
&lt;h2 id=&quot;retention-without-breaking-the-chain&quot;&gt;Retention without breaking the chain&lt;/h2&gt;
&lt;p&gt;Retention defaults to 90 days. Once a day, the retention job writes a &lt;code&gt;retention_cut&lt;/code&gt; checkpoint at the last row it will delete, archives those rows when &lt;code&gt;AUDIT_ARCHIVE_URL&lt;/code&gt; is set (local file, S3, Google Cloud Storage or Azure Blob; gzip NDJSON per UTC day plus a manifest with the file&amp;#39;s SHA-256 and the checkpoint), and only then deletes them. If the upload fails, nothing is deleted. The remaining log verifies from the cut checkpoint. &lt;code&gt;AUDIT_DATABASE_URL&lt;/code&gt; puts the audit log in its own database.&lt;/p&gt;
&lt;h2 id=&quot;what-this-helps-with-and-what-it-doesn-39-t&quot;&gt;What this helps with, and what it doesn&amp;#39;t&lt;/h2&gt;
&lt;p&gt;No log makes an organization compliant. Here&amp;#39;s how this one relates to the texts auditors will cite; our fuller mapping is on the &lt;a href=&quot;https://neurouter.com/compliance&quot;&gt;compliance page&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;EU AI Act.&lt;/strong&gt; For high-risk AI systems, &lt;a href=&quot;https://eur-lex.europa.eu/eli/reg/2024/1689/oj&quot;&gt;Regulation (EU) 2024/1689&lt;/a&gt; requires that they &amp;quot;technically allow for the automatic recording of events (logs) over the lifetime of the system&amp;quot; (Art. 12), and that providers (Art. 19) and deployers (Art. 26(6)) keep those logs, to the extent they control them, &amp;quot;for a period appropriate to the intended purpose of the high-risk AI system, of at least six months&amp;quot;, unless other law says otherwise. If you&amp;#39;re in scope, Neurouter&amp;#39;s 90-day default is too short: raise it or archive. Whether a system is high-risk depends on its use, and the Digital Omnibus on AI &lt;a href=&quot;https://cms.law/en/gbr/publication/the-eu-s-digital-omnibus-streamlined-ai-act-compliance-rules-are-now-in-force&quot;&gt;moved the application date&lt;/a&gt; for stand-alone high-risk systems to 2 December 2027. A gateway log covers the tool calls an AI system makes; it isn&amp;#39;t a complete Article 12 log of the system.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ISO/IEC 27001:2022.&lt;/strong&gt; Annex A includes a logging control (8.15). A verifiable log with defined retention and an off-database copy is the kind of evidence an auditor samples for it. The control, and how you meet it, is yours.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SOC 2.&lt;/strong&gt; A SOC 2 report is an auditor&amp;#39;s opinion on your controls against the AICPA&amp;#39;s &lt;a href=&quot;https://www.aicpa-cima.com/resources/download/2017-trust-services-criteria-with-revised-points-of-focus-2022&quot;&gt;Trust Services Criteria&lt;/a&gt;. Agent activity records and verification runs are evidence for the monitoring and logical-access criteria; they aren&amp;#39;t controls by themselves.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;known-gaps&quot;&gt;Known gaps&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Checkpoints aren&amp;#39;t anchored outside your infrastructure yet (for example to a WORM bucket or an RFC 3161 timestamping service); your SIEM copy is the anchor today.&lt;/li&gt;
&lt;li&gt;The KEK is configured through environment variables; external secret managers aren&amp;#39;t supported yet.&lt;/li&gt;
&lt;li&gt;The log sees tool calls, not model inputs and outputs that never become a call.&lt;/li&gt;
&lt;li&gt;The gateway records what it saw. &amp;quot;Status ok&amp;quot; means the upstream server said so.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;try-it&quot;&gt;Try it&lt;/h2&gt;
&lt;p&gt;Open the audit log and run &lt;em&gt;Verify integrity&lt;/em&gt; in the &lt;a href=&quot;https://neurouter-demo.web.app&quot;&gt;live demo&lt;/a&gt; (simulated data, in your browser), or read the implementation in &lt;a href=&quot;https://github.com/neurouter/neurouter/tree/master/apps/server/src/audit&quot;&gt;&lt;code&gt;apps/server/src/audit&lt;/code&gt;&lt;/a&gt; on &lt;a href=&quot;https://github.com/neurouter/neurouter&quot;&gt;GitHub&lt;/a&gt;. Operational details are in the &lt;a href=&quot;https://neurouter.com/docs/audit-log&quot;&gt;audit log documentation&lt;/a&gt;.&lt;/p&gt;
</content>
  </entry>
</feed>
