MCP audit logging: What to capture for SOC 2 and incident response

by Sujay ChoubeyNov 20, 202619 min read
MCP

TL;DR: MCP audit logging requires more than protocol debug messages to support SOC 2 reviews and incident response. Capture the initiating user, executing agent, tool, connected account, outcome, and correlation ID in structured records. The example below includes more than 20 fields. For SOC 2 CC6.1 evidence, treat the attribution fields (timestamp, event_id, actor.id, actor.type, actor.session_id, agent.id, agent.version, and correlation_id) as the core set, and decide on fields such as actor.name, resource.path, and the before/after state hashes based on your controls and data sensitivity. The July 2026 MCP specification update deprecated its protocol Logging utility, recommending stderr for stdio servers or OpenTelemetry for observability. Composio provides tool execution logs, while retention, evidence mapping, and SIEM ingestion still require explicit configuration.

Say your AI agent updates Salesforce records, sends Slack messages, and creates Jira tickets. Now your auditor wants proof of who authorized each action, which credentials were used, and what data changed. If you rely on protocol debug output for MCP audit logging, you have an evidence gap.

The July 28, 2026 MCP specification update deprecated its built-in Logging utility and recommends stderr for stdio servers or OpenTelemetry for structured observability. That deprecation confirms that MCP's protocol-level logging was designed for debugging, not for producing the audit-grade evidence that SOC 2 CC6.1, CC7.2, and HIPAA § 164.312(b) demand.

This guide breaks down exactly what to capture in your MCP audit logs, how to structure them for compliance evidence, and how to handle the edge cases that break naive logging strategies. Whether you're building an in-house MCP gateway or evaluating managed solutions, these field specifications and JSON schemas give you a starting point for design reviews and pre-audit gap analysis.

Why MCP debug logs fail SOC 2 audits

The deprecated MCP Logging utility lets servers send structured messages using RFC 5424 severity levels. Depending on the protocol version, clients can set log levels or supply request metadata, while servers send notifications containing severity levels, optional logger names, and JSON data. These messages can help debug agent behavior, but they are not a complete security audit trail.

Five gaps in protocol debug output

Protocol debug output alone has five common gaps that can complicate evidence collection under the AICPA Trust Services Criteria:

  1. Actor identity gap: MCP debug logs typically capture stderr output or protocol notifications without structured user context. SOC 2 CC6.1 requires logical access controls with attribution to named individuals. A record showing tool_call: repository/update without the initiating identity cannot demonstrate the necessary access attribution on its own.

  2. No tamper evidence: Debug logs written to stdout are easily overwritten and lack immutability guarantees. SOC 2 CC7.2 requires monitoring system components and detecting anomalies. If logs can be altered without detection, they provide weak evidence of monitoring effectiveness.

  3. Argument truncation: Protocol debug logs often truncate tool arguments for readability. SOC 2 CC8.1 addresses change management, and relevant change evidence may need to capture the nature and result of modifications. A truncated entry showing arguments: {...} does not independently establish what changed in a Salesforce record.

  4. Missing retention controls: Debug output rarely includes explicit retention policies or archival strategies. HIPAA § 164.312(b) requires audit controls for systems handling ePHI. The six-year rule in § 164.316(b)(2)(i) applies to required Security Rule documentation, not automatically to every raw audit event. Define log retention based on applicable requirements and documented risk assessments.

  5. No correlation across hops: MCP tool calls often chain through multiple agents and services. Without correlation IDs propagated through the entire request path, incident response teams can't reliably reconstruct what happened during a security event. In practice, this tends to slow detection and response, which teams commonly track as mean time to detect (MTTD) and mean time to respond (MTTR). That effect is a practitioner observation rather than a measured result, and incident response is the area SOC 2 CC7.4 addresses.

The gap between debug logging and audit logging is the gap between "the system recorded something" and "the system produced audit-grade evidence." NIST SP 800-92 recommends an organization-wide security log management process, not merely collecting application debug messages.

