Menu

AI

MCP Audit Logging: What to Record

What to record in MCP audit logs: the fields for every tool call, scope and approval events, what to mask, how to protect logs, and what the spec and OWASP say.

By: Irina ShvayaOctober 28, 2026

MCP Audit Logging: What to Record

This page is part of our MCP Security Center, within The MCP Guide. Want a second opinion on your setup? Request a free MCP readiness review.

MCP audit logging means keeping a reliable record of what AI agents did through MCP: which person or agent called which tool, on which server, with what inputs, when, and with what result. Good logs let you answer "what happened?" after a mistake or an attack. Without them, you are guessing.

The MCP tools specification says clients should "Log tool usage for audit purposes." OWASP lists "Lack of Audit and Telemetry" as one of its ten MCP risks. Neither tells you exactly which fields to keep, so this guide does.

It covers the fields to record, the events beyond tool calls, what to mask, and how to protect the logs themselves. Sources were checked on 28 October 2026.

Key Takeaways

  • Log every tool call with who, which client, which server and tool, inputs, result status, time and a correlation ID.
  • Also log approvals and denials, scope grants, server installs and tool-list changes.
  • Mask secrets and personal data, including tokens hidden inside URLs.
  • Store logs where the people and agents they record cannot change or delete them.
  • Check what your AI client logs by default; some redact MCP server names unless you opt in.

What the spec and OWASP say

The MCP tools specification lists logging among client SHOULDs: "Log tool usage for audit purposes." It also says there should be a human able to deny tool calls, which makes approval decisions worth logging too.

The MCP Security Best Practices add three specific logging points:

  • Servers should "Log elevation events (scope requested, granted subset) with correlation IDs."
  • Clients should "Log suspicious authorization URLs for security monitoring."
  • Proxies that spawn local servers should "Log all stdio transport usage for security monitoring."

OWASP's MCP08 entry goes further. It lists essential fields (timestamp, agent ID, session ID, tool invoked, parameters, response summary and user identity) and recommends structured formats such as JSON or OpenTelemetry. The OWASP project is in beta as of October 2026.

The fields to record for every tool call

FieldExampleWhy it matters
Timestamp (UTC)2026-10-28T14:03:11ZBuilds the timeline
User identityj.smith@company.comWho the agent acted for
Agent or clientClaude Code 2.x, support-botWhich app made the call
Correlation or trace ID7f3a...Links calls in one task
MCP server and versioncrm-server 1.4.2Which code ran
Tool nameupdate_contactWhat was used
Inputs (masked){"id": "123", "email": "[masked]"}What was asked
Approvalauto, user-approved, user-deniedWas a human involved
Result statussuccess, tool error, protocol errorDid it work
Result summary or size1 record updated, 2 KBWhat came back, without storing everything
Scopes on the tokencrm.read crm.writeWhat access was in play

Use one structured format across all servers. That makes searching and alerting far easier than mixed text logs.

Events beyond tool calls

Tool calls are only part of the picture. Also record:

  1. Approvals and denials. Who approved a risky call, and which calls were refused.
  2. Scope changes. When a token gained new scopes, as the best practices recommend.
  3. Server changes. Installs, removals, version upgrades and config edits.
  4. Tool-list changes. When a server's tools or descriptions change. Servers can signal this with a notifications/tools/list_changed message, per the tools spec. Unexpected changes may point to a rug pull.
  5. Authentication events. Sign-ins, failures, token refreshes and revocations.
  6. Blocked actions. Requests stopped by a gateway, sandbox or policy.

What not to log in clear text

Logs are a target. If they hold tokens, anyone who reads them can reuse those tokens.

Two 2026 advisories show how this goes wrong. OpenPanel accepted MCP credentials in a URL query string and wrote the full URL to logs, per its GitHub advisory. Its logger redacted sensitive keys but not tokens embedded inside a URL. A Meta Ads MCP server returned request URLs containing the operator's access token in error responses, per its advisory.

Mask or remove:

  • Access tokens, refresh tokens, API keys and client secrets, including inside URLs and error messages.
  • Passwords and one-time codes.
  • Personal data you do not need for the investigation, such as full email bodies.
  • Full prompts and tool outputs, unless you have a clear reason and a retention limit.

The token passthrough section of the best practices adds another reason to get identity right. When servers forward tokens, downstream logs "may show requests that appear to come from a different source," which makes investigations harder. See why MCP servers must not pass tokens through.

Protect the logs themselves

OWASP's MCP08 entry recommends:

  • Hashing log files and storing them in "append-only or write-once media."
  • Restricting log access, with dual authorization for deletion.
  • Forwarding logs to a SIEM (security information and event management) system and alerting on high-risk activity.
  • Setting retention to meet your compliance needs; it cites PCI DSS's one-year minimum as an example.

A practical rule: no AI agent should be able to read, edit or delete its own audit logs. Keep them outside every MCP server's reach.

For general logging practice beyond MCP, the joint guidance Best Practices for Event Logging and Threat Detection, published on 21 August 2024 by Australia's ASD with CISA, the FBI, the NSA and other partners, sets a baseline.

Check what your AI client records

Client defaults vary, so read the docs. For example, Claude Code's monitoring docs describe OpenTelemetry events including claude_code.tool_result and claude_code.tool_decision.

By default, the same docs say, prompt text is redacted. Names of user-configured MCP servers and tools are replaced with "custom" on several metrics and events. Setting OTEL_LOG_TOOL_DETAILS=1 records tool parameters and the real MCP server and tool names. Decide deliberately: real names help investigations, and full parameters may need masking downstream.

Other clients and gateways have their own settings. Our guide to MCP governance for IT leaders covers central controls.

A short logging rollout plan

  1. List where tool calls can be logged: the client, a gateway, the server, or all three.
  2. Pick one structured format and the fields in the table above.
  3. Add masking before logs leave the machine or service.
  4. Send logs to one central store the agents cannot reach.
  5. Write three alerts: a denied call on a write tool, a new server installed, and a tool-list change.
  6. Test it. Run a known tool call and confirm you can trace it end to end.

Next step

Want to know whether your current logs would answer "what did the agent do?" Our MCP readiness audit tests that with you. Building your own server? Our MCP development team builds structured, masked logging in from day one.

Frequently asked questions

Should the client or the server do the logging?

Both, ideally. The client knows who asked and whether a person approved. The server knows exactly what it did downstream. A gateway can add one central record across many servers.

Should we log full prompts and tool outputs?

Only with care. They can help investigations but often contain personal data and secrets. Many teams log a summary and size by default, and keep full content only for high-risk tools with a short retention period.

How long should we keep MCP logs?

Follow your existing retention policy and any regulations that apply. OWASP cites PCI DSS's one-year minimum as one example. Set the period before an incident, not after.

What is a correlation ID?

It is a unique value attached to every log line from one task or request. It lets you link the user's request, the approval, each tool call and the downstream API call. The best practices recommend correlation IDs for scope elevation events.

Is logging enough on its own?

No. Logs help you detect and investigate, but they do not prevent harm. Pair them with least privilege and approvals, as covered in the MCP security checklist.

You Might Also like to Read

Get a FREE Website Audit

Enter your website and get a 20–30 page SEO, GEO, AEO & CRO audit within 24 hours. Completely free.

Don't have a site yet? Get in touch →

Ready to speak with a marketing expert?
Give us a call! (916) 866-7893

Websites Launched
1407
Websites Launched
Marketing Experts
29
Marketing Experts
Hours of Dedicated Work
204533
Hours of Dedicated Work
Irina S.Benjamin G.Jeanette M.David G.