mcptesta/scripts/health-check.sh
Ryan Malloy bea4a2e5d3 Initial release: MCPTesta v1.0.0 🧪
Community-driven testing excellence for the MCP ecosystem

MCPTesta is a comprehensive testing framework for FastMCP servers that brings
scientific rigor and enterprise-grade capabilities to MCP protocol testing.

🎯 Core Features:
• Comprehensive FastMCP server testing with advanced protocol support
• Parallel execution with intelligent dependency resolution
• Flexible CLI and YAML configuration system
• Rich reporting: console, HTML, JSON, and JUnit formats
• Advanced MCP protocol features: notifications, cancellation, progress tracking
• Production-ready Docker environment with caddy-docker-proxy integration

🧪 Advanced Testing Capabilities:
• Multi-transport support (stdio, SSE, WebSocket)
• Authentication testing (Bearer tokens, OAuth flows)
• Stress testing and performance validation
• Memory profiling and leak detection
• CI/CD integration with comprehensive reporting

🎨 Professional Assets:
• Complete logo package with lab experiment theme
• Comprehensive documentation with Diátaxis framework
• Community-focused branding and messaging
• Multi-platform favicon and social media assets

📚 Documentation:
• Getting started tutorials and comprehensive guides
• Complete CLI and YAML reference documentation
• Architecture explanations and testing strategies
• Team collaboration and security compliance guides

🚀 Ready for:
• Community contributions and external development
• Enterprise deployment and production use
• Integration with existing FastMCP workflows
• Extension and customization for specific needs

Built with modern Python practices using uv, FastMCP, and Starlight documentation.
Designed for developers who demand scientific precision in their testing tools.

Repository: https://git.supported.systems/mcp/mcptesta
Documentation: https://mcptesta.l.supported.systems
2025-09-20 03:20:49 -06:00

161 lines
4.1 KiB
Bash
Executable File

#!/bin/sh
# MCPTesta Documentation Health Check Script
# Comprehensive health validation for container monitoring
set -e
# Configuration
HOST=${HOST:-localhost}
PORT=${PORT:-4321}
TIMEOUT=${HEALTH_TIMEOUT:-10}
MAX_RESPONSE_TIME=5000 # milliseconds
# Colors for output (simplified for sh compatibility)
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
# Logging functions
log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1"
}
success() {
echo "${GREEN}[HEALTHY]${NC} $1"
}
error() {
echo "${RED}[UNHEALTHY]${NC} $1" >&2
exit 1
}
# Health check functions
check_port() {
if ! nc -z "$HOST" "$PORT" 2>/dev/null; then
error "Port $PORT is not accessible on $HOST"
fi
log "Port $PORT is accessible"
}
check_http_response() {
local response_code
local response_time
# Check HTTP response with timeout
if ! response_code=$(wget --spider --server-response --timeout="$TIMEOUT" --tries=1 \
"http://$HOST:$PORT/" 2>&1 | grep "HTTP/" | tail -1 | awk '{print $2}'); then
error "HTTP request failed or timed out"
fi
# Validate response code
if [ "$response_code" != "200" ]; then
error "HTTP response code: $response_code (expected: 200)"
fi
log "HTTP response: $response_code OK"
}
check_response_time() {
local start_time
local end_time
local response_time
start_time=$(date +%s%3N)
if ! wget --spider --quiet --timeout="$TIMEOUT" --tries=1 "http://$HOST:$PORT/" 2>/dev/null; then
error "Response time check failed"
fi
end_time=$(date +%s%3N)
response_time=$((end_time - start_time))
if [ "$response_time" -gt "$MAX_RESPONSE_TIME" ]; then
error "Response time too slow: ${response_time}ms (max: ${MAX_RESPONSE_TIME}ms)"
fi
log "Response time: ${response_time}ms"
}
check_content() {
local content
# Check if the page contains expected content
if ! content=$(wget --quiet --timeout="$TIMEOUT" --tries=1 -O- "http://$HOST:$PORT/" 2>/dev/null); then
error "Failed to retrieve page content"
fi
# Basic content validation
if ! echo "$content" | grep -q "MCPTesta"; then
error "Page content validation failed - 'MCPTesta' not found"
fi
if ! echo "$content" | grep -q "<html"; then
error "Page content validation failed - HTML structure not found"
fi
log "Content validation passed"
}
check_dependencies() {
# Check if required commands are available
command -v wget >/dev/null 2>&1 || error "wget command not found"
command -v nc >/dev/null 2>&1 || error "nc (netcat) command not found"
log "Required dependencies available"
}
check_memory_usage() {
local memory_usage
local memory_limit_mb=512 # Default limit
# Get memory usage in MB (simplified check)
if [ -f /proc/meminfo ]; then
memory_usage=$(awk '/MemAvailable/ {printf "%.0f", $2/1024}' /proc/meminfo)
if [ "$memory_usage" -lt 50 ]; then
error "Low available memory: ${memory_usage}MB"
fi
log "Available memory: ${memory_usage}MB"
else
log "Memory check skipped (no /proc/meminfo)"
fi
}
check_disk_space() {
local disk_usage
local disk_limit=90 # 90% threshold
# Check disk usage of /app
if disk_usage=$(df /app 2>/dev/null | tail -1 | awk '{print $5}' | sed 's/%//'); then
if [ "$disk_usage" -gt "$disk_limit" ]; then
error "High disk usage: ${disk_usage}% (limit: ${disk_limit}%)"
fi
log "Disk usage: ${disk_usage}%"
else
log "Disk check skipped"
fi
}
# Main health check routine
main() {
log "Starting comprehensive health check..."
log "Target: http://$HOST:$PORT/"
log "Timeout: ${TIMEOUT}s"
# Run all health checks
check_dependencies
check_memory_usage
check_disk_space
check_port
check_http_response
check_response_time
check_content
success "All health checks passed"
log "Container is healthy and ready to serve requests"
}
# Run health check
main