The audit-grade MCP log schema

An audit-grade MCP log record needs to answer six questions for every tool call:

  • Who initiated the action (human user, service account, or another agent)?

  • Which agent executed it (agent ID and version)?

  • Which tool was called (tool name and MCP server)?

  • Which account was used (credential identity, never the credential itself)?

  • What changed (before/after state or arguments)?

  • When and where (timestamp, correlation ID, session ID)?

Here is an illustrative JSON audit event with more than 20 leaf fields. It is a sample record, not a formal JSON Schema or a mandatory compliance field list:

{
  "schema_version": "1.0.0",
  "event_id": "evt_550e8400e29b41d4a716446655440000",
  "timestamp": "2026-11-03T14:32:09.114Z",
  "actor": {
    "id": "user_12345",
    "type": "human",
    "name": "alice@example.com",
    "session_id": "sess_87654321"
  },
  "agent": {
    "id": "agent_claude_001",
    "version": "20240115",
    "parent_agent_id": null
  },
  "mcp_server": {
    "id": "server_github_integration",
    "endpoint": "https://mcp.internal/servers/github"
  },
  "tool": {
    "name": "repository/update_file",
    "arguments_hash": "sha256:a1b2c3d4e5f6",
    "argument_count": 4
  },
  "resource": {
    "type": "repository",
    "id": "org/repo",
    "path": "src/config.yaml"
  },
  "action": "write",
  "outcome": "success",
  "status_code": 200,
  "latency_ms": 342,
  "correlation_id": "corr_abcdef123456",
  "parent_correlation_id": null,
  "state_change": {
    "before_hash": "sha256:prev_state",
    "after_hash": "sha256:new_state"
  },
  "auth": {
    "token_hash": "sha256:token_fingerprint",
    "scope_granted": "repo:write",
    "token_issuer": "https://idp.example.com"
  },
  "retention_class": "audit_6y"
}

How the schema maps to SOC 2 and HIPAA

The fields below can support evidence collection for relevant controls, but the record alone does not establish compliance:

  • Attribution and scope: timestamp, event_id, actor.id, actor.type, actor.session_id, agent.id, agent.version, and correlation_id support evidence for SOC 2 CC6.1 (logical access) and HIPAA § 164.312(a)(2)(i) (unique user identification). The actor.type field distinguishes human users from service accounts and AI agents.

  • Request and tool: mcp_server.id, tool.name, tool.arguments_hash, and resource.id document what was accessed and through which path. The arguments_hash field is critical: it proves what arguments were passed without logging sensitive data like API keys or PII in plaintext. Use a non-sensitive argument fingerprint when full arguments are not required for investigation.

  • Outcome and state: action, outcome, status_code, state_change.before_hash, and state_change.after_hash can support monitoring under SOC 2 CC7.2 and change management reviews under CC8.1. For read operations, state_change can be null. For writes and deletes, capture hashes of the before and after states so you can prove what changed without storing full snapshots of sensitive data.

  • Authentication and lifecycle: auth.token_hash, auth.scope_granted, correlation_id, and retention_class document which credentials were used and how long this record must be retained. Never log plaintext tokens.

If you are building in-house, use this example to identify gaps between the data your gateway captures and the evidence your auditors request.

Correlation IDs across multi-hop agent chains

When an agent calls another agent, which calls a tool, which triggers a webhook, your audit trail needs to connect all four events. Without correlation IDs, you're reconstructing causality from timestamps, which fails the moment two requests overlap.


An AI agent executing a multi-tool task across Google Analytics and Google Sheets, demonstrating the need for correlation across tool calls.

Use a three-hop propagation pattern:

  1. Client ingress: Generate a correlation ID at the MCP gateway entry point or accept the trace context using the W3C traceparent header. This becomes the root correlation_id for the entire chain.

  2. MCP gateway to server: Inject the correlation ID into the _meta field on every request. The MCP request metadata mechanism supports extensible metadata, but any custom correlation field requires explicit agreement between client and server.

  3. Server to downstream tool: Propagate the correlation ID via standard trace context headers to any external APIs or nested agent calls. If Agent A calls Agent B, Agent B's audit events should include both correlation_id (inherited from A) and parent_agent_id (A's agent ID).

