get_my_audit_logs
Retrieve your audit logs from the MCP JSON Database Server using a JWT token and set a limit for the number of logs displayed.
Instructions
Kullanıcının kendi audit loglarını getirir
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Gösterilecek log sayısı (varsayılan: 50) | |
| token | Yes | JWT token |
Implementation Reference
- src/index.js:776-810 (handler)Main handler for the 'get_my_audit_logs' tool. Verifies user permissions via token, calls getUserAuditLogs helper, logs the access attempt, and returns the user's recent audit logs.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 (schema)Tool schema definition including input schema for token and optional limit, registered in the ListTools response.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, returns the most recent 'limit' logs in chronological order.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 []; } }