verify_log
Verify the integrity of hash-chained audit logs to detect tampering in the Nobulex MCP Compliance Server.
Instructions
Independently verify the integrity of the hash-chained audit log. Detects any tampering.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:99-114 (registration)The verify_log tool is registered in src/index.ts. The handler calls auditLog.verify().
server.tool( "verify_log", "Independently verify the integrity of the hash-chained audit log. Detects any tampering.", {}, async () => { const result = auditLog.verify(); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2), }, ], }; } ); - src/audit.ts:59-91 (handler)The implementation of verify() which performs the integrity check on the audit log.
verify(): { valid: boolean; entries: number; error?: string } { if (this.entries.length === 0) { return { valid: true, entries: 0 }; } for (let i = 0; i < this.entries.length; i++) { const entry = this.entries[i]; // Check previousHash linkage const expectedPrev = i === 0 ? GENESIS_HASH : this.entries[i - 1].hash; if (entry.previousHash !== expectedPrev) { return { valid: false, entries: this.entries.length, error: `Entry ${i}: previousHash mismatch.`, }; } // Recompute hash const { hash, ...rest } = entry; const recomputed = computeHash(rest); if (recomputed !== hash) { return { valid: false, entries: this.entries.length, error: `Entry ${i}: hash mismatch (tampering detected).`, }; } } return { valid: true, entries: this.entries.length }; }