Skip to main content
Glama

gate_stats

Retrieve gate enforcement statistics including blocked and warned counts with top gate insights to monitor access control patterns.

Instructions

Get gate enforcement statistics -- blocked count, warned count, top gates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The calculateStats function processes gate definitions (manual and auto-promoted) and computes statistics like block counts, warnings, top blocked gate, and estimated time saved.
    function calculateStats() {
      const autoGatesPath = getAutoGatesPath();
      const manualGates = loadGatesFile(MANUAL_GATES_PATH);
      const autoGates = loadGatesFile(autoGatesPath);
      const allGates = [...manualGates, ...autoGates];
    
      let autoPromotedData = { promotionLog: [] };
      if (fs.existsSync(autoGatesPath)) {
        try { autoPromotedData = JSON.parse(fs.readFileSync(autoGatesPath, 'utf-8')); } catch {}
      }
      const promotionLog = autoPromotedData.promotionLog || [];
    
      const blockGates = allGates.filter((g) => g.action === 'block');
      const warnGates = allGates.filter((g) => g.action === 'warn');
    
      // Count total blocks/warns from occurrences in auto-promoted gates
      const totalBlocked = autoGates
        .filter((g) => g.action === 'block')
        .reduce((sum, g) => sum + (g.occurrences || 0), 0);
      const totalWarned = autoGates
        .filter((g) => g.action === 'warn')
        .reduce((sum, g) => sum + (g.occurrences || 0), 0);
    
      // Top blocked gate
      const topBlocked = [...allGates]
        .sort((a, b) => (b.occurrences || 0) - (a.occurrences || 0))
        .find((g) => g.action === 'block') || null;
    
      // Last promotion event
      const lastPromotion = promotionLog.length > 0
        ? promotionLog[promotionLog.length - 1]
        : null;
    
      // Time saved estimate: ~15 min per blocked mistake
      const estimatedMinutesSaved = (totalBlocked + totalWarned) * 15;
      const estimatedHoursSaved = (estimatedMinutesSaved / 60).toFixed(1);
    
      return {
        totalGates: allGates.length,
        manualGates: manualGates.length,
        autoPromotedGates: autoGates.length,
        blockGates: blockGates.length,
        warnGates: warnGates.length,
        totalBlocked,
        totalWarned,
        topBlocked,
        lastPromotion,
        estimatedHoursSaved,
        gates: allGates,
      };
    }
  • The MCP tool handler calls loadGateStats (from gates-engine) and returns the result as a text result for the "gate_stats" tool.
    case 'gate_stats':
      return toTextResult(loadGateStats());
  • CLI command "gate-stats" triggers the gate statistics reporting logic.
    case 'gate-stats':
      gateStats();
      break;

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/IgorGanapolsky/mcp-memory-gateway'

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