UNPKG

mcp-wayback-machine

Version:

MCP server and CLI tool for interacting with the Wayback Machine without API keys

46 lines 1.51 kB
/** * Rate limiting for Wayback Machine API requests. * * RateLimitBackend defines the consumer interface (just acquire()). * InMemoryRateLimiter implements it for single-process use (stdio mode). * Worker deployments use a Durable Object backend (see rate-limit-do.ts). */ /** * Consumer interface for rate limiting. Consumers call acquire() before * making a request; it resolves when a slot is available. */ export interface RateLimitBackend { acquire(): Promise<void>; } interface RateLimitOptions { maxRequests: number; windowMs: number; } /** * In-memory rate limiter using a sliding window of request timestamps. * Suitable for single-process use (stdio mode) where all requests share * the same heap. */ export declare class InMemoryRateLimiter implements RateLimitBackend { private requests; private readonly maxRequests; private readonly windowMs; constructor(options: RateLimitOptions); canMakeRequest(): boolean; waitForSlot(): Promise<void>; recordRequest(): void; /** * Wait for a slot, then reserve it. waitForSlot() guarantees that * canMakeRequest() returned true immediately before it resolved, * so we can record immediately. */ acquire(): Promise<void>; private cleanup; } /** * Default rate limiter for stdio mode — conservative limits to be * respectful of the Internet Archive service. */ export declare const waybackRateLimiter: RateLimitBackend; export {}; //# sourceMappingURL=rate-limit.d.ts.map