For nested agent invocations, add a parent_correlation_id field. When Agent A spawns Agent B, Agent B's logs record correlation_id: corr_B and parent_correlation_id: corr_A. This lets you reconstruct the full execution tree during incident response.

The OpenTelemetry GenAI semantic conventions provide observability attributes for generative AI operations, while correlation across tool and audit events still requires an intentional implementation. If you're using OpenTelemetry for observability, reuse the same trace context for audit logs. If you're not, implement W3C Trace Context propagation manually. The requirement: every event in a multi-hop chain must carry an identifier that links it back to the original request.

Authentication event logging for MCP tool access

MCP tool calls often depend on OAuth tokens, API keys, or service account credentials. Your audit log needs to record which credential was used without ever logging the credential itself.

Log these five authentication fields for every tool call:

Field

Example Value

Purpose

token_issuer

https://idp.example.com

Identifies the identity provider

subject_id

user_12345 or service_github

Identifies the token bearer

scope_granted

repo:write,gist:read

Documents authorization boundaries

token_hash

sha256:abc123def456

Credential fingerprint (never plaintext)

expires_at

2026-11-03T18:32:09Z

Credential validity window

OWASP ASVS 4.0 requirement V7.1.1 prohibits logging credentials or payment details. If session tokens are logged, they must be stored as irreversible hashes.

When an OAuth token is refreshed, log a separate authentication event with event_type: token_refresh, the old token hash, the new token hash, and the refresh timestamp. This creates a chain of custody for credentials, which auditors ask for when evaluating SOC 2 CC6.1.

Composio offers managed OAuth connections across 1,700+ integrations. Its documented tool execution logs support auditing executed actions, but token refresh events with hashed fingerprints are not established by that API reference. If you're managing OAuth in-house, log every token issuance, refresh, and revocation event with the five fields above.

What to redact and how to hash it

Your audit log must capture enough detail to reconstruct events without becoming a liability itself. That means redacting or hashing specific categories of sensitive data before they hit your log pipeline.

Redact or hash these six data types:

  1. OAuth bearer tokens: Exclude the plaintext token. If correlation is essential, log a keyed fingerprint or a credential reference instead.

  2. API keys and credentials: Replace with a nonreversible reference. The OWASP Logging Cheat Sheet recommends excluding or sanitizing credentials, session tokens, sensitive personal data, and similar secrets.

  3. User passwords and session secrets: Exclude the secrets entirely. If you must reference a session, use the session ID, not the session token.

  4. Protected Health Information (PHI): Apply HIPAA's minimum necessary principle where applicable. If the audit log doesn't need a patient's name to prove access occurred, pseudonymize it with a hash or token.

  5. Personally Identifiable Information (PII): Consider de-identification techniques like deletion, scrambling, or pseudonymization where the individual's identity is not required for the audit trail.

  6. Tool arguments containing secrets: If arguments contain credentials or connection strings, omit the plaintext and store a non-sensitive fingerprint only when needed.

Redact at the point of logging, not at query time. If the raw record exists in a queue, agent buffer, or object store before redaction, you've already created a compliance risk. Implement redaction in the logging layer itself, before the record leaves the MCP server.

Retention, export, and SIEM integration

HIPAA requires retention of specified Security Rule documentation for six years under § 164.316(b)(2)(i), but it does not impose a universal six-year retention period on every audit log. SOC 2 does not prescribe a single retention duration either. Consider this illustrative three-tier strategy and adapt it to your legal and contractual obligations:

  • Active (online) storage: 90 days to 1 year in your primary log aggregation system for fast querying during incident response.

  • Archive (cold) storage: A retention period set by your applicable obligations, potentially six years where records qualify as required HIPAA documentation.

  • Immutable compliance archive: An organization-defined duration, potentially seven years, using write-once-read-many (WORM) controls or object lock for tamper resistance.

