Optionaloptions: AuditLoggerOptionsPrivate ReadonlyextraPrivate ReadonlymemoryPrivate ReadonlyrequiredPrivate ReadonlyretentionPrivate ReadonlysensitivePrivatecheckOptionalauthorization: stringRemoves all audit entries associated with userId from in-memory storage.
GDPR Article 17 — Right to Erasure. Only removes entries from the
in-memory MemoryAuditSink; entries already flushed to persistent sinks
(files, SIEM, etc.) must be erased separately via those sinks.
The user whose entries should be erased
Optionalauthorization: stringAuthorization token (required when configured)
Returns a snapshot of all in-memory audit log entries, optionally filtered by the configured data-retention policy.
When requiredAuthToken was set in the constructor, authorization must
match; otherwise an Error is thrown.
Optionalauthorization: stringAuthorization token (required when configured)
Entries ordered oldest-first, filtered by retention policy
Logs an audit event to the in-memory store and all configured sinks.
Parameter values matching sensitiveKeys are automatically replaced by
'[REDACTED]' before storage.
Audit log entry without a timestamp (generated automatically)
Logs a successful data-access event (e.g. a query returning records).
Action name (e.g. 'get_meps', 'get_committee_meetings')
Query parameters (sanitised automatically)
Number of records returned
Optionalduration: numberOptional wall-clock duration in milliseconds
Logs a failed operation as an audit error event.
Action name
Parameters supplied to the failed operation (sanitised)
Human-readable error message (must not contain secrets)
Optionalduration: numberOptional wall-clock duration in milliseconds
Log an MCP tool call as an audit record.
The tool's params are sanitised before being wrapped in the entry so
that PII in top-level tool parameter keys is redacted. Nested objects are
not recursively sanitised.
Name of the MCP tool that was invoked
Tool input parameters (sanitised automatically)
Whether the tool call completed without error
Optionalduration: numberOptional wall-clock duration in milliseconds
Optionalerror: stringOptional error message if the call failed
PrivatepruneQueries the in-memory log using a filter.
Field-based filter to apply
Optionalauthorization: stringAuthorization token (required when configured)
PrivatewritePrivate Staticbuild
GDPR-compliant audit logger with pluggable sinks, parameter sanitisation, data retention enforcement, and access-controlled log retrieval.
Pluggable sinks
By default the logger writes to an in-memory buffer (queryable via
getLogs()) and tostderr(MCP-compatible). Pass asinksoption to replace the default stderr sink with your own destinations (e.g.FileAuditSink,StructuredJsonSink).Parameter sanitisation
All
paramsobjects are passed throughsanitizeParams()before storage. Only top-level keys matchingsensitiveKeys(default:DEFAULT_SENSITIVE_KEYS) are replaced by'[REDACTED]'to prevent PII leakage into audit trails. Nested objects/arrays are not recursively sanitised; callers must avoid placing PII in nested structures or pre-sanitise such data before logging.Data retention
When
retentionMsis set,getLogs()automatically filters out entries older than the configured maximum age (GDPR Article 5(1)(e)).Access control
When
requiredAuthTokenis set,getLogs(),queryLogs(),clear(), anderaseByUser()throw if the caller does not supply the correct token.Example: Basic usage (backward-compatible)
Example: With file sink and 30-day retention
Since
0.8.0