- 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
61 lines
2.0 KiB
JavaScript
61 lines
2.0 KiB
JavaScript
#!/usr/bin/env node
|
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
import { SendGridMCPServer } from './server.js';
|
|
|
|
// Validate environment
|
|
const SENDGRID_API_KEY = process.env.SENDGRID_API_KEY;
|
|
|
|
if (!SENDGRID_API_KEY) {
|
|
console.error('❌ ERROR: SENDGRID_API_KEY environment variable is required');
|
|
console.error('');
|
|
console.error('Get your API key from:');
|
|
console.error(' 1. Log in to SendGrid: https://app.sendgrid.com/');
|
|
console.error(' 2. Navigate to Settings > API Keys');
|
|
console.error(' 3. Create a new API key with Full Access or Mail Send permissions');
|
|
console.error(' 4. Copy the key and set: export SENDGRID_API_KEY=your_key_here');
|
|
console.error('');
|
|
console.error('Required permissions:');
|
|
console.error(' - Mail Send (for transactional emails)');
|
|
console.error(' - Marketing Campaigns (for campaigns, lists, contacts)');
|
|
console.error(' - Template Engine (for templates)');
|
|
console.error(' - Suppressions (for bounce/spam management)');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Create server instance
|
|
const server = new SendGridMCPServer({
|
|
apiKey: SENDGRID_API_KEY,
|
|
});
|
|
|
|
// Graceful shutdown
|
|
let isShuttingDown = false;
|
|
|
|
const shutdown = async (signal: string) => {
|
|
if (isShuttingDown) return;
|
|
isShuttingDown = true;
|
|
|
|
console.error(`\n📡 Received ${signal}, shutting down SendGrid MCP server...`);
|
|
|
|
try {
|
|
await server.close();
|
|
console.error('✅ Server closed gracefully');
|
|
process.exit(0);
|
|
} catch (error) {
|
|
console.error('❌ Error during shutdown:', error);
|
|
process.exit(1);
|
|
}
|
|
};
|
|
|
|
process.on('SIGINT', () => shutdown('SIGINT'));
|
|
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
|
|
|
// Start server
|
|
const transport = new StdioServerTransport();
|
|
server.connect(transport).catch((error) => {
|
|
console.error('❌ Failed to start SendGrid MCP server:', error);
|
|
process.exit(1);
|
|
});
|
|
|
|
console.error('🚀 SendGrid MCP Server running on stdio');
|
|
console.error('📧 Ready to handle email operations');
|