Skip to main content
Glama
MIT License
27,120
19,789
  • Linux
  • Apple
rateLimit.ts•943 B
interface RateLimitEntry { count: number; resetTime: number; } export class RateLimiter { private limits: Map<string, RateLimitEntry> = new Map(); private readonly windowMs: number; private readonly maxRequests: number; constructor(windowMs = 60000, maxRequests = 10) { this.windowMs = windowMs; this.maxRequests = maxRequests; } isAllowed(identifier: string): boolean { const now = Date.now(); const entry = this.limits.get(identifier); if (!entry || now > entry.resetTime) { this.limits.set(identifier, { count: 1, resetTime: now + this.windowMs, }); return true; } if (entry.count >= this.maxRequests) { return false; } entry.count += 1; return true; } getRemainingTime(identifier: string): number { const entry = this.limits.get(identifier); if (!entry) return 0; return Math.max(0, entry.resetTime - Date.now()); } }

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/yamadashy/repomix'

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