Skip to content

MCP audit logging and SIEM export

Every component of the platform (gateway, credential broker, portal and each MCP server built on the starter) writes one JSON object per line to standard output for every audit event. The platform does not store, index, sign or rotate these lines. Keeping, searching and protecting them is the job of your log system.

For the list of events, the administration reasons and the Audit logs page of the portal, see Read the audit trail.

Component component componentId Logger
Gateway gateway mcp-gateway AUDIT
Credential broker broker mcp-credential-broker AUDIT
Portal portal mcp-portal-bff pl.aiwcorpo.mcp.audit
MCP server server its server id, for example mcp-jira pl.aiwcorpo.mcp.audit

The audit logger has its own console appender with the pattern %msg%n: the line is the JSON object and nothing else, with no timestamp or level in front. The same stream also carries ordinary application logs, which are plain text (Spring Boot’s console format in the gateway, broker and portal, and <time> <level> [<requestId>] <logger> - <message> in servers). A collector therefore has to pick the audit lines out of the stream: a line that parses as a JSON object and has event and requestId is an audit event.

Each component escapes every character above ASCII as \uXXXX, so a line cannot be split by U+2028 or U+2029, and Polish letters in a resource id arrive as escapes such as \u0142. Any JSON parser turns them back.

The gateway also keeps the events of each user’s own calls for the Audit logs page, 30 days by default (MCP_ACTIVITY_RETENTION). That store is for users, not a copy of the audit stream: it holds only tool_call, policy_decision and confirmation.

The schema is audit-event.schema.json in the contracts, with additionalProperties: false. A field that is not in this table cannot appear in a line.

Field Present Content
ts always UTC time with milliseconds, for example 2026-11-13T09:41:07.312Z
requestId always UUIDv7 of the request, shared by all lines of one call in every component
component, componentId always See the table above
event always tool_call, policy_decision, credential_resolve, connection_change, confirmation, admin_change, authentication, authenticator
clientRequestId gateway, when the client sent X-Request-Id Only if it matches ^[A-Za-z0-9._:-]{1,128}$; otherwise dropped
sub when a user is known sub claim of the token
username when a user is known preferred_username claim
client calls from an AI client azp claim, the client id (for example claude-code)
filter requests with an address filter Canonical query of the /mcp filter, for example systems=jira&access=read
server events about a server or system mcp-<system>. On broker events it names the target system
tool tool events Server-side tool name without the system prefix: get_issue, not jira__get_issue
risk tool events READ_ONLY, UPDATE, DESTRUCTIVE
resource when a resource is resolved Object {type, id, parent}, for example {"type": "Jira::Issue", "id": "ABC-123", "parent": "Jira::Project::HR"}
decision decisions allow, deny, confirmation_pending
reason refusals, admin changes, credential problems Snake case, at most 64 characters, for example not_granted, policy_forbid, kill_switch, rate_limited_user
policyRevision gateway and server decisions Revision of the policy data the decision used
credentialType credential events user-oauth, user-secret, token-exchange, service-account
outcome most events ok, error, denied
errorCode with outcome The code the client saw (access_denied, not_found_or_denied, rate_limited and so on) or null
latencyMs tool_call and some others Integer milliseconds
argsLength tool events Length in bytes of the serialized arguments
backendUser connection_change The account in the target system the user connected
suppressedCount, suppressedTargets gateway summary of throttled refusals How many refusals were left out of the audit in the window, and how many different targets they had
action, group, overrideId, overrideTarget, textSha256, textSha256Before, changedFields, definitionHash, tlsMode, fingerprint admin_change only See What administration changes record

A tool call allowed by the gateway, as it appears on standard output (wrapped here for reading):

{"ts":"2026-11-13T09:41:07.312Z","requestId":"019a7c3e-2f41-7b10-9c55-3e2d1a0b4c77",
"component":"gateway","componentId":"mcp-gateway","event":"tool_call",
"sub":"6f1c2a9e-4d4b-4c51-9a53-1e0f0c7d2b11","username":"jkowalski","client":"claude-code",
"server":"mcp-jira","tool":"get_issue","risk":"READ_ONLY","decision":"allow",
"policyRevision":41,"credentialType":"user-secret","outcome":"ok","errorCode":null,
"latencyMs":42,"argsLength":118}

On a call that the gateway allowed and the target system then refused, decision is allow and outcome is denied. And when the AI client presents a token that the gateway rejects, the authentication event carries no sub, client or token, only the rejection code in reason.

The event builders accept only schema fields, so there is no method that could put these into a line:

  • argument values and tool results (only argsLength);
  • tokens, credentials, OAuth secrets and service account keys;
  • confirmation codes, TOTP codes, authenticator seeds and otpauth:// URIs;
  • the free text an administrator types as the reason of an emergency switch;
  • the Cedar text of an override (only its SHA-256 in textSha256);
  • the values of changed server fields (only their names in changedFields).

What the lines do contain is personal data: sub, username, backendUser and resource ids such as an issue key or a page id. Plan retention and access to the index with that in mind.

Repeated refusals of the same kind are throttled per user, reason and target to one event every 10 seconds (MCP_RATE_LIMIT_AUDIT_INTERVAL), followed by a summary with suppressedCount. Do not build a counting alert on raw refusal events: add suppressedCount to the count, or alert on the summary itself.

The Compose bundle sets no logging options, so Docker uses its default driver, normally json-file, which by default does not rotate. Set max-size and max-file in /etc/docker/daemon.json so the disk does not fill, and make sure the collector reads faster than the files rotate: a line that is rotated away before it is read is lost, and the platform has no second copy.

