Class McpAuditEvent
Truncation keeps integrity even when it loses content
A payload longer than the configured cap is cut, but the event still carries the full byte size and a SHA-256 of the whole payload, and sets a truncated flag. A clipped record is weak evidence on its own — "we logged the response, but not the part you are asking about" — so truncation here costs readability rather than integrity, and nobody can mistake a cut record for a complete one.
Values are not recorded by default
At McpAuditSinks.Level.NAMES only argument names appear, which is what the diagnostic
McpCallRecord line has always done. Recording values makes this object carry production
data, and the retention, encryption and erasure obligations that come with it. That is a deliberate
decision for the deployment to take, not a default.
Copyright 2003-2026 ATB Consultancy Services Ltd
(formerly Orinda Software Ltd, Dublin, Ireland)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringWho may reach which config changed.static final StringAn account was created, removed, promoted or demoted, or had its password reset.static final Stringstatic final Stringstatic final StringA config was written or removed.static final StringA successful sign-in.static final StringA refused sign-in — the record that matters most, and the one an attack leaves behind.static final StringA sign-out.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe attempt was refused. -
Method Summary
Modifier and TypeMethodDescriptionThe config the request named, or null.longgetId()Unique per call.The JSON-RPC method, or the HTTP method when the request had no body.Why an authentication attempt was refused, from the fixed vocabulary, or null.Where the authentication attempt came from, or null.intThe HTTP status returned to the caller, or 0 when this was not a proxied request.What an administrative action acted on, or null.longgetUser()The authenticated account, or null — always null on an event a generated server built.booleanstatic McpAuditEventof(String theToolNameValue, Map<String, Object> theArgumentsValue, String theOutcomeValue, long theDurationValue, String theResponseValue, McpAuditSinks.Level theLevel, int theMaxBytes) Build an event, applying the level and the truncation cap.static McpAuditEventofAccess(String theUserValue, String theConfigValue, String theOperationValue, String theToolNameValue, String theOutcomeValue, int theStatusValue, long theDurationValue) Build the record for one request through the MCP proxy.static McpAuditEventofAdmin(String theActor, String theOperation, String theTargetValue, String theOutcomeValue, String theSourceValue) Build an administrative record: who did what, to what.static McpAuditEventofAuth(String theUserValue, String theOperationValue, String theOutcomeValue, String theSourceValue, String theReasonValue) Build an authentication record.static McpAuditEventWrap an already-serialised record, for replay from a spool.toJson()The event as JSON — the payload a sink writes.
-
Field Details
-
OP_LOGIN
-
OP_LOGIN_FAILED
A refused sign-in — the record that matters most, and the one an attack leaves behind.- See Also:
-
OP_LOGOUT
-
OUTCOME_DENIED
-
OP_ACCOUNT_CREATED
An account was created, removed, promoted or demoted, or had its password reset.- See Also:
-
OP_ACCOUNT_DELETED
- See Also:
-
OP_ROLE_CHANGED
- See Also:
-
OP_PASSWORD_RESET
- See Also:
-
OP_TOKEN_ISSUED
- See Also:
-
OP_TOKEN_REVOKED
- See Also:
-
OP_ACCESS_CHANGED
-
OP_CONFIG_SAVED
A config was written or removed. A config decides which objects are reachable AT ALL.- See Also:
-
OP_CONFIG_DELETED
- See Also:
-
-
Method Details
-
ofAccess
public static McpAuditEvent ofAccess(String theUserValue, String theConfigValue, String theOperationValue, String theToolNameValue, String theOutcomeValue, int theStatusValue, long theDurationValue) Build the record for one request through the MCP proxy.No arguments and no response: those belong to the tool call itself and the generated server records them. This half answers who asked, for what, and whether they were allowed.
- Parameters:
theUserValue- the authenticated account, or null when the request had nonetheConfigValue- the config named in the paththeOperationValue- the JSON-RPC method, or the HTTP method when there is no bodytheToolNameValue- the tool named by atools/call, otherwise nulltheStatusValue- the HTTP status returned to the caller
-
ofAdmin
public static McpAuditEvent ofAdmin(String theActor, String theOperation, String theTargetValue, String theOutcomeValue, String theSourceValue) Build an administrative record: who did what, to what.These matter at least as much as the sign-in records beside them. An account created, a role granted or an access-matrix row changed alters WHO CAN REACH WHAT, and a config decides which database objects are reachable at all — curation here is enforced by absence from the generated binary, so changing a config changes the reachable surface. None of it was recorded anywhere before.
- Parameters:
theActor- the signed-in account performing the actiontheOperation- one of theOP_constants abovetheTargetValue- what was acted on: an account name, a config name, or nulltheOutcomeValue-okorOUTCOME_DENIEDtheSourceValue- the remote address, or null
-
ofAuth
public static McpAuditEvent ofAuth(String theUserValue, String theOperationValue, String theOutcomeValue, String theSourceValue, String theReasonValue) Build an authentication record.Answers the question the tool-call records cannot: when an account signed in, from where, and how many times it failed first. A run of failures is often the only trace an attack leaves, which is why
OP_LOGIN_FAILEDis recorded at least as carefully as a success.Nothing derived from the submitted credential may be passed here.
theReasonis a fixed vocabulary chosen by the caller from the authentication exception's TYPE, never its message and never the failedAuthenticationobject, which in Spring Security can still hold the password that was tried.- Parameters:
theUserValue- the account name as submitted; may be an attacker's invention, so it is recorded as given and never trusted as an identitytheOperationValue-OP_LOGIN,OP_LOGIN_FAILEDorOP_LOGOUTtheOutcomeValue-okorOUTCOME_DENIEDtheSourceValue- the remote address, or null when it cannot be determinedtheReasonValue- why it was refused, from the fixed vocabulary; null on success
-
ofRawJson
Wrap an already-serialised record, for replay from a spool.- Parameters:
theRawJsonValue- the exact line that was written to disk
-
of
public static McpAuditEvent of(String theToolNameValue, Map<String, Object> theArgumentsValue, String theOutcomeValue, long theDurationValue, String theResponseValue, McpAuditSinks.Level theLevel, int theMaxBytes) Build an event, applying the level and the truncation cap.- Parameters:
theArgumentsValue- the call's arguments; only the keys are used belowMcpAuditSinks.Level.VALUEStheResponseValue- the response payload, or nulltheMaxBytes- cap for the recorded response, or 0 for no cap
-
getId
Unique per call.Present because spooled delivery is at-least-once: a crash between delivering a segment and deleting it replays that segment, so a consumer sees the record twice. Without an identity there is no way to collapse the duplicate, which would make the guarantee unusable rather than merely imperfect.
-
getTimestampMillis
public long getTimestampMillis() -
getToolName
-
getOutcome
-
getDurationMillis
public long getDurationMillis() -
getArguments
-
getResponse
-
isResponseTruncated
public boolean isResponseTruncated() -
getUser
The authenticated account, or null — always null on an event a generated server built. -
getConfig
The config the request named, or null. -
getOperation
The JSON-RPC method, or the HTTP method when the request had no body. Null when unknown. -
getStatus
public int getStatus()The HTTP status returned to the caller, or 0 when this was not a proxied request. -
toJson
The event as JSON — the payload a sink writes.An extension of
McpCallRecord's shape rather than a second format, so a log line and a queue message describe the same call the same way. -
getTarget
What an administrative action acted on, or null. -
getSource
Where the authentication attempt came from, or null. -
getReason
Why an authentication attempt was refused, from the fixed vocabulary, or null.
-