Archiving to S3 with appropriate access controls and lifecycle policies can support an approved retention plan without keeping all records in hot storage. The storage configuration alone does not establish HIPAA compliance.

Export audit logs to your SIEM using one of three standard mechanisms:

  1. Structured JSON over syslog (RFC 5424): Include MCP-specific fields as structured data elements in the syslog message.

  2. OpenTelemetry export: If you're already using OpenTelemetry for observability, export audit events as log records using attributes supported by your collector and SIEM.

  3. HTTP forwarding to SIEM ingest endpoints. Send logs to Splunk HTTP Event Collector (HEC) or the Datadog Logs API.

Composio’s SIEM streaming guide shows how to schedule a collector that pulls tool execution events from the Logs API and forwards them to Splunk or Datadog. Composio’s Enterprise plan also lists SIEM streaming for audit and tool-call logs. For configuration change history, Composio’s audit logs record events such as updates to session configurations.

For SOC 2 CC7.2, your SIEM should alert on anomalies like tool calls outside business hours, spikes in denied access attempts, or tool calls from unexpected IP ranges. Audit logs are only useful for incident response if someone is watching them.

Handling edge cases: Streaming, timeouts, and partial failures

Real-world MCP tool calls don't always complete cleanly. Your audit logging strategy needs to handle four non-standard execution scenarios:

  • Streaming responses: When a tool returns streaming output, log the stream metadata (start timestamp, chunk count, end timestamp, final status) rather than every chunk. Include a streaming: true flag and a completion marker so auditors know the record represents a multi-part response.

  • Partial executions: The MCP tools specification represents tool execution errors with isError: true in the tool result, rather than necessarily as protocol-level errors. Log all partial execution attempts with outcome: partial_success, partial_failure, or timeout. Include an attempt_count field if the client retried the call.

  • Timeouts: Record execution start time, configured timeout, actual elapsed time, and timeout trigger point. Log as outcome: timeout with a timeout_reason code (client timeout, server timeout, upstream API timeout).

  • Multi-hop agent chains: Each agent in the chain records its own audit event linked via parent_agent_id and parent_correlation_id. OpenTelemetry supports nested spans for this pattern, so if you're using OTel for observability, reuse the same parent-child span relationships in your audit log schema.

Across all four scenarios, your audit log must capture intent and outcome even when execution doesn't follow the happy path. An incomplete record is better than no record, and a partial record with an explicit outcome field is better than a silent gap.

How Composio handles MCP audit logging

Composio’s Logs API lets teams review individual tool executions and their outcomes. For a compliance review, confirm which fields your deployment records and exports.

Credentials are isolated from the LLM context and application code by architecture. Tokens are stored with AES-256 encryption, and the agent never sees the raw credential. When an agent calls a tool through Composio, the platform resolves which connected account to use, decrypts the credential inside an isolated runtime, injects it into the outbound request, and records tool execution metadata. Published Logs API documentation does not confirm a hashed token fingerprint on every event.

Composio holds SOC 2 Type II and ISO/IEC 27001:2022 certifications. The scope of the assessed controls should be checked against the relevant audit reports rather than treating certification as proof that every logging feature was independently tested. For teams making the build-vs-buy decision, that's the difference between building an audit logging system and hoping it passes your SOC 2 audit, versus evaluating a managed service with documented compliance practices.

The Logs API provides an interface to retrieve tool execution records. Confirm the export pipeline and retention requirements with the vendor before treating it as a complete SIEM integration. If you're evaluating MCP gateways, ask vendors: What fields do you log? Can I export them? What certifications do you hold? How do you handle credential redaction?

For an enterprise review, verify captured fields, denied-call visibility, retention options, credential redaction, and evidence availability against the product documentation and your own control requirements.

MCP audit logging requirements

Use these requirements to validate your MCP audit logging implementation against SOC 2 and HIPAA:

