← Blog

Auditing the MCP tool calls your team's coding agents make

When Claude Code, Codex, Cursor or Gemini CLI call MCP tools, the record of what happened can live in three places: the client, the MCP server, and the system behind it. What each layer can see, which one to trust as the record, whether to keep arguments, and how to read Sandscale's audit log for agent calls from the CLI.

A coding agent with MCP servers configured makes tool calls nobody types. Most are harmless reads. A few start machines, write files, or change settings. When a team asks “what did the agents do yesterday”, the honest answer depends on where you look, because an MCP tool call passes through three layers and each keeps a different record, or none.

This post is about choosing which record you rely on. It is narrower than our general post on what an audit log for coding agents should record; here the question is only MCP.

The three layers

The client. Claude Code, Codex, Cursor and Gemini CLI see every tool call: which server, which tool, the arguments the model chose, and the result. They are also on the developer’s machine, under the developer’s control, and their transcripts are not written as an audit trail. A client-side record is good for debugging a session and weak as evidence.

The MCP server. A server sees the calls made to it. What it records is up to whoever wrote it. A local stdio server started from a package you installed last week may record nothing at all, and if it does, it writes to that one machine.

The system behind the server. Most useful MCP tools are thin wrappers over an API: the tool call becomes an API request, and the API decides whether it is allowed. If that API keeps an audit log, the MCP call lands there with the same identity and checks as any other request. This is the layer a person other than the developer can trust, because the developer cannot edit it.

So the rule of thumb: rely on the record at the system behind the server, and add client-side records where you need detail it does not keep.

What the record should say

For each call, the questions a team ends up asking are:

  • Who. The person the agent acted for, not only a key ID. Keys get shared.
  • Through what. Which client or app made the call. Two agents run by the same person should be distinguishable.
  • What. The tool, or the API action it became, and the resource it touched.
  • Outcome. Allowed or refused, and the error when refused. Refusals are the interesting ones.
  • When and where. Time, and the region or machine.

Notice what is not on the list: the arguments. That is deliberate.

Arguments: keep them, or don’t

Arguments are where the detail is. They are also where the secrets are: a command line with a token in it, a file body, a connection string the model copied from a .env. A durable log that stores arguments becomes a second place your secrets live, kept for as long as you keep the log.

There is no single right answer, but there is a sensible split:

  • The durable, shared audit trail records who, what, outcome and when, and not the arguments.
  • Where a team needs arguments, it keeps them close to the work and for a short time: a client-side log on the agent’s machine, scrubbed, and rotated.

Client-side detail with a Claude Code hook

Claude Code names MCP tools mcp__<server>__<tool>, and its hooks can match them with a regular expression. A PostToolUse hook matching mcp__.* runs after every successful MCP call, and PostToolUseFailure after every failed one, with the session ID, the working directory, the tool name and its input on standard input. Their hooks reference has the fields.

A minimal hook that writes one line per call, without the arguments:

{
  "hooks": {
    "PostToolUse": [
      { "matcher": "mcp__.*",
        "hooks": [{ "type": "command",
          "command": "jq -c '{t: (now|todate), session: .session_id, tool: .tool_name, cwd: .cwd}' >> \"$HOME/.claude/mcp-calls.jsonl\"" }] }
    ]
  }
}

If you decide you want the arguments, add .tool_input to that filter, scrub what you know to be sensitive, and keep the file on that machine. Do not ship it into a shared log store without deciding how long it stays there.

This gives you a per-machine timeline. It is not tamper-evident, and it only exists where someone set up the hook.

The record behind the server: how it works with Sandscale

Sandscale’s MCP servers are both wrappers over the Sandscale API, so their calls land in the organization’s hash-chained audit log, the same log that records sandboxes started and stopped, commands run, secrets used, and approvals.

  • Remote server (https://mcp.sandscale.dev/mcp). Every call is in the audit log with the tool, the region, the outcome and the app, and never the arguments. Each call runs as the person who approved the connector.
  • Local server (sandscale mcp, from the CLI). Its tools are the CLI’s API commands, so each call is an API request made with that machine’s sign-in, and is recorded as that person’s action.

Sandscale’s security controls also scan prompts and MCP tool calls for credentials before they go anywhere, on every plan; a match stops the call, and the audit log records what kind of thing was found and where, not the value.

Reading it from the CLI

The Sandscale CLI (1.4.1) reads the log with the audit commands; each needs the audit:read permission in the organization.

The last day, as JSON, for a script or a reviewer:

sandscale audit events-list --from 2026-12-01T00:00:00Z --to 2026-12-02T00:00:00Z --json

events-list reads newest first and filters by --action or --action-prefix, --resource-type, --outcome and --project-id. Two details matter for MCP:

  • Read-only requests are hidden by default. Many MCP calls are reads: listing sandboxes, listing buckets. Add --include-read-only true when you want to see what the agents looked at, not only what they changed.
  • Filter refusals first. --outcome failure shows the calls that were refused, which is usually where the story is.

Use the action names you see in your own log as filters, rather than guessing them. To watch calls as they happen, sandscale audit logs-stream-get streams new entries as Server-Sent Events with the same filters. To check the chain itself, sandscale audit logs-verify-get; our post on hash-chained audit logs explains what that verification proves.

Every plan can read the log. Exporting it for a period, as evidence for your own assessments, is on Team and Enterprise.

A setup that holds up

  1. Prefer MCP servers that wrap a system with its own audit log, and have each person sign in as themselves.
  2. Treat that system’s log as the record. It should say who, through which app, what, the outcome and when.
  3. Keep arguments out of the durable log. If you need them, keep them in a short-lived, scrubbed client-side log.
  4. Review refusals weekly, and include read-only calls when you are investigating.
  5. For servers that run locally and log nothing, run them on the agent’s own machine, not a laptop with everyone’s credentials; see running untrusted MCP servers in a microVM.
Run your agents in a box of their own

Each sandbox is a Firecracker microVM. Free includes 100 awake vCPU-hours a month.

Start free

Keep reading