-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.command
More file actions
executable file
·109 lines (96 loc) · 6.6 KB
/
setup.command
File metadata and controls
executable file
·109 lines (96 loc) · 6.6 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# ─────────────────────────────────────────────────────────────────────────────
# Smart Speaker MCP — One-Time Setup
# After this: use the VS Code task "🔄 Rebuild + Restart Claude" after edits.
# ─────────────────────────────────────────────────────────────────────────────
cd "$(dirname "$0")"
PROJECT_DIR="$(pwd)"
BINARY_PATH="$PROJECT_DIR/smart-speaker-mcp"
CONFIG_DIR="$HOME/Library/Application Support/Claude"
CONFIG_FILE="$CONFIG_DIR/claude_desktop_config.json"
echo ""
echo "╔════════════════════════════════════════════════════╗"
echo "║ Smart Speaker MCP — Setup ║"
echo "╚════════════════════════════════════════════════════╝"
echo ""
# ── Go ────────────────────────────────────────────────────────────────────────
echo "▶ Checking Go..."
if ! command -v go &>/dev/null; then
echo " ❌ Go not found. Install from https://go.dev/dl/"; exit 1
fi
echo " ✅ $(go version)"
# ── yt-dlp ───────────────────────────────────────────────────────────────────
echo "▶ Checking yt-dlp..."
if ! command -v yt-dlp &>/dev/null; then
pip3 install yt-dlp --quiet || pip install yt-dlp --quiet
fi
echo " ✅ yt-dlp ready"
# ── Dependencies ──────────────────────────────────────────────────────────────
echo "▶ Downloading Go dependencies..."
go mod tidy && go mod download
echo " ✅ Done"
# ── Static analysis (catches imports-out-of-order, unused vars, format strings, etc.) ─
echo "▶ Running go vet..."
if ! go vet ./...; then
echo " ❌ go vet found problems — fix them and re-run setup."
exit 1
fi
echo " ✅ vet passed"
# ── Build ─────────────────────────────────────────────────────────────────────
echo "▶ Building binary for $(uname -m)..."
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/WeCodeBase/smart-speaker-mcp/internal/mcpserver.Version=4.0.0" -o smart-speaker-mcp ./cmd/smart-speaker-mcp
if [ $? -ne 0 ]; then echo " ❌ Build failed"; exit 1; fi
echo " ✅ $BINARY_PATH"
# ── Create .env config if it doesn't exist ───────────────────────────────────
ENV_FILE="$HOME/.config/smart-speaker-mcp/.env"
mkdir -p "$HOME/.config/smart-speaker-mcp"
if [ ! -f "$ENV_FILE" ]; then
echo "▶ Creating $ENV_FILE ..."
cat > "$ENV_FILE" << 'ENVEOF'
# ─────────────────────────────────────────────────────────────────────────────
# Smart Speaker MCP — Environment Config
# Edit this file to change settings. Restart Claude Desktop to apply.
# ─────────────────────────────────────────────────────────────────────────────
# ── Playback defaults ─────────────────────────────────────────────────────────
SMART_SPEAKER_DEFAULT_DEVICE=Family Room speaker
SMART_SPEAKER_SOURCE=local
# ── Local music ───────────────────────────────────────────────────────────────
SMART_SPEAKER_MUSIC_DIR=~/Music
# ── yt-dlp (auto-detected from PATH if blank) ────────────────────────────────
SMART_SPEAKER_YTDLP_PATH=
ENVEOF
echo " ✅ Created: $ENV_FILE"
else
echo " ✅ .env already exists: $ENV_FILE (not overwritten)"
fi
echo ""
# ── Claude Desktop config ─────────────────────────────────────────────────────
echo "▶ Registering with Claude Desktop..."
mkdir -p "$CONFIG_DIR"
python3 - <<PYEOF
import json, os
cfg = {}
if os.path.exists("$CONFIG_FILE"):
try:
cfg = json.load(open("$CONFIG_FILE"))
except: pass
cfg.setdefault("mcpServers", {})
cfg["mcpServers"]["smart-speaker"] = {"command": "$BINARY_PATH", "args": []}
json.dump(cfg, open("$CONFIG_FILE", "w"), indent=2)
print(" ✅ Registered: $BINARY_PATH")
PYEOF
echo ""
echo "╔════════════════════════════════════════════════════════════════╗"
echo "║ ✅ Setup complete! ║"
echo "║ ║"
echo "║ After any code change, rebuild + restart Claude: ║"
echo "║ ║"
echo "║ • macOS / Linux → make rebuild ║"
echo "║ • Windows (PS) → make rebuild (Git Bash / MSYS / WSL) ║"
echo "║ …or: go build . + restart Claude ║"
echo "║ • VS Code → ⌘⇧P → Run Task → 🔄 Rebuild + Restart ║"
echo "║ ║"
echo "║ Just rebuild (no restart): make build / go build . ║"
echo "║ Just restart Claude: make restart-claude ║"
echo "╚════════════════════════════════════════════════════════════════╝"
echo ""