get_my_audit_logs
Retrieve your audit logs from the JSON Database Server using JWT authentication. View recent activity records to monitor access and track changes in your account.
Instructions
Kullanıcının kendi audit loglarını getirir
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | JWT token | |
| limit | No | Gösterilecek log sayısı (varsayılan: 50) |
Implementation Reference
- src/index.js:776-810 (handler)Main execution logic for get_my_audit_logs tool: token validation, permission check, fetch user-specific audit logs, log the access, format and return response.case 'get_my_audit_logs': { const { token, limit = 50 } = args; try { const user = checkPermissionWithToken(token, PERMISSIONS.AUDIT_READ); const logs = await getUserAuditLogs(user.userId, limit); // Kendi audit log erişimini logla await auditLogger.dataAccessed(user.userId, user.role, 'my_audit_logs', { limit }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, data: logs, total: logs.length, requestedBy: { id: user.userId, role: user.role }, note: 'Kendi audit loglarınız gösteriliyor' }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message, requiredPermission: PERMISSIONS.AUDIT_READ }) }] }; } }
- src/index.js:306-316 (registration)Tool registration in the ListTools response, including name, description, and input schema.name: 'get_my_audit_logs', description: 'Kullanıcının kendi audit loglarını getirir', inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, limit: { type: 'number', description: 'Gösterilecek log sayısı (varsayılan: 50)' } }, required: ['token'] } },
- src/audit.js:121-132 (helper)Helper function that reads audit logs from JSON file, filters by specific userId, applies limit, sorts by time descending.export async function getUserAuditLogs(userId, limit = 50) { try { const auditData = await readAuditLogs(); return auditData.logs .filter(log => log.userId === userId) .slice(-limit) .reverse(); } catch (error) { console.error('Kullanıcı audit log hatası:', error); return []; } }