Schema and fields

  • Every tool call logs timestamp (ISO 8601 UTC), event_id (UUID), actor.id, actor.type, and actor.session_id

  • Every tool call logs agent.id, agent.version, and mcp_server.id

  • Every tool call logs tool.name, tool.arguments_hash (SHA-256), and resource.id

  • Every tool call logs action (read/write/delete/execute), outcome (success/failure), and status_code

  • Every tool call logs correlation_id and parent_correlation_id for multi-hop chains

  • State-changing operations log state_change.before_hash and state_change.after_hash

  • Authentication events log token_hash (never plaintext), scope_granted, and token_issuer

Redaction and security

  • OAuth tokens, API keys, and session secrets are excluded from plaintext logs

  • PHI and PII are pseudonymized or excluded per HIPAA minimum necessary and GDPR principles

  • Redaction happens before sensitive data enters the log pipeline

  • Audit log access is itself logged and restricted to authorized personnel

  • Audit logs are encrypted at rest with AES-256 or equivalent

Retention and export

  • Retention periods and immutable storage controls follow documented legal, contractual, and risk requirements

  • Audit logs export to SIEM via structured JSON over syslog, OpenTelemetry, or HTTP webhook

  • Export format includes fields relevant to SOC 2 CC6.1, CC7.2, CC7.3 (security event evaluation), CC7.4 (incident response), and CC8.1 evidence

Edge cases

  • Streaming tool responses log metadata (chunk count, final status) with streaming: true flag

  • Partial executions log outcome: partial_success or partial_failure with attempt_count

  • Timeouts log outcome: timeout with elapsed time and timeout reason

  • Multi-hop agent chains log parent_agent_id and parent_correlation_id on nested invocations

Compliance mapping

  • Log schema supports evidence for SOC 2 CC6.1, CC7.2, CC7.3 (security event evaluation), CC7.4 (incident response), and CC8.1

  • Log schema maps to HIPAA § 164.312(b) audit controls and § 164.312(a)(2)(i) unique user identification

  • Audit log format supports your SIEM's ingestion schema (Splunk HEC, Datadog, Elastic ECS)

If you're building in-house, these requirements provide a starting point for design reviews and pre-audit gap analysis. If you're evaluating managed MCP gateways, use them to compare vendor capabilities against your compliance requirements.

Start on the free tier with 100,000 Composio-managed tool calls per month, or book a call to discuss your security requirements before your next enterprise review.

FAQs

What is MCP audit logging?

MCP audit logging is the practice of recording structured, tamper-evident records of every tool call made through the Model Context Protocol, capturing who initiated the action, which agent executed it, which tool was called, which account was used, and what changed. Unlike MCP protocol debug logs, audit logs are designed to produce compliance evidence for SOC 2, HIPAA, and incident response.

What is an MCP audit log?

An MCP audit log can be a structured JSON record with 20+ fields that documents a single tool call, including timestamp, actor identity, agent ID, tool name, hashed arguments, resource accessed, action type, outcome, correlation ID, and before/after state hashes. It differs from a debug log by including actor attribution, tamper evidence, and compliance-grade retention controls.

What is the difference between MCP logging and MCP audit logging?

