UNPKG

leadmagic-mcp-server

Version:

Model Context Protocol server for LeadMagic API - Complete B2B data enrichment with 19 tools for email finding, profile enrichment, company intelligence, job data, and advertisement tracking

190 lines 6.1 kB
import axios from 'axios'; export class LeadMagicError extends Error { status; code; response; constructor(status, code, message, response) { super(message); this.status = status; this.code = code; this.response = response; this.name = 'LeadMagicError'; } } export class LeadMagicClient { client; constructor(config) { if (!config.apiKey) { throw new Error('LeadMagic API key is required'); } this.client = axios.create({ baseURL: config.baseUrl || 'https://api.leadmagic.io', timeout: config.timeout || 30000, headers: { 'X-API-Key': config.apiKey, 'Content-Type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'leadmagic-mcp-server/1.0.0', }, }); // Add response interceptor for error handling this.client.interceptors.response.use((response) => response, (error) => { if (error.response) { const { status, data } = error.response; throw new LeadMagicError(status, data?.error || 'API_ERROR', data?.message || error.message, data); } else if (error.request) { throw new LeadMagicError(0, 'NETWORK_ERROR', 'Network error occurred'); } else { throw new LeadMagicError(0, 'UNKNOWN_ERROR', error.message); } }); } /** * Check available API credits */ async getCredits() { const response = await this.client.post('/credits', {}); return response.data; } /** * Validate an email address for deliverability and get company information */ async validateEmail(request) { const response = await this.client.post('/email-validate', request); return response.data; } /** * Find verified email address based on person's name and company */ async findEmail(request) { const response = await this.client.post('/email-finder', request); return response.data; } /** * Get full profile details from B2B profile URL (e.g., LinkedIn) * Rate limit: 300 requests/minute */ async searchProfile(request) { const response = await this.client.post('/profile-search', request); return response.data; } /** * Search for company details using domain, name, or profile URL */ async searchCompany(request) { const response = await this.client.post('/company-search', request); return response.data; } /** * Find mobile phone numbers using profile URL, work email, or personal email */ async findMobile(request) { const response = await this.client.post('/mobile-finder', request); return response.data; } /** * Find B2B profile URL using work email address */ async emailToProfile(request) { const response = await this.client.post('/b2b-profile', request); return response.data; } /** * Search for job postings based on various criteria */ async findJobs(request) { const response = await this.client.post('/jobs-finder', request); return response.data; } /** * Find specific roles/positions within a company */ async findRole(request) { const response = await this.client.post('/role-finder', request); return response.data; } /** * Find employees of a specific company */ async findEmployees(request) { const response = await this.client.post('/employee-finder', request); return response.data; } /** * Get comprehensive funding information, financials, competitors, and company insights */ async getCompanyFunding(request) { const response = await this.client.post('/company-funding', request); return response.data; } /** * Find personal email addresses from B2B profile URLs */ async findPersonalEmail(request) { const response = await this.client.post('/personal-email-finder', request); return response.data; } /** * Find work email addresses from B2B profile URLs */ async socialToWorkEmail(request) { const response = await this.client.post('/b2b-social-email', request); return response.data; } /** * Search for Google Ads based on company's domain or name */ async searchGoogleAds(request) { const response = await this.client.post('/google/searchads', request); return response.data; } /** * Search for Meta (Facebook/Instagram) Ads based on company's domain or name */ async searchMetaAds(request) { const response = await this.client.post('/meta/searchads', request); return response.data; } /** * Search for B2B Ads based on company's domain or name */ async searchB2BAds(request) { const response = await this.client.post('/b2b/searchads', request); return response.data; } /** * Get detailed information about a specific B2B ad */ async getB2BAdDetails(request) { const response = await this.client.post('/b2b/ad-details', request); return response.data; } /** * Get list of available countries for job filtering */ async getJobCountries() { const response = await this.client.get('/job-country'); return response.data; } /** * Get list of available job types for filtering */ async getJobTypes() { const response = await this.client.get('/job-types'); return response.data; } /** * Generic method for custom API calls */ async request(method, endpoint, data) { const response = await this.client.request({ method, url: endpoint, data, }); return response.data; } } //# sourceMappingURL=client.js.map