UNPKG

octocode-mcp

Version:

Model Context Protocol (MCP) server for advanced GitHub repository analysis and code discovery. Provides AI assistants with powerful tools to search, analyze, and understand codebases across GitHub.

53 lines (52 loc) 1.55 kB
/** * Fetch with retry mechanism and exponential backoff */ export interface FetchWithRetriesOptions { /** * Maximum number of retry attempts (excluding the initial request) * @default 3 */ maxRetries?: number; /** * Initial delay in milliseconds for exponential backoff * @default 1000 (1 second) */ initialDelayMs?: number; /** * Custom headers to include in the request */ headers?: Record<string, string>; /** * HTTP method * @default 'GET' */ method?: string; /** * Whether to include the package version as a query parameter * @default false */ includeVersion?: boolean; } /** * Fetches a URL with automatic retries and exponential backoff. * * Retry behavior: * - Retries on network errors, server errors (5xx), and rate limits (429) * - Respects 'Retry-After' header for 429 responses * - Does NOT retry on client errors (4xx) except rate limits * - Uses exponential backoff: 1s, 2s, 4s (default) if no Retry-After header * * @param url - The URL to fetch * @param options - Configuration options for retries and request * @returns The JSON response (or null for 204 No Content) * @throws Error if all retry attempts fail * * @example * ```typescript * const data = await fetchWithRetries('https://api.example.com/data', { * maxRetries: 3, * headers: { 'User-Agent': 'MyApp/1.0' } * }); * ``` */ export declare function fetchWithRetries(url: string, options?: FetchWithRetriesOptions): Promise<unknown>;