@cyanheads/git-mcp-server
Version:
An MCP (Model Context Protocol) server enabling LLMs and AI agents to interact with Git repositories. Provides tools for comprehensive Git operations including clone, commit, branch, diff, log, status, push, pull, merge, rebase, worktree, tag management,
93 lines • 2.77 kB
TypeScript
import { RequestContext } from "../index.js";
/**
* Rate limiting configuration options
*/
export interface RateLimitConfig {
/** Time window in milliseconds */
windowMs: number;
/** Maximum number of requests allowed in the window */
maxRequests: number;
/** Custom error message template */
errorMessage?: string;
/** Whether to skip rate limiting in certain environments (e.g. development) */
skipInDevelopment?: boolean;
/** Custom key generator function */
keyGenerator?: (identifier: string, context?: RequestContext) => string;
/** How often to run cleanup of expired entries (in milliseconds) */
cleanupInterval?: number;
}
/**
* Individual rate limit entry
*/
export interface RateLimitEntry {
/** Current request count */
count: number;
/** When the window resets (timestamp) */
resetTime: number;
}
/**
* Generic rate limiter that can be used across the application
*/
export declare class RateLimiter {
private config;
/** Map storing rate limit data */
private limits;
/** Cleanup interval timer */
private cleanupTimer;
/** Default configuration */
private static DEFAULT_CONFIG;
/**
* Create a new rate limiter
* @param config Rate limiting configuration
*/
constructor(config: RateLimitConfig);
/**
* Start the cleanup timer to periodically remove expired entries
*/
private startCleanupTimer;
/**
* Clean up expired rate limit entries to prevent memory leaks
*/
private cleanupExpiredEntries;
/**
* Update rate limiter configuration
* @param config New configuration options
*/
configure(config: Partial<RateLimitConfig>): void;
/**
* Get current configuration
* @returns Current rate limit configuration
*/
getConfig(): RateLimitConfig;
/**
* Reset all rate limits
*/
reset(): void;
/**
* Check if a request exceeds the rate limit
* @param key Unique identifier for the request source
* @param context Optional request context
* @throws {McpError} If rate limit is exceeded
*/
check(key: string, context?: RequestContext): void;
/**
* Get rate limit information for a key
* @param key The rate limit key
* @returns Current rate limit status or null if no record exists
*/
getStatus(key: string): {
current: number;
limit: number;
remaining: number;
resetTime: number;
} | null;
/**
* Stop the cleanup timer when the limiter is no longer needed
*/
dispose(): void;
}
/**
* Create and export a default rate limiter instance
*/
export declare const rateLimiter: RateLimiter;
//# sourceMappingURL=rateLimiter.d.ts.map