UNPKG

@orengrinker/jira-mcp-server

Version:

A comprehensive Model Context Protocol server for Jira integration with issue management, board operations, time tracking, and project management capabilities

32 lines (25 loc) 929 B
export class RateLimiter { private requests: number[] = []; private maxRequests: number; private windowMs: number; constructor(maxRequests = 100, windowMs = 60000) { this.maxRequests = maxRequests; this.windowMs = windowMs; } async waitForSlot(): Promise<void> { const now = Date.now(); // Remove old requests outside the window this.requests = this.requests.filter(time => now - time < this.windowMs); // If we're at the limit, wait if (this.requests.length >= this.maxRequests) { const oldestRequest = Math.min(...this.requests); const waitTime = this.windowMs - (now - oldestRequest) + 100; // Add 100ms buffer if (waitTime > 0) { await new Promise(resolve => setTimeout(resolve, waitTime)); return this.waitForSlot(); // Recursive call to check again } } // Add current request this.requests.push(now); } }