Skip to content

Auditing and control

Every tool call an agent makes fires the event event.mcp.call ("MCP Tool Call", in the Security group of the event list). The tool runs inside the event, which gives you two things:

  • a record of everything agents do, in the event log, that rules and notifications can react to;
  • a veto: a pre-online rule of the event that fails stops the call before the tool runs.

What the event records

Variable Value
username The token's user
tool The tool called, e.g. job_list
op The API operation it ran, e.g. job.list
kind read, write or destructive
args The arguments, masked (below)
response The answer as JSON, cut at 16 KB, masked
is_error 1 when the call failed
error The error the agent got, when it failed
elapsed Seconds the call took
token_prefix The prefix of the token used (never the token), as clarive auth list-tokens shows it
remote_addr The caller's address. Behind a reverse proxy or a CDN it is the first address of X-Forwarded-For, as in the login events

The text of the event in activity views is user jdoe called the MCP tool job_list.

Requests refused before reaching a tool (no token or an invalid one, an unknown tool name, malformed arguments) are protocol errors and fire no event. Listing the tools fires none either.

What is masked

The event log is read by administrators who are not necessarily allowed to see everything an agent saw, so the event keeps less than the agent got:

  • Secret keys. The value of any key that looks like a secret is replaced by the hide string, at any depth: passwords (password, passwd, dbpass, pass_svn, pwd...), secret and token in any form (client_secret, accessToken...), API keys, private, access, SSL, SSH, TLS and client keys, credentials, webhook URLs, salts and authorization or cookie values. Everything under such a key is masked too.
  • Variables. Every value inside a variables map, whatever its name: a password variable may be called anything.
  • key. A field named just key is masked unless it is a registry key such as config.comm.email or service.foo.bar.
  • Credentials in URLs. https://user:pass@host is kept as https://********@host.
  • Values that may be secrets whatever their name. The value of config.set, variable.set_value and variable.set_project_value is masked. Imported text (ci.import, hcl.apply, hcl.plan) and file contents (file.write, file.put) keep only their size.
  • Answers that reveal secrets. The values of variable.get (which can reveal passwords) and of config.get and config.list (whose values root sees in clear) are masked in the event.
  • Root-only answers. Of operations only root may call (server logs, the REPL, the registry...), the event keeps the size of the answer, not the answer.
  • Long values. Strings longer than 2000 characters are cut, and arguments or answers longer than 16 KB are kept as cut JSON text.

The agent itself gets the full answer; masking only applies to what the event stores.

Reading the record

In the web interface, open the event log and filter by the event MCP Tool Call. From the CLI:

clarive event log --event-key event.mcp.call --limit 20
clarive event get 123456                    # one event with its data and the rules it ran

Events are purged with the rest of the event log: by default after 7 days (the Purge settings event_ok_purge and event_ko_purge, see Purge daemon). Raise them, or copy the events elsewhere with a rule, if you need agent activity for longer.

Refusing calls with a rule

An event rule of event.mcp.call that runs pre-online and fails stops the call: the operation never runs, and the agent gets a forbidden error that carries the rule's message:

forbidden: topic.delete was not run, event.mcp.call stopped it: Agents may not run destructive tools: do it in the web interface

For example, to keep agents away from every destructive tool:

event "no-destructive-agent-calls" {
  name  = "No destructive agent calls"
  event = "event.mcp.call"
  when  = "pre-online"

  if "destructive tool" {
    cond = "kind eq 'destructive'"

    fail "refuse" {
      msg = "Agents may not run destructive tools: do it in the web interface"
    }
  }
}

Save it with clarive hcl save-rule --hcl @no-destructive-agent-calls.hcl or build the same rule in the Rule Designer: an event rule for MCP Tool Call, pre-online, with an IF on kind and a FAIL inside.

Other ideas, all with the same shape:

  • refuse every write to one user: all = ["username eq 'intern'", "kind ne 'read'"];
  • refuse a whole namespace (like is a regular expression): cond = { a = "op", op = "like", b = "^repl\\." };
  • refuse a single operation: cond = "op eq 'server.execute'";
  • refuse calls from outside your network: a condition on remote_addr.

The tool runs only after the pre-online rules pass, so a slow rule slows every agent call; keep these rules short.

If the event cannot be recorded at all (the event log is unreachable), the call is refused too: an agent never acts without a record.

Being told

Post-online and post-offline rules of event.mcp.call, and notifications on it, see the call with its result. For example, a notification on MCP Tool Call that emails the security team, or a post-offline rule that posts to a chat channel when kind is destructive and is_error is 0.