Spaces:
Running
Running
Add 02-setup-rea-agents.sh service to auto-register REA MCP in Hermes, Claude Code, OpenCode, DSH, and VS Code
Browse files- services/02-setup-rea-agents.sh +105 -0
services/02-setup-rea-agents.sh
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# 02-setup-rea-agents.sh — Ensure REA MCP is registered across all coding agents on /data
|
| 3 |
+
# (Hermes, Claude Code, OpenCode, DeepSeek Harness, VS Code)
|
| 4 |
+
|
| 5 |
+
LOG="/tmp/logs/setup-rea-agents.log"
|
| 6 |
+
mkdir -p /tmp/logs /data/config/opencode /data/config/dsh /data/workspace/.vscode /root/.config
|
| 7 |
+
|
| 8 |
+
echo "🔧 Configuring REA MCP across all coding agents..." > "$LOG"
|
| 9 |
+
|
| 10 |
+
# 1. Hermes Agent MCP registration (/home/appuser/.hermes/config.yaml & /data/apps/hermes/config.yaml)
|
| 11 |
+
mkdir -p /home/appuser/.hermes /data/apps/hermes
|
| 12 |
+
python3 -c '
|
| 13 |
+
import yaml, os
|
| 14 |
+
|
| 15 |
+
for p in ["/home/appuser/.hermes/config.yaml", "/data/apps/hermes/config.yaml"]:
|
| 16 |
+
os.makedirs(os.path.dirname(p), exist_ok=True)
|
| 17 |
+
d = {}
|
| 18 |
+
if os.path.exists(p):
|
| 19 |
+
try:
|
| 20 |
+
d = yaml.safe_load(open(p)) or {}
|
| 21 |
+
except Exception:
|
| 22 |
+
pass
|
| 23 |
+
servers = d.setdefault("mcp_servers", {})
|
| 24 |
+
servers["rea"] = {
|
| 25 |
+
"command": "/usr/local/bin/rea",
|
| 26 |
+
"args": ["mcp"],
|
| 27 |
+
"enabled": True
|
| 28 |
+
}
|
| 29 |
+
with open(p, "w") as f:
|
| 30 |
+
yaml.safe_dump(d, f)
|
| 31 |
+
print("Registered REA in Hermes config:", p)
|
| 32 |
+
' >> "$LOG" 2>&1 || true
|
| 33 |
+
|
| 34 |
+
# 2. OpenCode CLI MCP registration (/root/.config/opencode/opencode.json & /data/config/opencode/opencode.json)
|
| 35 |
+
python3 -c '
|
| 36 |
+
import json, os
|
| 37 |
+
|
| 38 |
+
for p in ["/data/config/opencode/opencode.json", "/data/workspace/.opencode/opencode.json", "/root/.config/opencode/opencode.json"]:
|
| 39 |
+
os.makedirs(os.path.dirname(p), exist_ok=True)
|
| 40 |
+
d = {}
|
| 41 |
+
if os.path.exists(p):
|
| 42 |
+
try:
|
| 43 |
+
d = json.load(open(p))
|
| 44 |
+
except Exception:
|
| 45 |
+
pass
|
| 46 |
+
mcp = d.setdefault("mcp", {})
|
| 47 |
+
mcp["rea"] = {
|
| 48 |
+
"type": "local",
|
| 49 |
+
"command": ["/usr/local/bin/rea", "mcp"],
|
| 50 |
+
"enabled": True
|
| 51 |
+
}
|
| 52 |
+
with open(p, "w") as f:
|
| 53 |
+
json.dump(d, f, indent=2)
|
| 54 |
+
print("Registered REA in OpenCode config:", p)
|
| 55 |
+
' >> "$LOG" 2>&1 || true
|
| 56 |
+
|
| 57 |
+
# 3. Claude Code CLI MCP registration (~/.claude/mcp.json & /data/workspace/.claude/mcp.json)
|
| 58 |
+
mkdir -p /root/.claude /data/workspace/.claude
|
| 59 |
+
python3 -c '
|
| 60 |
+
import json, os
|
| 61 |
+
|
| 62 |
+
for p in ["/root/.claude/mcp.json", "/data/workspace/.claude/mcp.json", "/data/code-server/User/mcp.json", "/data/workspace/.vscode/mcp.json"]:
|
| 63 |
+
os.makedirs(os.path.dirname(p), exist_ok=True)
|
| 64 |
+
d = {}
|
| 65 |
+
if os.path.exists(p):
|
| 66 |
+
try:
|
| 67 |
+
d = json.load(open(p))
|
| 68 |
+
except Exception:
|
| 69 |
+
pass
|
| 70 |
+
servers = d.setdefault("mcpServers", {})
|
| 71 |
+
servers["rea"] = {
|
| 72 |
+
"command": "/usr/local/bin/rea",
|
| 73 |
+
"args": ["mcp"]
|
| 74 |
+
}
|
| 75 |
+
with open(p, "w") as f:
|
| 76 |
+
json.dump(d, f, indent=2)
|
| 77 |
+
print("Registered REA in Claude/VSCode config:", p)
|
| 78 |
+
' >> "$LOG" 2>&1 || true
|
| 79 |
+
|
| 80 |
+
# 4. DeepSeek Harness (DSH) MCP registration (/data/config/dsh/dsh.json & /root/.dsh/config.json)
|
| 81 |
+
mkdir -p /data/config/dsh /root/.dsh
|
| 82 |
+
python3 -c '
|
| 83 |
+
import json, os
|
| 84 |
+
|
| 85 |
+
for p in ["/data/config/dsh/dsh.json", "/root/.dsh/config.json"]:
|
| 86 |
+
os.makedirs(os.path.dirname(p), exist_ok=True)
|
| 87 |
+
d = {}
|
| 88 |
+
if os.path.exists(p):
|
| 89 |
+
try:
|
| 90 |
+
d = json.load(open(p))
|
| 91 |
+
except Exception:
|
| 92 |
+
pass
|
| 93 |
+
mcp = d.setdefault("mcp", {})
|
| 94 |
+
mcp["rea"] = {
|
| 95 |
+
"command": "/usr/local/bin/rea",
|
| 96 |
+
"args": ["mcp"],
|
| 97 |
+
"enabled": True
|
| 98 |
+
}
|
| 99 |
+
with open(p, "w") as f:
|
| 100 |
+
json.dump(d, f, indent=2)
|
| 101 |
+
print("Registered REA in DSH config:", p)
|
| 102 |
+
' >> "$LOG" 2>&1 || true
|
| 103 |
+
|
| 104 |
+
echo "✅ All agent configurations injected with REA MCP." >> "$LOG"
|
| 105 |
+
exit 0
|