- READMEs added: asana, close, freshdesk, google-console, gusto, square - main.ts + server.ts (lazy loading): activecampaign, clickup, klaviyo, mailchimp, pipedrive, trello, touchbistro, closebot, close, google-console - All 13 compile with 0 TSC errors
88 lines
2.3 KiB
JavaScript
88 lines
2.3 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Apollo.io MCP Server - Entry Point
|
|
* Provides AI-powered access to Apollo.io sales intelligence platform
|
|
*/
|
|
|
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
import { ApolloMCPServer } from './server.js';
|
|
import { ApolloClient } from './client/apollo-client.js';
|
|
|
|
// Environment validation
|
|
const apiKey = process.env.APOLLO_API_KEY;
|
|
|
|
if (!apiKey) {
|
|
console.error('❌ APOLLO_API_KEY environment variable is required');
|
|
console.error('');
|
|
console.error('Get your API key from:');
|
|
console.error(' 1. Log in to Apollo.io');
|
|
console.error(' 2. Go to Settings > Integrations > API');
|
|
console.error(' 3. Generate or copy your API key');
|
|
console.error('');
|
|
console.error('Then set it:');
|
|
console.error(' export APOLLO_API_KEY="your-api-key-here"');
|
|
console.error('');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Create Apollo API client
|
|
const apolloClient = new ApolloClient({
|
|
apiKey,
|
|
baseUrl: process.env.APOLLO_BASE_URL,
|
|
});
|
|
|
|
// Create MCP server
|
|
const server = new Server(
|
|
{
|
|
name: 'apollo-mcp-server',
|
|
version: '1.0.0',
|
|
},
|
|
{
|
|
capabilities: {
|
|
tools: {},
|
|
},
|
|
}
|
|
);
|
|
|
|
// Initialize Apollo MCP server with tool handlers
|
|
const apolloServer = new ApolloMCPServer(server, apolloClient);
|
|
await apolloServer.setupHandlers();
|
|
|
|
// Graceful shutdown handler
|
|
let isShuttingDown = false;
|
|
const shutdown = async (signal: string) => {
|
|
if (isShuttingDown) return;
|
|
isShuttingDown = true;
|
|
|
|
console.error(`\n📡 Received ${signal}, shutting down gracefully...`);
|
|
|
|
try {
|
|
await server.close();
|
|
console.error('✅ Server closed successfully');
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('❌ Error during shutdown:', error);
|
|
process.exit(1);
|
|
}
|
|
};
|
|
|
|
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
|
|
// Health check support
|
|
process.on('message', (msg: any) => {
|
|
if (msg === 'health_check') {
|
|
process.send?.({ status: 'healthy', server: 'apollo-mcp' });
|
|
}
|
|
});
|
|
|
|
// Start server with stdio transport
|
|
const transport = new StdioServerTransport();
|
|
await server.connect(transport);
|
|
|
|
console.error('🚀 Apollo MCP Server running on stdio');
|
|
console.error(`📊 ${apolloServer.getToolCount()} tools available`);
|
|
console.error('');
|