Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions actions/setup/sh/start_mcp_gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,23 @@ echo ""
# Wait for gateway to be ready using /health endpoint
# Note: Gateway may take 40-50 seconds when starting multiple MCP servers
# (e.g., serena alone takes ~22 seconds to start)
# Allow override via MCP_GATEWAY_HEALTH_TIMEOUT_SECONDS environment variable
echo "Waiting for gateway to be ready..."
# Use localhost for health check since:
# 1. This script runs on the host (not in a container)
# 2. The gateway uses --network host, so it's accessible on localhost
# Note: MCP_GATEWAY_DOMAIN may be set to host.docker.internal for use by containers,
# but the health check should always use localhost since we're running on the host.
HEALTH_CHECK_HOST="localhost"
HEALTH_TIMEOUT_SECONDS="${MCP_GATEWAY_HEALTH_TIMEOUT_SECONDS:-240}"
echo "Health endpoint: http://${HEALTH_CHECK_HOST}:${MCP_GATEWAY_PORT}/health"
echo "(Note: MCP_GATEWAY_DOMAIN is '${MCP_GATEWAY_DOMAIN}' for container access)"
echo "Retrying up to 120 times with 1s delay (120s total timeout)"
echo "Retrying up to ${HEALTH_TIMEOUT_SECONDS} times with 1s delay (${HEALTH_TIMEOUT_SECONDS}s total timeout)"

# Check health endpoint using localhost (since we're running on the host)
# Per MCP Gateway Specification v1.3.0, /health must return HTTP 200 with JSON body containing specVersion and gatewayVersion
# Use curl retry: 120 attempts with 1 second delay = 120s total
RESPONSE=$(curl -s --retry 120 --retry-delay 1 --retry-connrefused --retry-all-errors -w "\n%{http_code}" "http://${HEALTH_CHECK_HOST}:${MCP_GATEWAY_PORT}/health" 2>&1)
# Use curl retry with configurable timeout (default: 240s)
RESPONSE=$(curl -s --retry "${HEALTH_TIMEOUT_SECONDS}" --retry-delay 1 --retry-connrefused --retry-all-errors -w "\n%{http_code}" "http://${HEALTH_CHECK_HOST}:${MCP_GATEWAY_PORT}/health" 2>&1)
HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
HEALTH_RESPONSE=$(echo "$RESPONSE" | head -n -1)

Expand Down
8 changes: 5 additions & 3 deletions actions/setup/sh/verify_mcp_gateway_health.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ echo ''
echo '=== Testing Gateway Health ==='

# Capture both response body and HTTP code in a single curl call
# Use curl retry: 120 attempts with 1 second delay = 120s total
# Use curl retry with configurable timeout (default: 240s)
# Allow override via MCP_GATEWAY_HEALTH_TIMEOUT_SECONDS environment variable
HEALTH_TIMEOUT_SECONDS="${MCP_GATEWAY_HEALTH_TIMEOUT_SECONDS:-240}"
echo "Calling health endpoint: ${gateway_url}/health"
echo "Retrying up to 120 times with 1s delay (120s total timeout)"
response=$(curl -s --retry 120 --retry-delay 1 --retry-connrefused --retry-all-errors -w "\n%{http_code}" "${gateway_url}/health")
echo "Retrying up to ${HEALTH_TIMEOUT_SECONDS} times with 1s delay (${HEALTH_TIMEOUT_SECONDS}s total timeout)"
response=$(curl -s --retry "${HEALTH_TIMEOUT_SECONDS}" --retry-delay 1 --retry-connrefused --retry-all-errors -w "\n%{http_code}" "${gateway_url}/health")
http_code=$(echo "$response" | tail -n 1)
health_response=$(echo "$response" | head -n -1)

Expand Down