Files
KNEL-AIMiddleware/validate-mcp.sh
Charles N Wyble a0ca7c9eaf feat: add Crush MCP server configurations and validate multiple MCP servers
- Add crush.json with comprehensive MCP configurations for Crush AI assistant
- Configure stdio-based MCPs: penpot, context7, docker, drawio, redmine
- Configure HTTP-based MCP: nextcloud (port 8083 with SSE endpoint)
- Fix mcp-redmine Dockerfile with correct python module entrypoint
- Fix nextcloud-mcp Dockerfile to handle .dockerignore blocking observability
- Fix drawio-mcp Dockerfile to use pnpm and correct build directory
- Update docker-compose.yml with proper MCP server configurations
- Add environment variable configuration for MCPs requiring external services
- Create MCP validation script to test servers with protocol messages
- Update STATUS.md with confirmed working MCP servers and their requirements
- Validate: penpot, context7, docker, drawio, redmine, nextcloud (HTTP)
- Document required env vars for ghost, imap, proxmox, penpot MCPs
- Configure Crush to use both stdio (docker run) and HTTP endpoints
2026-01-22 16:05:08 -05:00

107 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
# MCP Server Validation Script
# Tests each MCP server with actual protocol messages
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Initialize JSON message
INIT_MSG='{"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{},"protocolVersion":"2024-11-05","clientInfo":{"name":"test","version":"1.0.0"}},"id":1}'
# Test a container with initialize message
test_mcp_server() {
local container_name=$1
local timeout=${2:-5}
shift 2
local env_vars=("$@")
echo -e "${YELLOW}Testing $container_name...${NC}"
# Build environment arguments
local env_args=""
for env_var in "${env_vars[@]}"; do
env_args="$env_args -e $env_var"
done
# Run container with stdin input and environment variables
result=$(timeout $timeout docker run --rm -i --name "$container_name-test" \
$env_args \
"$container_name" \
<<<"$INIT_MSG" \
2>&1)
# Check for valid JSON-RPC response
if echo "$result" | grep -q '"result"'; then
# Check if it has server info
if echo "$result" | grep -q '"serverInfo"'; then
server_name=$(echo "$result" | grep -o '"name":"[^"]*"' | head -1 | cut -d'"' -f4)
version=$(echo "$result" | grep -o '"version":"[^"]*"' | head -1 | cut -d'"' -f4)
echo -e "${GREEN}$container_name: Working ($server_name v${version})${NC}"
return 0
fi
fi
# Check if server requires environment variables
if echo "$result" | grep -qi "environment variable"; then
echo -e "${YELLOW}$container_name: Needs environment variables${NC}"
return 1
fi
# Check if server needs external service
if echo "$result" | grep -qi "connection refused\|not connected"; then
echo -e "${YELLOW}$container_name: Needs external service (expected)${NC}"
return 1
fi
# Check other errors
echo -e "${RED}$container_name: Failed${NC}"
echo -e "${RED} Error: $(echo "$result" | head -3 | tail -1)${NC}"
return 1
}
# Test all built containers
echo -e "${YELLOW}=== MCP Server Validation ===${NC}\n"
# Stdio-based MCP servers
test_mcp_server "kneldevstack-aimiddleware-ghost-mcp" \
"GHOST_URL=https://ghost.example.com" \
"GHOST_API_KEY=dummy-key"
test_mcp_server "kneldevstack-aimiddleware-penpot-mcp" \
"PENPOT_URL=https://design.penpot.app" \
"PENPOT_TOKEN=dummy-token"
test_mcp_server "kneldevstack-aimiddleware-imap-mcp" \
"IMAP_HOST=imap.example.com" \
"IMAP_USERNAME=user@example.com" \
"IMAP_PASSWORD=dummy-password"
test_mcp_server "kneldevstack-aimiddleware-proxmox-mcp" \
"PROXMOX_HOST=https://proxmox.example.com" \
"PROXMOX_USER=root@pam" \
"PROXMOX_TOKEN=dummy-token" \
"PROXMOX_NODE=pve"
test_mcp_server "kneldevstack-aimiddleware-context7-mcp"
test_mcp_server "kneldevstack-aimiddleware-docker-mcp"
test_mcp_server "kneldevstack-aimiddleware-drawio-mcp"
test_mcp_server "kneldevstack-aimiddleware-mcp-redmine" \
"REDMINE_URL=https://redmine.example.com" \
"REDMINE_API_KEY=dummy-key"
# HTTP-based MCP servers
echo -e "${YELLOW}Testing nextcloud-mcp (HTTP endpoint)...${NC}"
result=$(timeout 5 curl -s http://localhost:8083/health/live 2>&1 || echo "Connection failed")
if echo "$result" | grep -q "200 OK\|healthy"; then
echo -e "${GREEN}✓ nextcloud-mcp (HTTP): Running on http://localhost:8083${NC}"
else
echo -e "${YELLOW}⚠ nextcloud-mcp (HTTP): Not running or unhealthy${NC}"
fi
echo -e "\n${YELLOW}=== Validation Complete ===${NC}"