Skip to content

Commit aa28e86

Browse files
committed
Add support for enabling Render MCP server in installation script and update README with usage instructions
1 parent d871e74 commit aa28e86

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ Preview changes without writing files:
4141
curl -fsSL https://raw.githubusercontent.com/render-oss/render-opencode-plugin/main/install.sh | bash -s -- --dry-run
4242
```
4343

44+
Install the Render MCP server config too:
45+
46+
```bash
47+
curl -fsSL https://raw.githubusercontent.com/render-oss/render-opencode-plugin/main/install.sh | bash -s -- --enable-mcp
48+
```
49+
50+
This preserves your existing `opencode.json` fields and skips an existing `mcp.render` entry unless you pass `--force`. Set `RENDER_API_KEY` before using Render MCP.
51+
4452
Restart OpenCode after installation.
4553

4654
### Install from npm

install.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CONFIG_DIR="${OPENCODE_CONFIG_DIR:-${HOME:-}/.config/opencode}"
66
SOURCE_DIR=""
77
FORCE="0"
88
DRY_RUN="0"
9+
ENABLE_MCP="0"
910

1011
usage() {
1112
cat <<'EOF'
@@ -17,6 +18,7 @@ Usage:
1718
Options:
1819
--config-dir <path> Target OpenCode config directory. Defaults to ~/.config/opencode.
1920
--source <path> Use a local repo checkout instead of downloading from GitHub.
21+
--enable-mcp Add the Render MCP server to opencode.json.
2022
--force Overwrite existing files.
2123
--dry-run Print what would change without writing files.
2224
-h, --help Show this help.
@@ -37,6 +39,10 @@ while [[ $# -gt 0 ]]; do
3739
FORCE="1"
3840
shift
3941
;;
42+
--enable-mcp)
43+
ENABLE_MCP="1"
44+
shift
45+
;;
4046
--dry-run)
4147
DRY_RUN="1"
4248
shift
@@ -112,9 +118,69 @@ for dir in plugins skills commands agents; do
112118
done < <(find "$ASSETS_DIR/$dir" -type f -print0)
113119
done
114120

121+
install_mcp_config() {
122+
local config_path="$CONFIG_DIR/opencode.json"
123+
124+
if ! command -v python3 >/dev/null 2>&1; then
125+
echo "Cannot enable MCP because python3 is not installed." >&2
126+
exit 1
127+
fi
128+
129+
if [[ "$DRY_RUN" == "1" ]]; then
130+
echo "would merge Render MCP server into $config_path"
131+
return
132+
fi
133+
134+
mkdir -p "$CONFIG_DIR"
135+
136+
CONFIG_PATH="$config_path" FORCE="$FORCE" python3 <<'PY'
137+
import json
138+
import os
139+
from pathlib import Path
140+
141+
config_path = Path(os.environ["CONFIG_PATH"])
142+
force = os.environ.get("FORCE") == "1"
143+
144+
if config_path.exists() and config_path.read_text().strip():
145+
config = json.loads(config_path.read_text())
146+
else:
147+
config = {"$schema": "https://opencode.ai/config.json"}
148+
149+
if not isinstance(config, dict):
150+
raise SystemExit(f"{config_path} must contain a JSON object.")
151+
152+
mcp = config.setdefault("mcp", {})
153+
if not isinstance(mcp, dict):
154+
raise SystemExit(f"{config_path} has a non-object mcp field.")
155+
156+
if "render" in mcp and not force:
157+
print(f"skipped existing Render MCP config in {config_path}")
158+
raise SystemExit(0)
159+
160+
mcp["render"] = {
161+
"type": "remote",
162+
"url": "https://mcp.render.com/mcp",
163+
"enabled": True,
164+
"oauth": False,
165+
"headers": {
166+
"Authorization": "Bearer {env:RENDER_API_KEY}",
167+
},
168+
}
169+
170+
config_path.write_text(json.dumps(config, indent=2) + "\n")
171+
print(f"merged Render MCP server into {config_path}")
172+
PY
173+
}
174+
175+
if [[ "$ENABLE_MCP" == "1" ]]; then
176+
install_mcp_config
177+
fi
178+
115179
cat <<EOF
116180
117181
Render OpenCode files installed.
118182
183+
$(if [[ "$ENABLE_MCP" == "1" ]]; then echo "Set RENDER_API_KEY before using Render MCP."; fi)
184+
119185
Restart OpenCode so it can load new plugins, skills, commands, and agents.
120186
EOF

0 commit comments

Comments
 (0)