Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·94 lines (83 loc) · 3.33 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·94 lines (83 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
# One-time setup: install the Magic Hour MCP server and register it
# with Claude Code and Codex CLI.
set -euo pipefail
cd "$(dirname "$0")"
source ./duel.config
: "${MAGIC_HOUR_API_KEY:?export MAGIC_HOUR_API_KEY before running setup}"
# --- dependency check -------------------------------------------------------
APT_PKGS=()
need() { command -v "$1" >/dev/null 2>&1; }
need git || { echo "MISSING: git"; APT_PKGS+=(git); }
need curl || { echo "MISSING: curl"; APT_PKGS+=(curl); }
if ! need ffmpeg || ! need ffprobe; then
echo "MISSING: ffmpeg/ffprobe"; APT_PKGS+=(ffmpeg)
fi
need python3 || { echo "MISSING: python3"; APT_PKGS+=(python3 python3-venv python3-pip); }
# stock Ubuntu/WSL ships python3 without the venv module
if need python3 && ! python3 -m venv --help >/dev/null 2>&1; then
echo "MISSING: python3-venv module"; APT_PKGS+=(python3-venv)
fi
if [ ${#APT_PKGS[@]} -gt 0 ]; then
if need apt-get; then
echo
read -r -p "Install missing packages now? (sudo apt-get install ${APT_PKGS[*]}) [Y/n] " ans || ans=Y
case "${ans:-Y}" in
[Yy]*|"") sudo apt-get update && sudo apt-get install -y "${APT_PKGS[@]}" ;;
*) echo "Install them yourself, then re-run ./setup.sh"; exit 1 ;;
esac
else
echo "No apt-get on this system — install manually: ${APT_PKGS[*]}"; exit 1
fi
fi
CLI_MISSING=0
if ! need claude; then
CLI_MISSING=1
cat <<'HELP'
MISSING: claude (Claude Code CLI) — install it INSIDE WSL, e.g.:
npm install -g @anthropic-ai/claude-code
then log in with: claude
Docs: https://docs.claude.com/en/docs/claude-code/overview
HELP
fi
if ! need codex; then
CLI_MISSING=1
cat <<'HELP'
MISSING: codex (Codex CLI) — install it INSIDE WSL, e.g.:
npm install -g @openai/codex
then log in with: codex
Docs: https://developers.openai.com/codex/cli
HELP
fi
if [ "$CLI_MISSING" = 1 ]; then
echo "(npm itself comes from Node.js: sudo apt-get install -y nodejs npm, or use nvm)"
echo "Install the CLI(s) above, then re-run ./setup.sh"
exit 1
fi
echo "✓ dependencies present"
# --- Magic Hour MCP server --------------------------------------------------
if [ ! -d mcp-server ]; then
git clone https://github.com/magichourhq/magic-hour-mcp mcp-server
fi
python3 -m venv .venv
./.venv/bin/pip install --quiet -e ./mcp-server
echo "✓ MCP server installed (start it with ./serve.sh)"
# --- register with Claude Code (user scope: works from any cwd) -------------
claude mcp remove magic-hour --scope user >/dev/null 2>&1 || true
claude mcp add --scope user --transport http magic-hour "$MCP_URL" \
--header "Authorization: Bearer $MAGIC_HOUR_API_KEY"
echo "✓ registered with Claude Code"
# --- register with Codex CLI ------------------------------------------------
codex mcp remove magic-hour >/dev/null 2>&1 || true
codex mcp add magic-hour --url "$MCP_URL" \
--bearer-token-env-var MAGIC_HOUR_API_KEY
echo "✓ registered with Codex (verify: codex mcp get magic-hour --json)"
cat <<'EOF'
Next steps:
1. Terminal A: ./serve.sh (keep it running)
2. ONE-TIME ARMING for unattended Claude runs:
claude --dangerously-skip-permissions
...accept the warning, ask it to "call the magic-hour ping tool", quit.
3. ./run.sh <fable|sol> <sunscreen|burger|codex-micro|bigben> [credits]
(same shell as the API key export — Codex needs it for MCP auth)
EOF