import dotenv from 'dotenv';
import { createHTTPServer } from '@leanmcp/core';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { existsSync } from 'fs';
// Load environment variables
dotenv.config();
// Verify critical dependencies before starting
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log('π Checking dependencies...');
const slackWebApiPath = join(__dirname, 'node_modules', '@slack', 'web-api');
const leanmcpCorePath = join(__dirname, 'node_modules', '@leanmcp', 'core');
if (!existsSync(slackWebApiPath)) {
console.error('β Error: @slack/web-api not installed!');
console.error('');
console.error('Run one of these commands to fix:');
console.error(' chmod +x install.sh && ./install.sh # Mac/Linux');
console.error(' install.bat # Windows');
console.error(' npm install # Manual');
console.error('');
process.exit(1);
}
if (!existsSync(leanmcpCorePath)) {
console.error('β Error: @leanmcp/core not installed!');
console.error('');
console.error('Run one of these commands to fix:');
console.error(' chmod +x install.sh && ./install.sh # Mac/Linux');
console.error(' install.bat # Windows');
console.error(' npm install # Manual');
console.error('');
process.exit(1);
}
console.log('β
Dependencies verified\n');
// Start server
try {
const server = await createHTTPServer({
name: 'slack-mcp-server',
version: '1.0.0',
port: 3001,
cors: true,
logging: true,
});
console.log('π Slack MCP Server is running!');
console.log('=====================================');
console.log('π MCP Endpoint: http://localhost:3001/mcp');
console.log('π Test with:');
console.log(' npx @modelcontextprotocol/inspector http://localhost:3001/mcp');
console.log('=====================================\n');
console.log('Available tools:');
console.log(' β getChannelSummary - δΈζι’ιζθ¦');
console.log(' β sendDirectMessage - ειη§δΏ‘');
console.log(' β sendChannelMessage - ειι’ιζΆζ―');
console.log(' β listUsers - εεΊη¨ζ·');
console.log(' β listChannels - εεΊι’ι');
console.log(' β readMessages - θ―»εζΆζ―\n');
if (!process.env.SLACK_BOT_TOKEN) {
console.warn('β οΈ WARNING: SLACK_BOT_TOKEN not configured!');
console.warn(' Create .env file: cp .env.example .env');
console.warn(' See SETUP.md for instructions.\n');
}
} catch (error) {
console.error('β Server failed to start:', error.message);
console.error('');
console.error('If you see import errors, run:');
console.error(' npm install');
console.error('');
process.exit(1);
}