UNPKG

smartlead-mcp-server

Version:

MCP server for Smartlead campaign management integration. Features include creating campaigns, updating campaign settings, and managing campaign sequences.

64 lines 2.7 kB
import { SuperGateway as MockSuperGateway } from './supergateway-mock.js'; import { isFeatureEnabled } from './licensing/index.js'; /** * Try to dynamically import Supergateway package */ export async function tryImportSupergateway() { try { // First try to import the real package return await import('supergateway'); } catch (error) { console.error(`Failed to import Supergateway: ${error instanceof Error ? error.message : String(error)}`); console.error('Falling back to mock Supergateway implementation'); // Return our mock implementation as a fallback return { SuperGateway: MockSuperGateway }; } } /** * Create a Supergateway instance */ export async function createSupergateway(apiKey) { try { // Check if the current license allows n8n integration const n8nIntegrationEnabled = await isFeatureEnabled('n8nIntegration'); if (!n8nIntegrationEnabled) { console.error('============================================================='); console.error('ERROR: Your license does not include n8n integration features'); console.error('This feature requires a Basic or Premium license subscription.'); console.error('Visit https://yourservice.com/pricing to upgrade your plan.'); console.error(''); console.error('For testing purposes, you can obtain a Basic license from'); console.error('https://yourservice.com/pricing'); console.error('============================================================='); return null; } // Try to dynamically import the Supergateway module const supergateModule = await tryImportSupergateway(); if (!supergateModule) { console.error('Supergateway module not found.'); return null; } // Check if API key is provided if (!apiKey) { console.error('SUPERGATEWAY_API_KEY not provided'); console.error('Please set the SUPERGATEWAY_API_KEY environment variable in your .env file.'); return null; } // Create Supergateway instance const { SuperGateway } = supergateModule; const gateway = new SuperGateway({ apiKey, // Additional configuration options can be added here }); console.error('Supergateway initialized successfully'); return gateway; } catch (error) { console.error(`Error initializing Supergateway: ${error instanceof Error ? error.message : String(error)}`); return null; } } //# sourceMappingURL=supergateway.js.map