smartlead-mcp-by-leadmagic
Version:
💜 The Premier Model Context Protocol Server for SmartLead's Cold Email Automation Platform - Complete API coverage with 116+ tools for campaign management, lead tracking, smart delivery, and analytics. Beautiful purple-gradient installer, zero-config set
108 lines • 3.29 kB
TypeScript
/**
* SmartLead MCP Server - Base API Client
*
* Core HTTP client functionality with error handling, retry logic, and rate limiting.
* This base client is extended by specific API modules for different endpoint categories.
*
* Features:
* - Exponential backoff retry logic
* - Rate limiting and request queuing
* - Comprehensive error handling and classification
* - Request/response logging and debugging
* - Type-safe parameter validation
* - Connection testing and health checks
*
* @author LeadMagic Team
* @version 1.5.0
*/
import { type AxiosInstance, type AxiosResponse } from 'axios';
import type { SmartLeadConfig } from '../types/config.js';
/**
* Custom error class for SmartLead API errors
* Provides detailed error information and classification
*/
export declare class SmartLeadError extends Error {
readonly code: string;
readonly status: number;
readonly response?: unknown;
readonly isRetryable: boolean;
constructor(message: string, code?: string, status?: number, response?: unknown, isRetryable?: boolean);
/**
* Check if this is a client error (4xx status codes)
*/
isClientError(): boolean;
/**
* Check if this is a server error (5xx status codes)
*/
isServerError(): boolean;
/**
* Check if this is a network error
*/
isNetworkError(): boolean;
/**
* Check if this error should trigger a retry
*/
shouldRetry(): boolean;
}
/**
* Base SmartLead API Client
*
* Provides core HTTP functionality that is extended by specific API modules.
* Handles authentication, rate limiting, retries, and error management.
*/
export declare class BaseSmartLeadClient {
protected readonly apiClient: AxiosInstance;
protected readonly config: Required<SmartLeadConfig>;
private requestCount;
private rateLimitResetTime;
/**
* Creates a new base SmartLead API client
*
* @param config - Client configuration including API key and optional settings
* @throws {SmartLeadError} If configuration is invalid
*/
constructor(config: SmartLeadConfig);
/**
* Rate limiting: Check if we can make a request now
* @private
*/
private checkRateLimit;
/**
* Parse rate limit info from response headers
* @private
*/
private parseRateLimitHeaders;
/**
* Sets up Axios interceptors for request/response handling
* @private
*/
private setupInterceptors;
/**
* Handles Axios errors and converts them to SmartLeadError instances
* @private
*/
private handleAxiosError;
/**
* Implements exponential backoff retry logic
* @protected
*/
protected delay(ms: number): Promise<void>;
/**
* Executes a request with retry logic
* @protected
*/
protected withRetry<T>(operation: () => Promise<AxiosResponse<T>>, context: string, attempt?: number): Promise<AxiosResponse<T>>;
/**
* Test the API connection and validate credentials
*/
testConnection(): Promise<{
success: boolean;
message?: string;
error?: string;
}>;
/**
* Get client configuration (excluding sensitive data)
*/
getConfig(): Partial<SmartLeadConfig>;
}
//# sourceMappingURL=base.d.ts.map