get_audit_logs_by_date
Retrieve audit logs within a specified date range using a JWT token for admin or manager access on MCP JSON Database Server.
Instructions
Belirli tarih aralığındaki audit logları getirir (Admin/Manager)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endDate | Yes | Bitiş tarihi (YYYY-MM-DD) | |
| limit | No | Gösterilecek log sayısı (varsayılan: 100) | |
| startDate | Yes | Başlangıç tarihi (YYYY-MM-DD) | |
| token | Yes | JWT token |
Implementation Reference
- src/audit.js:137-154 (handler)Core handler function that reads audit logs, filters by date range (startDate to endDate), applies limit, and returns the logs.export async function getAuditLogsByDateRange(startDate, endDate, limit = 100) { try { const auditData = await readAuditLogs(); const start = new Date(startDate); const end = new Date(endDate); return auditData.logs .filter(log => { const logDate = new Date(log.timestamp); return logDate >= start && logDate <= end; }) .slice(-limit) .reverse(); } catch (error) { console.error('Tarih aralığı audit log hatası:', error); return []; } }
- src/index.js:343-354 (schema)Input schema definition for the tool, specifying required parameters: token, startDate, endDate, and optional limit.name: 'get_audit_logs_by_date', description: 'Belirli tarih aralığındaki audit logları getirir (Admin/Manager)', inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, startDate: { type: 'string', description: 'Başlangıç tarihi (YYYY-MM-DD)' }, endDate: { type: 'string', description: 'Bitiş tarihi (YYYY-MM-DD)' }, limit: { type: 'number', description: 'Gösterilecek log sayısı (varsayılan: 100)' } }, required: ['token', 'startDate', 'endDate'] }
- src/index.js:901-952 (registration)MCP server tool dispatcher case that handles the tool call: checks permissions, validates dates, invokes the core handler, logs access, and formats response.case 'get_audit_logs_by_date': { const { token, startDate, endDate, limit = 100 } = args; try { const user = checkPermissionWithToken(token, PERMISSIONS.AUDIT_READ); // Tarih format kontrolü const start = new Date(startDate); const end = new Date(endDate); if (isNaN(start.getTime()) || isNaN(end.getTime())) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Geçersiz tarih formatı. YYYY-MM-DD formatını kullanın' }) }] }; } const logs = await getAuditLogsByDateRange(startDate, endDate, limit); // Tarih bazlı audit log erişimini logla await auditLogger.dataAccessed(user.userId, user.role, 'audit_logs_by_date', { startDate, endDate, limit }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, data: logs, dateRange: { startDate, endDate }, total: logs.length, requestedBy: { id: user.userId, role: user.role } }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message, requiredPermission: PERMISSIONS.AUDIT_READ }) }] }; } }
- src/index.js:36-44 (registration)Imports the getAuditLogsByDateRange handler function and related audit utilities from audit.js.import { auditLogger, getAllAuditLogs, getUserAuditLogs, getAuditLogsByCategory, getAuditLogsByDateRange, AUDIT_CATEGORIES, AUDIT_LEVELS } from './audit.js';