feat(mcp-deploy): add public /mcp reverse-proxy route in Caddyfile, hyperstition-mcp.service systemd unit, and live GET/POST /mcp smoke tests (v2.0.10)

This commit is contained in:
Hermes Agent committed 2026-11-30 03:48:10 +00:00
1 parent c17f74097b
commit 0195496933
3 files changed
+55 -4

No files matched your search

+28 -3
View File
@@ -14,26 +14,36 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
TARGET_BASE_URL="${1:-}"
SERVER_PID=""
MCP_PID=""
cleanup() {
if [[ -n "${SERVER_PID}" ]] && kill -0 "${SERVER_PID}" 2>/dev/null; then
kill "${SERVER_PID}" 2>/dev/null || true
fi
if [[ -n "${MCP_PID}" ]] && kill -0 "${MCP_PID}" 2>/dev/null; then
kill "${MCP_PID}" 2>/dev/null || true
fi
}
trap cleanup EXIT
if [[ -z "${TARGET_BASE_URL}" ]]; then
export LIVE_REPOS="${LIVE_REPOS:-/tmp/hyperstition-live-repos}"
rm -rf "${LIVE_REPOS}"
echo "[1/3] Hydrating per-repository webroot at ${LIVE_REPOS} via sync-vps-repos.sh --no-pull..."
echo "[1/4] Hydrating per-repository webroot at ${LIVE_REPOS} via sync-vps-repos.sh --no-pull..."
"${SCRIPT_DIR}/sync-vps-repos.sh" --no-pull
PORT="${TEST_PORT:-18090}"
echo "[2/3] Starting local HTTP server on http://127.0.0.1:${PORT} serving ${LIVE_REPOS}..."
MCP_PORT="${TEST_MCP_PORT:-18095}"
echo "[2/4] Starting local HTTP server on http://127.0.0.1:${PORT} and MCP HTTP server on http://127.0.0.1:${MCP_PORT}/mcp..."
python3 -m http.server "${PORT}" --bind 127.0.0.1 --directory "${LIVE_REPOS}" >/dev/null 2>&1 &
SERVER_PID="$!"
PYTHONPATH="${SCRIPT_DIR}/../src" python3 "${SCRIPT_DIR}/../src/hyperstitionstud_io/mcp/server.py" --transport http --host 127.0.0.1 --port "${MCP_PORT}" >/dev/null 2>&1 &
MCP_PID="$!"
sleep 0.6
TARGET_BASE_URL="http://127.0.0.1:${PORT}"
MCP_URL="http://127.0.0.1:${MCP_PORT}/mcp"
else
MCP_URL="${TARGET_BASE_URL%/}/mcp"
fi
echo "[3/3] Verifying all 35 portal, /learn/, /gallery/, graph, encyclopedia, haiperdohp-jemaytreeah (.gitignore artifacts), CI & schema routes against ${TARGET_BASE_URL}..."
@@ -89,4 +99,19 @@ for route in "${ROUTES[@]}"; do
fi
done
echo "[OK] All ${PASS_COUNT}/${#ROUTES[@]} deployment routes verified (HTTP 200 OK)."
echo "[4/4] Verifying stateless read-only MCP Streamable HTTP endpoint (${MCP_URL})..."
mcp_get_code="$(curl -s -o /dev/null -w "%{http_code}" "${MCP_URL}")"
if [[ "${mcp_get_code}" != "200" ]]; then
echo " [FAIL ${mcp_get_code}] GET ${MCP_URL}" >&2
exit 1
fi
echo " [200 OK] GET ${MCP_URL} (MCP capability manifest)"
mcp_post_out="$(curl -s -X POST "${MCP_URL}" -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"hs_evaluate_aq_and_ingglish","arguments":{"terms":["capital","capture","folds"]}}}')"
if ! grep -q 'exact_gen1_singularity.*true' <<<"${mcp_post_out}"; then
echo " [FAIL] POST ${MCP_URL} did not return exact_gen1_singularity=true" >&2
exit 1
fi
echo " [200 OK] POST ${MCP_URL} (JSON-RPC 2.0 tools/call hs_evaluate_aq_and_ingglish verified)"
echo "[OK] All ${PASS_COUNT}/${#ROUTES[@]} static routes + 2 MCP HTTP endpoints verified (HTTP 200 OK)."