The example below uses Vector, which reads container logs through the Docker API. Fluent Bit, Filebeat or Grafana Alloy can do the same: read the container stream, keep the lines that parse as JSON with event and requestId, forward them unchanged. Compose names containers <project>-<service>-<n>, so the bundle gives mcp-platform-gateway-1, mcp-platform-mcp-credential-broker-1 and mcp-platform-portal-1. Add the containers of your MCP servers from their own Compose projects.

sources:
mcp_containers:
type: docker_logs
include_containers:
- mcp-platform-gateway-
- mcp-platform-mcp-credential-broker-
- mcp-platform-portal-
- <server-container-prefix>
transforms:
mcp_audit:
type: remap
inputs: [mcp_containers]
drop_on_abort: true
source: |
parsed, err = parse_json(.message)
if err != null || !is_object(parsed) { abort }
audit = object!(parsed)
if !is_string(audit.event) || !is_string(audit.requestId) { abort }
audit.container_name = .container_name
audit.timestamp = .timestamp
. = audit

include_containers matches by prefix. Access to the Docker socket is equivalent to root on the host, so run the collector as a host service you trust, not inside the platform’s network.

Keep container_name in the event. An MCP server is a separate program, and a line that only looks like an audit event of the gateway is easy to print from any process. In the SIEM, accept component: gateway only from the gateway container, broker only from the broker, and a server’s componentId only from that server’s container.

Then add one sink.

OpenSearch or Elasticsearch, into a daily index of its own (an own index avoids a clash between the field event and the ECS object event of the built-in logs-* templates):

sinks:
siem:
type: elasticsearch
inputs: [mcp_audit]
endpoints: ["https://<search-host>:9200"]
mode: bulk
bulk:
index: "mcp-audit-%Y.%m.%d"
auth:
strategy: basic
user: mcp_audit_writer
password: "${MCP_AUDIT_WRITER_PASSWORD}"

Give the writer user the index privilege create_doc on mcp-audit-* and nothing else, so the collector can add events but not change or delete them. The platform does not sign or chain its events, so this is where tamper resistance comes from.

Splunk, through the HTTP Event Collector:

sinks:
siem:
type: splunk_hec_logs
inputs: [mcp_audit]
endpoint: "https://<splunk-host>:8088"
default_token: "${SPLUNK_HEC_TOKEN}"
index: mcp_audit
sourcetype: "mcp:audit"
encoding:
codec: json

Loki. Labels must have few values, so use component and event, which every line has, and never sub, requestId or resource:

sinks:
siem:
type: loki
inputs: [mcp_audit]
endpoint: "http://<loki-host>:3100"
labels:
component: "{{ component }}"
event: "{{ event }}"
encoding:
codec: json

Other fields stay in the line and are read at query time with the json parser. outcome is not a good label: some events have none, for example a confirmation with confirmation_pending.

KQL works in Kibana and in OpenSearch Dashboards (DQL). For Splunk the event is JSON, so spath extracts the fields. In Loki, the json parser flattens nested keys with an underscore (resource.id becomes resource_id).

Everything that happened in one call, in all components. The user gives you the Request ID from the Audit logs page:

KQL: requestId:"019a7c3e-2f41-7b10-9c55-3e2d1a0b4c77"
Splunk: index=mcp_audit "019a7c3e-2f41-7b10-9c55-3e2d1a0b4c77" | spath | sort ts | table ts component event decision reason outcome errorCode
LogQL: {component=~".+"} |= "019a7c3e-2f41-7b10-9c55-3e2d1a0b4c77" | json

Every tool a user called, and with which client:

KQL: event:tool_call and username:"jkowalski"
Splunk: index=mcp_audit | spath | search event=tool_call username=jkowalski | stats count by client server tool outcome
LogQL: sum by (server, tool) (count_over_time({event="tool_call"} | json | username="jkowalski" [24h]))

Destructive operations that went through:

KQL: event:tool_call and risk:DESTRUCTIVE and outcome:ok
Splunk: index=mcp_audit | spath | search event=tool_call risk=DESTRUCTIVE outcome=ok | table ts username server tool resource.id
LogQL: {event="tool_call"} | json | risk="DESTRUCTIVE" and outcome="ok"

Who touched one resource, for example a Jira issue (the resource is resolved by the server, so look at server events):

KQL: component:server and resource.id:"ABC-123"
Splunk: index=mcp_audit | spath | search component=server "resource.id"="ABC-123" | table ts username tool decision outcome
LogQL: {component="server"} | json | resource_id="ABC-123"

Administration changes in a period, with the administrator:

KQL: event:admin_change
Splunk: index=mcp_audit | spath | search event=admin_change | table ts username reason server tool definitionHash fingerprint
LogQL: {event="admin_change"} | json

A refusal sweep: one user probing many tools.

KQL: event:policy_decision and decision:deny and suppressedTargets >= 5
Splunk: index=mcp_audit | spath | search event=policy_decision decision=deny suppressedTargets>=5 | table ts username reason suppressedCount suppressedTargets
LogQL: {event="policy_decision"} | json | decision="deny" and suppressedTargets >= 5

Which account in the target system a user connected:

KQL: event:connection_change and username:"jkowalski"
Splunk: index=mcp_audit | spath | search event=connection_change username=jkowalski | table ts server credentialType backendUser reason
LogQL: {event="connection_change"} | json | username="jkowalski"

Rejected tokens or client certificates in a burst:

KQL: event:authentication
Splunk: index=mcp_audit | spath | search event=authentication | timechart span=5m count by reason
LogQL: sum by (component) (count_over_time({event="authentication"}[5m]))

The alerts worth wiring from these fields are listed in Alerts worth having.