Skip to main content
Glama
validate_deployment.sh7.27 kB
#!/bin/bash # Deployment Validation Script for MCP KYC Server # This script validates that all services are running correctly set -e echo "=========================================" echo "MCP KYC Server Deployment Validation" echo "=========================================" echo "" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Counters PASSED=0 FAILED=0 # Function to print success print_success() { echo -e "${GREEN}✓${NC} $1" ((PASSED++)) } # Function to print failure print_failure() { echo -e "${RED}✗${NC} $1" ((FAILED++)) } # Function to print warning print_warning() { echo -e "${YELLOW}⚠${NC} $1" } # Function to print section header print_header() { echo "" echo "=========================================" echo "$1" echo "=========================================" } # 1. Check Docker containers print_header "1. Checking Docker Containers" if command -v docker &> /dev/null; then # Check if MCP server container is running if docker ps | grep -q "kyc-mcp-server"; then print_success "MCP Server container is running" else print_failure "MCP Server container is not running" fi # Check if Redis container is running if docker ps | grep -q "redis"; then print_success "Redis container is running" else print_failure "Redis container is not running" fi else print_warning "Docker not found, skipping container checks" fi # 2. Check Redis connectivity print_header "2. Checking Redis Connectivity" if command -v redis-cli &> /dev/null; then if redis-cli ping &> /dev/null; then print_success "Redis is responding to PING" else print_failure "Redis is not responding" fi # Check Redis memory usage REDIS_MEMORY=$(redis-cli info memory | grep "used_memory_human" | cut -d: -f2 | tr -d '\r') if [ -n "$REDIS_MEMORY" ]; then print_success "Redis memory usage: $REDIS_MEMORY" fi else print_warning "redis-cli not found, skipping Redis checks" fi # 3. Check MCP Server process print_header "3. Checking MCP Server Process" if pgrep -f "python.*main.py" > /dev/null; then print_success "MCP Server process is running" PID=$(pgrep -f "python.*main.py") print_success "Process ID: $PID" else print_failure "MCP Server process is not running" fi # 4. Check network ports print_header "4. Checking Network Ports" # Check if port 8000 is listening (MCP server) if netstat -tuln 2>/dev/null | grep -q ":8000 " || ss -tuln 2>/dev/null | grep -q ":8000 "; then print_success "Port 8000 (MCP Server) is listening" else print_failure "Port 8000 (MCP Server) is not listening" fi # Check if port 6379 is listening (Redis) if netstat -tuln 2>/dev/null | grep -q ":6379 " || ss -tuln 2>/dev/null | grep -q ":6379 "; then print_success "Port 6379 (Redis) is listening" else print_failure "Port 6379 (Redis) is not listening" fi # 5. Check log files print_header "5. Checking Log Files" LOG_DIR="/var/log/kyc-mcp" if [ -d "$LOG_DIR" ]; then print_success "Log directory exists: $LOG_DIR" # Check for recent errors if [ -f "$LOG_DIR/error.log" ]; then ERROR_COUNT=$(tail -n 100 "$LOG_DIR/error.log" 2>/dev/null | grep -c "ERROR" || echo "0") if [ "$ERROR_COUNT" -eq 0 ]; then print_success "No recent errors in error.log" else print_warning "Found $ERROR_COUNT errors in last 100 lines of error.log" fi fi # Check log file sizes for log_file in "$LOG_DIR"/*.log; do if [ -f "$log_file" ]; then SIZE=$(du -h "$log_file" | cut -f1) echo " Log file: $(basename $log_file) - Size: $SIZE" fi done else print_warning "Log directory not found: $LOG_DIR" fi # 6. Check environment variables print_header "6. Checking Environment Variables" ENV_FILE=".env" if [ -f "$ENV_FILE" ]; then print_success "Environment file exists" # Check critical variables if grep -q "KYC_API_KEY=" "$ENV_FILE"; then print_success "KYC_API_KEY is configured" else print_failure "KYC_API_KEY is not configured" fi if grep -q "JWT_SECRET_KEY=" "$ENV_FILE"; then print_success "JWT_SECRET_KEY is configured" else print_failure "JWT_SECRET_KEY is not configured" fi else print_warning "Environment file not found: $ENV_FILE" fi # 7. Check tool metadata print_header "7. Checking Tool Metadata" METADATA_DIR="metadata/tools" if [ -d "$METADATA_DIR" ]; then print_success "Metadata directory exists" METADATA_COUNT=$(find "$METADATA_DIR" -name "*.json" | wc -l) print_success "Found $METADATA_COUNT tool metadata files" # Validate JSON files for json_file in "$METADATA_DIR"/*.json; do if [ -f "$json_file" ]; then if python3 -m json.tool "$json_file" > /dev/null 2>&1; then print_success "Valid JSON: $(basename $json_file)" else print_failure "Invalid JSON: $(basename $json_file)" fi fi done else print_failure "Metadata directory not found: $METADATA_DIR" fi # 8. Check Python dependencies print_header "8. Checking Python Dependencies" if command -v pip &> /dev/null; then # Check if requirements are installed if pip show mcp &> /dev/null; then print_success "MCP package is installed" else print_failure "MCP package is not installed" fi if pip show redis &> /dev/null; then print_success "Redis package is installed" else print_failure "Redis package is not installed" fi if pip show httpx &> /dev/null; then print_success "HTTPX package is installed" else print_failure "HTTPX package is not installed" fi else print_warning "pip not found, skipping dependency checks" fi # 9. Check disk space print_header "9. Checking Disk Space" DISK_USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//') if [ "$DISK_USAGE" -lt 80 ]; then print_success "Disk usage is healthy: ${DISK_USAGE}%" elif [ "$DISK_USAGE" -lt 90 ]; then print_warning "Disk usage is high: ${DISK_USAGE}%" else print_failure "Disk usage is critical: ${DISK_USAGE}%" fi # 10. Check system resources print_header "10. Checking System Resources" # Check memory if command -v free &> /dev/null; then MEMORY_USAGE=$(free | grep Mem | awk '{printf "%.0f", $3/$2 * 100}') if [ "$MEMORY_USAGE" -lt 80 ]; then print_success "Memory usage is healthy: ${MEMORY_USAGE}%" else print_warning "Memory usage is high: ${MEMORY_USAGE}%" fi fi # Check CPU load if [ -f /proc/loadavg ]; then LOAD_AVG=$(cat /proc/loadavg | awk '{print $1}') print_success "CPU load average (1 min): $LOAD_AVG" fi # Summary print_header "Validation Summary" echo "" echo "Total Checks: $((PASSED + FAILED))" echo -e "${GREEN}Passed: $PASSED${NC}" echo -e "${RED}Failed: $FAILED${NC}" echo "" if [ $FAILED -eq 0 ]; then echo -e "${GREEN}✓ All validation checks passed!${NC}" exit 0 else echo -e "${RED}✗ Some validation checks failed. Please review the output above.${NC}" exit 1 fi

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/CTD-Techs/CTD-MCP'

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