Skip to main content
Glama

get_all_audit_logs

Retrieve all audit logs from the MCP JSON Database Server using a JWT token. Specify the log limit for customized results (default: 200). Accessible only by admin users for comprehensive audit tracking.

Instructions

Tüm audit logları getirir (Sadece admin)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoGösterilecek log sayısı (varsayılan: 200)
tokenYesJWT token

Implementation Reference

  • Core handler function that reads the audit logs JSON file and returns the last 'limit' (default 200) logs in reverse chronological order (newest first). This is the primary implementation of the tool logic.
    export async function getAllAuditLogs(limit = 200) { try { const auditData = await readAuditLogs(); return auditData.logs .slice(-limit) .reverse(); } catch (error) { console.error('Tüm audit log hatası:', error); return []; } }
  • src/index.js:318-328 (registration)
    Tool registration in the ListTools response, including name, description, and input schema definition for validation.
    name: 'get_all_audit_logs', description: 'Tüm audit logları getirir (Sadece admin)', inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, limit: { type: 'number', description: 'Gösterilecek log sayısı (varsayılan: 200)' } }, required: ['token'] } },
  • MCP CallToolRequestSchema handler case for 'get_all_audit_logs': performs token verification, permission check (requires AUDIT_READ_ALL for admin), calls the core getAllAuditLogs helper, audits the sensitive access, and returns properly formatted MCP content response.
    case 'get_all_audit_logs': { const { token, limit = 200 } = args; try { const user = checkPermissionWithToken(token, PERMISSIONS.AUDIT_READ_ALL); const logs = await getAllAuditLogs(limit); // Tüm audit log erişimini logla (kritik) await auditLogger.sensitiveDataAccessed(user.userId, user.role, 'all_audit_logs', { limit }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, data: logs, total: logs.length, requestedBy: { id: user.userId, role: user.role }, warning: 'Bu tüm sistem audit loglarını içerir - Gizli bilgiler içerebilir' }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message, requiredPermission: PERMISSIONS.AUDIT_READ_ALL, note: 'Tüm audit loglar sadece admin tarafından görüntülenebilir' }) }] }; } }
  • Supporting helper function used by getAllAuditLogs to safely read the audit_logs.json file, handling missing file gracefully.
    async function readAuditLogs() { try { const data = await fs.readFile(AUDIT_LOG_PATH, 'utf8'); return JSON.parse(data); } catch (error) { if (error.code === 'ENOENT') { // Dosya yoksa boş array döndür return { logs: [] }; } console.error('Audit log okuma hatası:', error); return { logs: [] }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yusuferenkt/mcp-database'

If you have feedback or need assistance with the MCP directory API, please join our Discord server