threatdeck
Live 13:45 UTC ·

Learn / Agents, tools and MCP

Lesson 6 of 68 minReviewed

Logging and auditing agents

Record enough about each agent step to reconstruct an incident, use the OpenTelemetry GenAI conventions instead of inventing a schema, and decide deliberately how much content to capture.

After an agent incident the questions are always the same: what did it read, what did it decide, what did it do, and on whose behalf? Without a record per step, responders are left inferring behaviour from the permissions the agent had. The MCP tools specification asks clients to log tool usage for audit purposes [1], and the UK NCSC recommends logging enough to spot suspicious activity, potentially including full model inputs and outputs, tool use and API calls [2].

The minimum record per step

Fields worth keeping for every tool call
FieldWhy it matters
Trace or session id, agent identity, end userAttribution, and joining agent logs to identity-provider and SaaS logs
Model, model version and system-prompt versionReproducing behaviour and spotting a change that preceded the incident
Tool name, MCP server and tool call idWhich capability was used, through which server
Arguments, with secrets redactedWhat was actually requested, not what the model said it would do
Decision: automatic, approved or rejected, by whom or which policyWhether a control was exercised or bypassed
Result status, size and errorFailed and oversized results are early signals
Content sources that entered context (URLs, document ids)Finding the injected input after the fact

OWASP's agent cheat sheet asks for the same core (every decision, tool call and outcome) and adds, for high-risk actions, the risk classification, authorisation outcome, approval id and policy version; it also says to redact passwords, tokens and secrets before logging and to track token use per session or user [3].

Use the standard schema

OpenTelemetry's GenAI semantic conventions define an execute_tool span with gen_ai.tool.name required and gen_ai.tool.call.id when the provider supplies one; gen_ai.tool.call.arguments and gen_ai.tool.call.result are opt-in attributes flagged as possibly containing sensitive information, and the conventions are still marked as in development [4]. The same project publishes conventions for MCP spans [5]. Building on them means your SIEM queries survive a change of agent framework.

Products follow a similar split. Claude Code's OpenTelemetry export emits a tool_decision event with the decision and its source (configuration, hook or user) and a tool_result event per completed call; prompt text is redacted unless OTEL_LOG_USER_PROMPTS=1 is set, and tool parameters are included only with OTEL_LOG_TOOL_DETAILS=1 [6].

Content capture is a data decision

Arguments and results contain source code, customer data and sometimes credentials. Decide per environment whether to capture them, who may read them and for how long, and treat the log store as sensitive data in its own right. Capturing nothing makes investigations guesswork; capturing everything into a widely readable index creates a new exposure.

What to alert on

  • Bursts of failed or rejected tool calls; the NCSC notes that failed calls can be the first sign of an attacker probing a system [2].
  • Approval bypass attempts, unusual tool-call frequency and spikes in high-risk actions [3].
  • A new MCP server, or a change to an agent's configuration or approval settings, outside your deployment process.
  • Connections from MCP server processes to destinations they have not used before.

Across a fleet, the MCP project's guidance adds two standing capabilities: an inventory of client configurations and an audit trail of which server and tool ran when, so a review can reconstruct what a compromised server did [7].

Try it on ThreatDeck

Self-check

4 questions

Pick an answer to see whether it is right and why. Only your score is saved, in this browser.

  1. In the OpenTelemetry GenAI conventions, which attribute is opt-in because it may contain sensitive information?
  2. Which signal does the NCSC point to as a possible early sign of an attacker probing an LLM system?
  3. Which record lets responders reconstruct what an agent did during an incident?
  4. With Claude Code's OpenTelemetry export at default settings, what happens to the text of user prompts?

References

  1. MCP specification: Tools (2026-07-28). Model Context Protocol, 2026-07-28.
  2. Prompt injection is not SQL injection (it may be worse). UK National Cyber Security Centre, 2025-12-08.
  3. AI Agent Security Cheat Sheet. OWASP Cheat Sheet Series.
  4. Semantic conventions for GenAI execute tool spans. OpenTelemetry.
  5. OpenTelemetry semantic conventions for Generative AI (spans, metrics, events, MCP). OpenTelemetry.
  6. Claude Code: Monitoring (OpenTelemetry). Anthropic.
  7. MCP Local Server Security. Model Context Protocol, 2026-07-28.
Completing the self-check also marks the lesson complete. Saved in this browser only.

Following

Follow the vendors, products, AI tools, techniques and actors you care about. Matching stories, CVEs and exploited bugs are marked, a Following tab appears in the feed, and returning visits show what changed. Saved only in this browser.

Presets

Get updates

A personal RSS feed of new stories on everything you follow. Paste it into any feed reader, Slack or Teams RSS app.