Skip to main content
Glama
yusuferenkt

MCP JSON Database Server

by yusuferenkt

get_audit_logs_by_date

Retrieve audit logs within a specified date range for administrative monitoring and security analysis in the JSON Database Server.

Instructions

Belirli tarih aralığındaki audit logları getirir (Admin/Manager)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenYesJWT token
startDateYesBaşlangıç tarihi (YYYY-MM-DD)
endDateYesBitiş tarihi (YYYY-MM-DD)
limitNoGösterilecek log sayısı (varsayılan: 100)

Implementation Reference

  • Handler for 'get_audit_logs_by_date' tool: validates token and permissions, checks date formats, calls getAuditLogsByDateRange helper, logs access, returns filtered logs.
    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
            })
          }]
        };
      }
    }
  • Input schema definition and registration for the 'get_audit_logs_by_date' tool in the tools list.
      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']
      }
    },
  • Helper function that filters and retrieves audit logs by date range from the audit log data file.
    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 [];
      }
    }

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