dhis2_get_audit_summary
Retrieve summary statistics for audit logs and system usage to monitor activity and track performance in DHIS2 health information systems.
Instructions
Get summary statistics of audit log and system usage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1423-1459 (handler)Main handler for the 'dhis2_get_audit_summary' tool. Retrieves audit summary from auditLogger, adds session info, logs the call, and returns formatted text response.case 'dhis2_get_audit_summary': const summary = auditLogger.getAuditSummary(); const permissionSummary = PermissionSystem.getPermissionSummary(userPermissions); auditLogger.log({ toolName: name, parameters: {}, outcome: 'success', dhis2Instance: dhis2Client?.baseURL, userId: currentUser?.username, executionTime: Date.now() - startTime }); return { content: [{ type: 'text', text: `š DHIS2 MCP Server Audit Summary š¢ **Usage Statistics:** ⢠Total Operations: ${summary.totalOperations} ⢠Successful: ${summary.successCount} (${Math.round((summary.successCount / summary.totalOperations) * 100) || 0}%) ⢠Errors: ${summary.errorCount} (${Math.round((summary.errorCount / summary.totalOperations) * 100) || 0}%) š¤ **Current Session:** ⢠User: ${currentUser?.displayName || 'Unknown'} ⢠Permission Level: ${permissionSummary.level} ⢠Available Tools: ${PermissionSystem.filterToolsByPermissions(tools, userPermissions).length} of ${tools.length} ⢠Connected to: ${dhis2Client?.baseURL || 'Not connected'} š ļø **Most Used Tools:** ${summary.mostUsedTools.slice(0, 5).map(tool => ` ⢠${tool.tool}: ${tool.count} times`).join('\n') || ' ⢠No operations yet'} ${summary.recentErrors.length > 0 ? `ā ļø **Recent Errors:** ${summary.recentErrors.slice(0, 3).map(error => ` ⢠${error.toolName}: ${error.error}`).join('\n')}` : 'ā No recent errors'}` }] };
- src/audit-logger.ts:67-96 (helper)Core getAuditSummary method in AuditLogger class that computes statistics: total ops, success/error counts, most used tools, recent errors.getAuditSummary(): { totalOperations: number; successCount: number; errorCount: number; mostUsedTools: Array<{ tool: string; count: number }>; recentErrors: AuditEntry[]; } { const toolUsage = new Map<string, number>(); this.entries.forEach(entry => { toolUsage.set(entry.toolName, (toolUsage.get(entry.toolName) || 0) + 1); }); const mostUsedTools = Array.from(toolUsage.entries()) .map(([tool, count]) => ({ tool, count })) .sort((a, b) => b.count - a.count) .slice(0, 10); const recentErrors = this.entries .filter(entry => entry.outcome === 'error') .slice(-5); return { totalOperations: this.entries.length, successCount: this.getSuccessCount(), errorCount: this.getErrorCount(), mostUsedTools, recentErrors }; }
- src/audit-logger.ts:110-112 (helper)Global singleton instance of AuditLogger used by all tools including dhis2_get_audit_summary.} // Global audit logger instance