Skip to content

Open-source Revit MCP server: let Claude and other AI assistants read and edit BIM models, with human approval on every change.

fix: codex arg injection via dash-prefixed chat messages, build script still hard-fails on Rhino/PowerBI

A. Sam Mohammadd835ea27c6d3
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/agent_bridge.py b/packages/mcp-server-revit/src/revit_mcp_server/agent_bridge.py
index dc5810f..fbe5b0c 100644
--- a/packages/mcp-server-revit/src/revit_mcp_server/agent_bridge.py
+++ b/packages/mcp-server-revit/src/revit_mcp_server/agent_bridge.py
@@ -150,7 +150,10 @@ def _run_codex_turn(message: str, session_id: Optional[str]) -> Dict[str, Any]:
base = [codex_path, "exec"]
if session_id:
base += ["resume", session_id]
- base += [message, "--sandbox", "read-only", "--skip-git-repo-check", "--json", "-o", out_path]
+ # message is untrusted user input and must not be parsed as a flag if
+ # it starts with "-" — "--" tells codex's CLI parser everything after
+ # it is positional, so flags all go before it, message last.
+ base += ["--sandbox", "read-only", "--skip-git-repo-check", "--json", "-o", out_path, "--", message]
try:
proc = subprocess.run(base, capture_output=True, encoding="utf-8", stdin=subprocess.DEVNULL, timeout=_TURN_TIMEOUT_SECONDS)
diff --git a/packages/mcp-server-revit/tests/test_agent_bridge.py b/packages/mcp-server-revit/tests/test_agent_bridge.py
index 5453efe..6657076 100644
--- a/packages/mcp-server-revit/tests/test_agent_bridge.py
+++ b/packages/mcp-server-revit/tests/test_agent_bridge.py
@@ -114,6 +114,33 @@ def test_codex_missing_cli(monkeypatch):
assert "codex" in result["error"]
+def test_codex_message_starting_with_dash_is_not_parsed_as_a_flag(monkeypatch):
+ monkeypatch.setattr(agent_bridge, "_CODEX_REGISTRATION_CHECKED", True)
+ monkeypatch.setattr(agent_bridge.shutil, "which", lambda _name: "/usr/bin/codex")
+
+ captured = {}
+
+ def fake_run(args, **kwargs):
+ captured["args"] = args
+ out_index = args.index("-o") + 1
+ with open(args[out_index], "w", encoding="utf-8") as f:
+ f.write("done")
+ return _completed(args, stdout="")
+
+ monkeypatch.setattr(agent_bridge.subprocess, "run", fake_run)
+
+ agent_bridge.run_agent_turn("codex", "-fix the wall heights", None)
+
+ args = captured["args"]
+ assert "--" in args
+ dash_index = args.index("--")
+ # everything before "--" must be a recognized flag/value, the message
+ # must be the last argument, after "--", so codex's parser can't treat
+ # a leading "-" in the message as a flag.
+ assert args[dash_index + 1] == "-fix the wall heights"
+ assert dash_index + 1 == len(args) - 1
+
+
def test_codex_success_reads_last_message_file(monkeypatch, tmp_path):
monkeypatch.setattr(agent_bridge, "_CODEX_REGISTRATION_CHECKED", True)
monkeypatch.setattr(agent_bridge.shutil, "which", lambda _name: "/usr/bin/codex")
diff --git a/scripts/build-addin.ps1 b/scripts/build-addin.ps1
index 78af35a..f11c222 100644
--- a/scripts/build-addin.ps1
+++ b/scripts/build-addin.ps1
@@ -89,8 +89,10 @@ if (Test-Path $rhinoPath) {
& $dotnet.Source build $rhinoPath -c $Configuration -v:minimal
if ($LASTEXITCODE -ne 0) {
- Write-Error "Rhino build failed with exit code $LASTEXITCODE"
- # Don't exit here so we don't fail the whole build if just Rhino fails
+ # Write-Host, not Write-Error: with $ErrorActionPreference = "Stop" (top
+ # of this script), Write-Error is a terminating error and would abort
+ # the whole script here, exactly what this branch exists to avoid.
+ Write-Host "Rhino build failed with exit code $LASTEXITCODE - continuing." -ForegroundColor Yellow
} else {
Write-Host "Rhino Build succeeded" -ForegroundColor Green
}
@@ -103,7 +105,10 @@ if (Test-Path $pbiPath) {
& $dotnet.Source build $pbiPath -c $Configuration -v:minimal
if ($LASTEXITCODE -ne 0) {
- Write-Error "Power BI build failed with exit code $LASTEXITCODE"
+ # Write-Host, not Write-Error - see the identical note on the Rhino
+ # build above; Write-Error would abort the script under
+ # $ErrorActionPreference = "Stop".
+ Write-Host "Power BI build failed with exit code $LASTEXITCODE - continuing." -ForegroundColor Yellow
} else {
Write-Host "Power BI Build succeeded" -ForegroundColor Green