We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ysh-fe/content_automation'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
retry.ts•770 B
/**
* Simple retry utility
* Retries a function with fixed delay between attempts
*/
/**
* Retry a function with fixed delay
* @param fn - Function to retry
* @param maxRetries - Maximum number of retry attempts (default: 3)
* @param delayMs - Delay between retries in milliseconds (default: 1000)
* @returns Result of function execution
* @throws Error if all retries fail
*/
export const retry = async <T>(
fn: () => Promise<T>,
maxRetries = 3,
delayMs = 1000
): Promise<T> => {
for (let i = 0; i <= maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries) {
throw error;
}
await new Promise(resolve => setTimeout(resolve, delayMs));
}
}
throw new Error('Retry failed');
};