videogen/scripts/setup-cloudflare-codex.sh
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

87 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Register and verify Cloudflare's official managed MCP servers for Codex.
#
# This script is intentionally secret-free. It does not install packages,
# deploy resources, read repository environment files, or manage Cloudflare
# credentials. The first MCP tool call may open Cloudflare OAuth in a browser.
set -euo pipefail
log() { printf '[cloudflare-codex] %s\n' "$*"; }
fail() { printf '[cloudflare-codex] ERROR: %s\n' "$*" >&2; exit 1; }
usage() {
cat <<'EOF'
Usage: ./scripts/setup-cloudflare-codex.sh [--verify-only]
Without arguments, add any missing official Cloudflare MCP registrations and
then verify Codex and Wrangler. --verify-only performs read-only checks.
EOF
}
VERIFY_ONLY=0
case "${1:-}" in
"") ;;
--verify-only) VERIFY_ONLY=1 ;;
-h|--help) usage; exit 0 ;;
*) usage >&2; exit 2 ;;
esac
[ "$#" -le 1 ] || { usage >&2; exit 2; }
command -v codex >/dev/null 2>&1 || fail "codex is not on PATH. Install or open Codex, then retry."
command -v wrangler >/dev/null 2>&1 || fail "wrangler is not on PATH. Install Wrangler v4+, then retry."
# Wrangler otherwise writes under the macOS user Library, which can be
# unavailable in sandboxes. Keep diagnostics in a caller-selected directory or
# in the operating system's writable temporary directory.
if [ -z "${WRANGLER_LOG_PATH:-}" ]; then
WRANGLER_LOG_PATH="${TMPDIR:-/tmp}/videogen-wrangler.log"
fi
export WRANGLER_LOG_PATH
WRANGLER_LOG_DIR="$(dirname "$WRANGLER_LOG_PATH")"
mkdir -p "$WRANGLER_LOG_DIR"
WRITABLE_PROBE="$WRANGLER_LOG_DIR/.videogen-wrangler-write-probe.$$"
: > "$WRITABLE_PROBE" || fail "Wrangler log directory is not writable: $WRANGLER_LOG_PATH"
rm -f "$WRITABLE_PROBE"
log "Wrangler logs: $WRANGLER_LOG_PATH"
WRANGLER_VERSION="$(wrangler --version 2>/dev/null | awk 'NR == 1 { print $1 }')"
case "$WRANGLER_VERSION" in
4.*) log "Wrangler $WRANGLER_VERSION detected." ;;
*) fail "Wrangler v4+ is required; detected '${WRANGLER_VERSION:-unknown}'." ;;
esac
# Source: https://developers.cloudflare.com/agent-setup/codex/
MCP_SPECS=(
"cloudflare|https://mcp.cloudflare.com/mcp"
"cloudflare-docs|https://docs.mcp.cloudflare.com/mcp"
"cloudflare-bindings|https://bindings.mcp.cloudflare.com/mcp"
"cloudflare-builds|https://builds.mcp.cloudflare.com/mcp"
"cloudflare-observability|https://observability.mcp.cloudflare.com/mcp"
)
for spec in "${MCP_SPECS[@]}"; do
IFS='|' read -r name url <<< "$spec"
if current="$(codex mcp get "$name" 2>/dev/null)"; then
if printf '%s\n' "$current" | grep -Fq "$url"; then
log "$name already uses the official endpoint."
else
fail "$name already exists with a different configuration. Review 'codex mcp get $name'; no changes were made to it."
fi
elif [ "$VERIFY_ONLY" -eq 1 ]; then
fail "$name is missing. Run this script without --verify-only to add it."
else
log "Adding $name."
codex mcp add "$name" --url "$url"
fi
done
log "Registered Codex MCP servers:"
codex mcp list
# CI suppresses Wrangler's optional interactive error-reporting prompt while
# preserving the authenticated account check.
log "Checking Wrangler OAuth authentication."
CI=1 wrangler whoami
log "Cloudflare Codex setup verified. OAuth for each MCP server is completed on its first tool call."