state-hub/scripts/codex-state-hub-mcp.sh
tegwick 5927591be8
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 1m0s
Prepare State Hub retirement baseline
2026-08-09 16:19:53 +02:00

37 lines
948 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
STATE_HUB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
STATE_HUB_PYTHON="${STATE_HUB_PYTHON:-$STATE_HUB_DIR/.venv/bin/python}"
cd "$STATE_HUB_DIR"
API_BASE="${API_BASE:-http://127.0.0.1:8000}"
HEALTH_URL="${API_BASE%/}/state/health"
LOG_FILE="${STATE_HUB_API_LOG:-/tmp/state-hub-api-for-codex.log}"
api_healthy() {
curl -sf "$HEALTH_URL" >/dev/null
}
if ! api_healthy; then
nohup make api >"$LOG_FILE" 2>&1 &
for _ in $(seq 1 45); do
api_healthy && break
sleep 1
done
fi
if ! api_healthy; then
echo "state-hub API is not healthy at $HEALTH_URL; see $LOG_FILE" >&2
exit 1
fi
if [ ! -x "$STATE_HUB_PYTHON" ]; then
echo "state-hub Python is not executable at $STATE_HUB_PYTHON" >&2
echo "install the repository environment before starting the Codex MCP server" >&2
exit 1
fi
export API_BASE
export MCP_TRANSPORT=stdio
exec "$STATE_HUB_PYTHON" mcp_server/codex_server.py