Skip to main content
All audit endpoints require an authenticated administrator and operate only when MCPHub is running in PostgreSQL database mode. When routing.skipAuth is enabled for local development, unauthenticated requests inherit the synthetic admin identity (actorVia: "skip-auth"), as documented in Authentication — never enable skipAuth in production.

GET /api/audit/available

Check whether configuration audit logging is enabled.

GET /api/audit

List audit events using keyset cursor pagination and metadata filters.

DELETE /api/audit/cleanup

Prune audit events older than the configured or specified retention window.

Check Audit Availability

Checks whether PostgreSQL audit logging is active for the current deployment.
  • Endpoint: /api/audit/available
  • Method: GET
  • Access: Admin only (403 for non-admin callers)
  • Success Response:

Query Audit Events

Returns configuration and access audit events ordered from newest to oldest (occurredAt DESC, id DESC) using keyset cursor pagination. Returns 404 when running in file mode.
  • Endpoint: /api/audit
  • Method: GET
  • Access: Admin only
  • Query Parameters:
    • limit (optional, integer 1–100, default 50): Number of events per page.
    • cursor (optional, opaque string): pagination.nextCursor returned by a previous response.
    • actor (optional, string): Exact actorUsername match.
    • actionPrefix (optional, string): Prefix filter on action (e.g. server., group., key., config.).
    • targetType (optional, enum): One of server, group, bearer_key, user, system_config, template.
    • targetId (optional, string): Exact targetId match.
    • startDate (optional, ISO 8601 date string): Inclusive lower bound for occurredAt.
    • endDate (optional, ISO 8601 date string): Inclusive upper bound for occurredAt.
  • Success Response:

Clean Up Expired Audit Events

Deletes audit events older than the configured retention period (system_config.audit.retentionDays, default 365) or an explicit days override. Uses a PostgreSQL transaction advisory lock and batched deletes so multi-replica deployments do not contend on cleanup.
  • Endpoint: /api/audit/cleanup
  • Method: DELETE
  • Access: Admin only
  • Query Parameters:
    • days (optional, integer 1–3650): Override the configured audit.retentionDays for this cleanup run.
  • Success Response:
  • Conflict Response (409): Returned when another worker already holds the cleanup advisory lock (data.skipped === true, deletedCount === 0).