/** * postgres-mcp — Audit Interceptor * * Wraps tool execution to produce audit entries for all tool * invocations. Write/admin tools are always logged; read-scoped * tools are logged only when `--audit-reads` is enabled. * * Each entry includes a `tokenEstimate` (~4 bytes per token) * computed from the serialized result size. * * When a BackupManager is provided, captures pre-mutation * snapshots of target objects before destructive tool execution. * * The interceptor is injected into `DatabaseAdapter.registerTool()` * so that all 248 tool handlers are audited without per-handler changes. */ import type { AuditLogger } from "./logger.js"; import type { BackupManager, SnapshotQueryAdapter } from "./backup-manager.js"; /** * Audit interceptor interface — used by `DatabaseAdapter.registerTool()`. */ export interface AuditInterceptor { /** * Wrap a tool invocation with audit logging. * Returns the tool result unchanged; re-throws any errors. * * @param toolName MCP tool name * @param args Tool input arguments * @param requestId Request ID from RequestContext * @param fn The actual tool handler to execute * @param options Optional configuration, such as overriding the recorded tool name */ around(toolName: string, args: unknown, requestId: string, fn: () => Promise, options?: { logAs?: string; }): Promise; } /** * Create an audit interceptor bound to the given logger. * * @param auditLogger The JSONL audit logger * @param backupManager Optional backup manager for pre-mutation snapshots * @param queryAdapter Optional query adapter for snapshot DDL capture */ export declare function createAuditInterceptor(auditLogger: AuditLogger, backupManager?: BackupManager, queryAdapter?: SnapshotQueryAdapter): AuditInterceptor; //# sourceMappingURL=interceptor.d.ts.map