@@ -6,6 +6,7 @@ CONFIG_DIR="${OPENCODE_CONFIG_DIR:-${HOME:-}/.config/opencode}"
66SOURCE_DIR=" "
77FORCE=" 0"
88DRY_RUN=" 0"
9+ ENABLE_MCP=" 0"
910
1011usage () {
1112 cat << 'EOF '
1718Options:
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)
113119done
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+
115179cat << EOF
116180
117181Render OpenCode files installed.
118182
183+ $( if [[ " $ENABLE_MCP " == " 1" ]]; then echo " Set RENDER_API_KEY before using Render MCP." ; fi)
184+
119185Restart OpenCode so it can load new plugins, skills, commands, and agents.
120186EOF
0 commit comments