MCP logging (the protocol's deprecated Logging utility) was designed for debugging and sends severity-leveled messages from server to client. MCP audit logging captures structured evidence of who did what, when, and to which resource, with fields mapped to SOC 2 Trust Services Criteria and HIPAA audit control requirements. The July 2026 MCP update deprecated protocol logging and recommended stderr for stdio servers or OpenTelemetry for observability.

What is an AI agent audit trail?

An AI agent audit trail is a chronological record of every action an AI agent takes, including tool calls, API requests, and state changes, with enough detail to reconstruct the agent's behavior during incident response or compliance audits. It requires correlation IDs to link multi-hop agent chains, actor attribution to distinguish human users from autonomous agents, and tamper-evident storage to prove log integrity.

How long should I retain MCP audit logs for SOC 2?

SOC 2 does not prescribe one fixed log retention period. HIPAA's six-year requirement applies to specified Security Rule documentation, not automatically to all audit logs. Define active storage, cold storage, and immutable archive periods based on applicable legal and organizational requirements.

What fields are required in an MCP audit log for HIPAA compliance?

HIPAA § 164.312(b) requires audit controls that record and examine activity in systems containing ePHI. An organization should identify the event, actor, time, affected resource, and outcome as appropriate to its audited system. HIPAA does not prescribe this exact universal field list. For MCP tool calls, add agent ID, tool name, hashed arguments, and correlation ID to support incident investigation.

How do I redact sensitive data from MCP audit logs?

Exclude OAuth tokens, API keys, and session secrets from logs. Where a stable reference is essential, use a nonreversible, securely generated fingerprint. Pseudonymize PHI and PII per HIPAA minimum necessary and GDPR principles. Never log plaintext credentials, even in debug mode.

Can I use MCP protocol logging for SOC 2 audits?

Not by themselves. The MCP protocol’s Logging utility was deprecated in July 2026. Protocol debug messages alone do not establish identity attribution, tamper evidence, or appropriate retention. Use a structured audit schema and define your SIEM and retention configuration based on your compliance obligations.

How do I export MCP audit logs to Splunk or Datadog?

Export audit logs via structured JSON over syslog (RFC 5424), OpenTelemetry log records, or HTTP webhook to Splunk HTTP Event Collector (HEC) or Datadog Logs API. Include all audit fields as structured data elements so your SIEM can index and alert on them. Composio provides a tool execution Logs API that can feed a customer-managed ingestion pipeline.

What happens when an MCP tool call fails or times out?

Log the attempt with outcome: failure or outcome: timeout, the error code or timeout reason, elapsed time, and attempt count if the client retried. The MCP tools specification uses isError: true for tool execution errors, so your audit log should capture both the protocol-level success and the tool-level failure.

Key terms glossary

Audit log: A structured, timestamped record of who did what, when, where, and to which resource, designed to provide evidence for compliance audits and incident investigation. Audit logs differ from operational logs by including actor attribution, tamper evidence, and compliance-grade retention.

Correlation ID: A unique identifier propagated through every hop of a multi-service request, linking related events across agents, MCP servers, and downstream APIs. Correlation IDs let incident response teams reconstruct causality when a single user action triggers multiple tool calls.

Credential isolation: An architectural pattern where OAuth tokens and API keys are stored separately from application code and the LLM context, so the agent never sees the raw credential. Credentials are decrypted inside an isolated runtime and injected into outbound requests without passing through the agent's memory.

MCP Gateway: A service or component that routes tool calls between AI agents and MCP servers. Depending on its implementation, it can centralize authentication, policy enforcement, and audit records. Logging fields, SIEM exports, and certifications vary by vendor.

Policy-as-code enforcement: Access restrictions evaluated in the request path before the model is involved, enforced at the infrastructure layer rather than through prompt instructions. An admin disables a tool or action, and the agent cannot use it regardless of what the prompt contains.

SOC 2 Trust Services Criteria: Criteria used to evaluate controls relevant to security, availability, processing integrity, confidentiality, and privacy. CC6.1 covers logical access, CC7.2 covers system monitoring, CC7.3 covers security event evaluation, CC7.4 covers incident response, and CC8.1 covers change management. Audit logs provide evidence for all five.

Tamper evidence: Technical controls that make unauthorized log modification detectable, such as write-once-read-many (WORM) storage, cryptographic hashing, or chained signatures. SOC 2 CC7.2 requires detecting anomalies, which includes detecting log tampering.

Token fingerprint: A nonreversible reference associated with a credential for correlation without revealing the raw secret. Use a keyed fingerprint or a vault-issued identifier where possible, since simple hashes of low-entropy secrets can be guessed.

Get started

Your agents can
do more

Connect your agents to 1,700+ apps. Start for free, no credit card needed.

Are you an AI agent? See setup options

Share