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(chat): block model self-approval of plans and surface tool errors to the model

sammohammad578ee441c0ff370
diff --git a/docs/0012-native-agent-chat-backend.md b/docs/0012-native-agent-chat-backend.md
index e9c268c..5b5726d 100644
--- a/docs/0012-native-agent-chat-backend.md
+++ b/docs/0012-native-agent-chat-backend.md
@@ -21,7 +21,10 @@ Build a native Anthropic tool-calling loop (`agent_native.py`, added in a later
Keep the existing `agent_bridge.py` CLI-shelling path as an explicit fallback for power users who have the CLI installed and authenticated. This path is not being removed because it is a real, currently working path for users who prefer it.
### 3. Configuration Surface
-The `anthropic_api_key` field is added to the `Config` class (`config.py`). It follows the existing `MCP_REVIT_`-prefixed pydantic-settings pattern, requiring no bespoke settings-loading code — environment variables and `.env` files are auto-discovered by the existing loader.
+The `anthropic_api_key` field is added to the `Config` class (`config.py`). It follows the existing `MCP_REVIT_`-prefixed pydantic-settings pattern, requiring no bespoke settings-loading code — environment variables and `.env` files are auto-discovered by the existing loader. This is the only way to supply the key today: the panel's Settings view has no API-key field (an earlier UI-only field that saved nothing was removed), and the hub reads config once at startup, so setting or changing `MCP_REVIT_ANTHROPIC_API_KEY` requires a Revit restart. Persisting a key from the UI is a separate, not-yet-made design decision. See `docs/configuration-reference.md`.
+
+### 4. Trust Model: The Model Cannot Approve Its Own Plans
+The native loop hands the model every registry tool **except** `approve_plan`, `reject_plan` and `rollback_plan` (`agent_native._MODEL_EXCLUDED_TOOLS`), and refuses those names at execution time if the model emits them anyway. That exclusion carries the approval workflow's guarantee. None of the plan-lifecycle tools is `is_mutating`, so the per-call `ApprovalGate.check_tool_execution` check never runs for them, and `execute_plan` only checks that the plan's state is `approved`. If the model could call `approve_plan`, it could run `plan_actions` → `approve_plan` → `execute_plan` with no human involved. With the exclusion, the model can propose plans (`plan_actions`), inspect them (`list_pending_plans`) and run plans that are already approved (`execute_plan`), but only a human can move a plan to `approved`. The human does that by clicking Approve/Reject in the panel's Plans view, which the add-in relays (`BridgePanel`'s `plan.approve`/`plan.reject`) straight to the hub's `/execute` endpoint, outside the chat loop. Per-tool-call failures, including gate rejections, go back to the model as `is_error` tool results so it can explain them. They do not abort the turn.
## Consequences
- **Chat Works Out of the Box**: Users can enable chat with just an API key, eliminating the CLI install/login dependency that blocked adoption
diff --git a/docs/configuration-reference.md b/docs/configuration-reference.md
index 2d090b5..7918652 100644
--- a/docs/configuration-reference.md
+++ b/docs/configuration-reference.md
@@ -19,6 +19,7 @@ The server supports two runtime modes:
| `MCP_REVIT_ALLOWED_DIRECTORIES` | Yes | none | Semicolon-separated directories the server may access. |
| `MCP_REVIT_WORKSPACE_DIR` | Yes | none | Root directory for generated files and workspace-backed tools. |
| `MCP_REVIT_AUDIT_LOG` | No | `workspace/audit.jsonl` | Audit log path used by the security layer. |
+| `MCP_REVIT_ANTHROPIC_API_KEY` | No | unset | Anthropic API key for the panel's native Claude chat (`agent_native.py`, ADR 0012). If you don't set it, "Claude" chat falls back to the `claude` CLI when that's on PATH. Otherwise no AI provider is available. You can also put it in a `.env` file. The hub reads it only at startup, so restart Revit after you set or change it. The panel's Settings view can't set it. |
| `REVIT_SDK` | Build only | unset | Optional path used by the add-in build scripts. |
## Package and Registry Metadata
diff --git a/packages/mcp-server-revit/pyproject.toml b/packages/mcp-server-revit/pyproject.toml
index 6d2d576..7229130 100644
--- a/packages/mcp-server-revit/pyproject.toml
+++ b/packages/mcp-server-revit/pyproject.toml
@@ -21,7 +21,10 @@ dependencies = [
"specklepy>=3,<4",
"pyyaml>=6.0",
"openpyxl>=3.1",
- "anthropic>=0.34",
+ # agent_native.py replays response.content (incl. thinking blocks, which
+ # Claude Opus 5 emits by default) back into history, and marks the tools
+ # list with cache_control - pinned to the SDK version verified against both.
+ "anthropic>=0.99",
]
[project.scripts]
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/agent_native.py b/packages/mcp-server-revit/src/revit_mcp_server/agent_native.py
index bdc24f7..8d50d67 100644
--- a/packages/mcp-server-revit/src/revit_mcp_server/agent_native.py
+++ b/packages/mcp-server-revit/src/revit_mcp_server/agent_native.py
@@ -57,17 +57,35 @@ _TURN_CAP_ERROR = (
"without a final response."
)
-_MISSING_KEY_ERROR = "No Anthropic API key configured. Add one in Settings."
+_MISSING_KEY_ERROR = (
+ "No Anthropic API key configured. Set the MCP_REVIT_ANTHROPIC_API_KEY "
+ "environment variable and restart Revit."
+)
_SYSTEM_PROMPT = (
"You are the AI assistant embedded in the AEC Model Bridge Revit panel. "
"You can call the provided tools to inspect and modify the open Revit "
- "model. Mutating tools require an approved plan (plan_actions, then a "
- "human approves it via approve_plan) before they will execute; if a "
- "mutating call is rejected because no approved plan backs it, explain "
- "that to the user rather than retrying blindly."
+ "model. Mutating tools require an approved plan: call plan_actions to "
+ "propose one; a human then reviews and approves it in the panel's Plans "
+ "view - you cannot approve your own plans. Once a plan is approved, call "
+ "execute_plan to run it. If a mutating call is rejected because no "
+ "approved plan backs it, tell the user to review the plan in the panel "
+ "rather than retrying blindly. If any tool call returns an error, explain "
+ "the failure to the user."
)
+# Plan-lifecycle tools the model must never be able to call. The approval
+# workflow's entire guarantee is that a HUMAN moves a plan to "approved":
+# execute_plan only checks the plan's state flag, and approve_plan is what
+# sets that flag, with no gate of its own (none of these are is_mutating).
+# If the model could call approve_plan it could propose, approve and execute
+# its own plan with no human involved. Approve/reject happen only through
+# the panel's Plans view (BridgePanel's plan.approve / plan.reject relay,
+# which calls the hub's /execute endpoint directly, outside this loop).
+# rollback_plan is excluded for the same reason: it writes to the model
+# without any plan approval of its own.
+_MODEL_EXCLUDED_TOOLS = frozenset({"approve_plan", "reject_plan", "rollback_plan"})
+
# session_id -> running message list (user/assistant/tool_result turns so
# far). In-memory only - see module docstring.
_sessions: Dict[str, List[Dict[str, Any]]] = {}
@@ -76,11 +94,21 @@ _sessions: Dict[str, List[Dict[str, Any]]] = {}
def _build_tools(registry) -> List[Dict[str, Any]]:
"""Builds the Anthropic `tools=[...]` parameter directly from the
registry's ProviderTool objects - .input_schema is already valid JSON
- Schema, no translation needed."""
- return [
+ Schema, no translation needed. Tools in _MODEL_EXCLUDED_TOOLS are never
+ offered to the model (see that constant for why).
+
+ The last tool carries an ephemeral cache_control breakpoint: the full
+ tool list is large (~200 tools, tens of KB of schema) and identical on
+ every one of up to _MAX_TURNS model calls per turn, so caching the tools
+ prefix avoids re-processing it uncached on each call."""
+ tools: List[Dict[str, Any]] = [
{"name": tool.name, "description": tool.description, "input_schema": tool.input_schema}
for tool in registry.get_all_tools()
+ if tool.name not in _MODEL_EXCLUDED_TOOLS
]
+ if tools:
+ tools[-1]["cache_control"] = {"type": "ephemeral"}
+ return tools
async def _execute_tool_call(registry, approval_provider, name: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
@@ -88,6 +116,14 @@ async def _execute_tool_call(registry, approval_provider, name: str, arguments:
_run_tool_sync: mutating tools must pass ApprovalGate.check_tool_execution
before they run. This is the safety boundary every tool-calling path in
this codebase shares - do not skip it and do not add a bypass."""
+ # Defense in depth: _build_tools never offers these, but refuse them here
+ # too in case the model emits a tool_use for a name it was not given.
+ if name in _MODEL_EXCLUDED_TOOLS:
+ raise PermissionError(
+ f"Tool '{name}' is not available to the chat assistant; plans are "
+ "approved, rejected and rolled back by a human in the panel's Plans view."
+ )
+
provider = registry.lookup_tool_provider(name)
if not provider:
raise ValueError(f"Unknown tool '{name}'")
@@ -111,17 +147,30 @@ async def _execute_tool_call(registry, approval_provider, name: str, arguments:
return result
-async def _execute_tool_calls(registry, approval_provider, tool_use_blocks: List[Any]) -> List[Tuple[str, Dict[str, Any]]]:
+async def _execute_tool_calls(
+ registry, approval_provider, tool_use_blocks: List[Any]
+) -> List[Tuple[str, Dict[str, Any], bool]]:
"""Runs every tool_use block requested in one model turn, sequentially.
+ Returns (tool_use_id, result, is_error) per block. A failing tool call
+ (approval-gate rejection, unknown tool, Revit-side error, ...) does NOT
+ raise: it becomes an {"error": ...} result with is_error=True, so the
+ model sees the failure and can explain it, and any earlier call in the
+ same turn that already succeeded (possibly a mutation) stays recorded in
+ session history instead of being rolled back and later re-applied.
+
Sequential (not asyncio.gather) is deliberate: ApprovalGate reads and
writes plan state as plain JSON files on disk, so mutating tool calls
within the same turn must not race each other against that state.
"""
- results = []
+ results: List[Tuple[str, Dict[str, Any], bool]] = []
for block in tool_use_blocks:
- result = await _execute_tool_call(registry, approval_provider, block.name, block.input)
- results.append((block.id, result))
+ try:
+ result = await _execute_tool_call(registry, approval_provider, block.name, block.input)
+ results.append((block.id, result, False))
+ except Exception as e:
+ logger.info("Native chat tool call '%s' failed: %s", block.name, e)
+ results.append((block.id, {"error": str(e)}, True))
return results
@@ -144,10 +193,11 @@ def run_native_turn(
Returns {"ok": True, "response": str, "session_id": str} on success, or
{"ok": False, "error": str} - never raises for expected failure modes
- (missing API key, Anthropic API error, tool execution failure, hitting
- the turn cap) so a later HTTP layer can pass this straight through as
- the response body, exactly like agent_bridge.run_agent_turn already
- does today.
+ (missing API key, Anthropic API error, hitting the turn cap) so a later
+ HTTP layer can pass this straight through as the response body, exactly
+ like agent_bridge.run_agent_turn already does today. An individual tool
+ call failing is NOT a turn failure: it is returned to the model as an
+ is_error tool_result and the conversation continues.
Sync by design: this matches agent_bridge.run_agent_turn's signature,
which is what the HTTP layer (panel_server.py, a synchronous
@@ -200,21 +250,28 @@ def run_native_turn(
executed = asyncio.run(_execute_tool_calls(registry, approval_provider, tool_use_blocks))
tool_result_blocks = [
- {"type": "tool_result", "tool_use_id": tool_use_id, "content": json.dumps(result, default=str)}
- for tool_use_id, result in executed
+ {
+ "type": "tool_result",
+ "tool_use_id": tool_use_id,
+ "content": json.dumps(result, default=str),
+ **({"is_error": True} if is_error else {}),
+ }
+ for tool_use_id, result, is_error in executed
]
history.append({"role": "user", "content": tool_result_blocks})
return {"ok": False, "error": _TURN_CAP_ERROR}
except Exception as e:
- # Roll back everything this call added to the session. Without
- # this, a failure partway through a turn (e.g. an approval-gate
- # rejection) could leave a dangling tool_use block in history with
- # no matching tool_result - which the Anthropic API rejects with a
- # 400 on every subsequent turn, permanently breaking this
- # session_id. Rolling back leaves the session exactly as it was
- # before this failed call, so a retry (or a different message)
- # still works.
+ # Reserved for genuine transport/API-level failures (e.g. a network
+ # error or 4xx/5xx from client.messages.create) - per-tool-call
+ # failures never reach here, they become is_error tool_results in
+ # _execute_tool_calls. Roll back everything this call added to the
+ # session: a failure partway through could otherwise leave a
+ # dangling tool_use block in history with no matching tool_result,
+ # which the Anthropic API rejects with a 400 on every subsequent
+ # turn, permanently breaking this session_id. Rolling back leaves
+ # the session exactly as it was before this failed call, so a retry
+ # (or a different message) still works.
del history[snapshot_len:]
logger.warning("Native chat turn failed: %s", e)
return {"ok": False, "error": str(e)}
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/panel_server.py b/packages/mcp-server-revit/src/revit_mcp_server/panel_server.py
index 2ab4011..2ab7d87 100644
--- a/packages/mcp-server-revit/src/revit_mcp_server/panel_server.py
+++ b/packages/mcp-server-revit/src/revit_mcp_server/panel_server.py
@@ -196,8 +196,9 @@ class PanelRequestHandler(BaseHTTPRequestHandler):
result = {
"ok": False,
"error": (
- "No AI provider is available. Add an Anthropic API key in Settings, "
- "or install and sign in to the claude/codex CLI."
+ "No AI provider is available. Set the MCP_REVIT_ANTHROPIC_API_KEY "
+ "environment variable and restart Revit, or install and sign in "
+ "to the claude/codex CLI."
),
}
except Exception as e:
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/security/audit.py b/packages/mcp-server-revit/src/revit_mcp_server/security/audit.py
index 245330e..95975aa 100644
--- a/packages/mcp-server-revit/src/revit_mcp_server/security/audit.py
+++ b/packages/mcp-server-revit/src/revit_mcp_server/security/audit.py
@@ -23,7 +23,7 @@ _SECRET_KEYS = {
}
_SECRET_VALUE_RE = re.compile(
- r"(?i)(?:^|[^a-z0-9])(api[_-]?key|token|session[_-]?token|secret|password|passwd|session|authorization|rhinocomputekey)\b\s*[:=]\s*([^\s,;]+)"
+ r"(?i)(?<![a-z0-9])(api[_-]?key|token|session[_-]?token|secret|password|passwd|session|authorization|rhinocomputekey)\b\s*[:=]\s*([^\s,;]+)"
)
_WINDOWS_PATH_RE = re.compile(r"(?<!\w)(?:[A-Za-z]:[\\/](?:[^\s\"'<>|]+[\\/])*[^\s\"'<>|]+)")
_POSIX_PATH_RE = re.compile(r"(?:(?<=^)|(?<=[\s\"'(<\[]))(/(?:[^/\s]+/)*[^/\s]+)")
diff --git a/packages/mcp-server-revit/tests/test_agent_native.py b/packages/mcp-server-revit/tests/test_agent_native.py
index bcea658..74364b1 100644
--- a/packages/mcp-server-revit/tests/test_agent_native.py
+++ b/packages/mcp-server-revit/tests/test_agent_native.py
@@ -18,8 +18,10 @@ import pytest
from anthropic.types import TextBlock, ToolUseBlock
from revit_mcp_server import agent_native
+from revit_mcp_server.providers.approval_provider import ApprovalProvider
from revit_mcp_server.providers.base import AECProvider, ProviderTool
from revit_mcp_server.providers.registry import ProviderRegistry
+from revit_mcp_server.security.workspace import WorkspaceMonitor
class _FakeToolProvider(AECProvider):
@@ -102,10 +104,72 @@ def test_missing_api_key_returns_error_without_calling_api(monkeypatch, registry
result = agent_native.run_native_turn("hello", None, registry, approval_provider)
- assert result == {"ok": False, "error": "No Anthropic API key configured. Add one in Settings."}
+ assert result == {
+ "ok": False,
+ "error": "No Anthropic API key configured. Set the MCP_REVIT_ANTHROPIC_API_KEY "
+ "environment variable and restart Revit.",
+ }
client_ctor.assert_not_called()
+def test_build_tools_never_offers_plan_approval_tools_to_the_model(tmp_path):
+ """Load-bearing regression test for the self-approval bypass: with a real
+ ApprovalProvider registered, the model must never be handed approve_plan,
+ reject_plan or rollback_plan (otherwise it could plan_actions ->
+ approve_plan -> execute_plan with no human involved), while the tools it
+ legitimately needs to propose and run approved plans stay available."""
+ reg = ProviderRegistry()
+ reg.register(ApprovalProvider(workspace=WorkspaceMonitor([tmp_path]), registry=reg, approval_mode="required"))
+ reg.register(_FakeToolProvider())
+
+ registered = {t.name for t in reg.get_all_tools()}
+ # Guard against a vacuous pass: the excluded tools really are in the registry.
+ assert {"approve_plan", "reject_plan", "rollback_plan"} <= registered
+
+ offered = {t["name"] for t in agent_native._build_tools(reg)}
+
+ assert "approve_plan" not in offered
+ assert "reject_plan" not in offered
+ assert "rollback_plan" not in offered
+ assert {"plan_actions", "list_pending_plans", "execute_plan"} <= offered
+ assert {"revit_set_parameter_value", "revit_get_parameter_value"} <= offered
+
+
+def test_model_emitted_approve_plan_is_refused_and_never_executes(monkeypatch, tmp_path):
+ """Defense in depth: even if the model emits a tool_use for approve_plan
+ (a name it was never offered), the loop refuses it and the plan's state
+ is untouched."""
+ monkeypatch.setattr(agent_native.config, "anthropic_api_key", "test-key")
+ reg = ProviderRegistry()
+ approval = ApprovalProvider(workspace=WorkspaceMonitor([tmp_path]), registry=reg, approval_mode="required")
+ reg.register(approval)
+ reg.register(_FakeToolProvider())
+ plan = approval.gate.create_plan(
+ [{"tool": "revit_set_parameter_value", "arguments": {"element_id": 1, "parameter_name": "Mark", "value": "X"}}],
+ [{}],
+ )
+
+ create = Mock(side_effect=[
+ _tool_use_response("approve_plan", {"plan_id": plan["plan_id"]}),
+ _text_response("I can't approve plans myself."),
+ ])
+ _install_fake_client(monkeypatch, create)
+
+ result = agent_native.run_native_turn("approve it", None, reg, approval)
+
+ assert result["ok"] is True
+ assert approval.gate.load_plan(plan["plan_id"])["state"] != "approved"
+ tool_result = agent_native._sessions[result["session_id"]][2]["content"][0]
+ assert tool_result["is_error"] is True
+ assert "not available to the chat assistant" in tool_result["content"]
+
+
+def test_tools_carry_a_single_cache_breakpoint_on_the_last_tool(registry):
+ tools = agent_native._build_tools(registry)
+ assert tools[-1]["cache_control"] == {"type": "ephemeral"}
+ assert all("cache_control" not in t for t in tools[:-1])
+
+
def test_successful_single_turn_returns_text_and_session_id(monkeypatch, registry, approval_provider):
monkeypatch.setattr(agent_native.config, "anthropic_api_key", "test-key")
create = Mock(return_value=_text_response("3 doors on Level 1"))
@@ -152,6 +216,66 @@ def test_mutating_tool_call_goes_through_approval_gate_before_executing(monkeypa
assert call_order == [("gate", "revit_set_parameter_value"), ("execute", "revit_set_parameter_value")]
+def test_gate_rejected_tool_call_surfaces_to_model_as_error_result_without_rollback(
+ monkeypatch, registry, approval_provider
+):
+ """A per-tool-call failure (here: the approval gate rejecting a mutating
+ call) must NOT abort the turn. It comes back to the model as a
+ tool_result with is_error=True, the model gets to explain it, and the
+ session history keeps the whole exchange - including a sibling call in
+ the same turn that already succeeded."""
+ monkeypatch.setattr(agent_native.config, "anthropic_api_key", "test-key")
+ approval_provider.gate.check_tool_execution.side_effect = RuntimeError(
+ "Mutating tool 'revit_set_parameter_value' requires a valid 'plan_id' parameter."
+ )
+
+ read_args = {"element_id": 1, "parameter_name": "FireRating"}
+ write_args = {"element_id": 1, "parameter_name": "FireRating", "value": "90"}
+ two_calls = SimpleNamespace(content=[
+ ToolUseBlock(type="tool_use", id="tu_read", name="revit_get_parameter_value", input=read_args),
+ ToolUseBlock(type="tool_use", id="tu_write", name="revit_set_parameter_value", input=write_args),
+ ])
+ create = Mock(side_effect=[two_calls, _text_response("That change needs an approved plan - review it in the panel.")])
+ _install_fake_client(monkeypatch, create)
+
+ result = agent_native.run_native_turn("set fire rating to 90", None, registry, approval_provider)
+
+ assert result["ok"] is True
+ assert result["response"] == "That change needs an approved plan - review it in the panel."
+ assert create.call_count == 2
+
+ history = agent_native._sessions[result["session_id"]]
+ # user, assistant(tool_use x2), user(tool_results), assistant(text) - nothing rolled back.
+ assert [m["role"] for m in history] == ["user", "assistant", "user", "assistant"]
+ read_result, write_result = history[2]["content"]
+ assert read_result["tool_use_id"] == "tu_read"
+ assert "is_error" not in read_result
+ assert write_result["tool_use_id"] == "tu_write"
+ assert write_result["is_error"] is True
+ assert "requires a valid 'plan_id'" in write_result["content"]
+
+ # The rejected mutation never ran; the sibling read did.
+ fake_provider = registry.lookup_tool_provider("revit_set_parameter_value")
+ assert fake_provider.calls == [("revit_get_parameter_value", read_args)]
+
+
+def test_api_failure_after_tool_calls_still_rolls_back_whole_turn(monkeypatch, registry, approval_provider):
+ """The outer rollback is now reserved for transport/API-level failures:
+ if messages.create itself fails mid-turn, the session is restored to its
+ pre-turn state so no dangling tool_use/tool_result pair is left behind."""
+ monkeypatch.setattr(agent_native.config, "anthropic_api_key", "test-key")
+ create = Mock(side_effect=[
+ _tool_use_response("revit_get_parameter_value", {"element_id": 1, "parameter_name": "FireRating"}),
+ ConnectionError("network down"),
+ ])
+ _install_fake_client(monkeypatch, create)
+
+ result = agent_native.run_native_turn("what's the fire rating?", None, registry, approval_provider)
+
+ assert result == {"ok": False, "error": "network down"}
+ assert all(len(h) == 0 for h in agent_native._sessions.values())
+
+
def test_non_mutating_tool_call_does_not_require_gate_check(monkeypatch, registry, approval_provider):
monkeypatch.setattr(agent_native.config, "anthropic_api_key", "test-key")
diff --git a/packages/mcp-server-revit/tests/test_audit.py b/packages/mcp-server-revit/tests/test_audit.py
index 4ac6fe7..96b3f04 100644
--- a/packages/mcp-server-revit/tests/test_audit.py
+++ b/packages/mcp-server-revit/tests/test_audit.py
@@ -75,6 +75,15 @@ def test_redact_text_redacts_prefixed_api_key_in_free_text():
assert "<redacted>" in redacted
+def test_redact_text_does_not_mangle_the_prefixed_key_label():
+ # The boundary before the keyword is a zero-width lookbehind, so the
+ # separator character ("_" here) is checked but not consumed/dropped:
+ # the label text around the redacted value must survive intact.
+ assert _redact_text("anthropic_api_key: sk-ant-real-secret-value") == "anthropic_api_key=<redacted>"
+ assert _redact_text("config anthropic_api_key=sk-ant-x rest") == "config anthropic_api_key=<redacted> rest"
+ assert _redact_text("github-token: ghp_abc") == "github-token=<redacted>"
+
+
def test_redact_text_still_redacts_existing_plain_keyword_cases():
# These are the pre-existing free-text patterns the regex already
# handled (keyword at token start, not as a suffix) - must not regress.
diff --git a/packages/mcp-server-revit/tests/test_panel_server.py b/packages/mcp-server-revit/tests/test_panel_server.py
index 812f3be..0261b6a 100644
--- a/packages/mcp-server-revit/tests/test_panel_server.py
+++ b/packages/mcp-server-revit/tests/test_panel_server.py
@@ -280,7 +280,8 @@ def test_agent_chat_no_provider_available_returns_error_without_dispatch(running
assert body == {
"ok": False,
- "error": "No AI provider is available. Add an Anthropic API key in Settings, or install and sign in to the claude/codex CLI.",
+ "error": "No AI provider is available. Set the MCP_REVIT_ANTHROPIC_API_KEY environment variable "
+ "and restart Revit, or install and sign in to the claude/codex CLI.",
}
native_mock.assert_not_called()
bridge_mock.assert_not_called()
diff --git a/panel/app.js b/panel/app.js
index 5e36c45..dea25b2 100644
--- a/panel/app.js
+++ b/panel/app.js
@@ -129,7 +129,7 @@ function renderAlerts() {
alerts.push(["warning", "LLM offline", "Chat and natural-language tools are unavailable."]);
}
if (state.providers && !state.providers.claude && !state.providers.codex) {
- alerts.push(["warning", "No AI provider available", "Add an Anthropic API key in Settings, or install and sign in to the claude/codex CLI."]);
+ alerts.push(["warning", "No AI provider available", "Set the MCP_REVIT_ANTHROPIC_API_KEY environment variable and restart Revit, or install and sign in to the claude/codex CLI."]);
}
}
@@ -391,8 +391,7 @@ settingsForm.addEventListener("submit", (event) => {
event.preventDefault();
postToHost("settings.save", {
hubUrl: hubUrl.value,
- approvalMode: document.getElementById("approval-mode").value,
- anthropicApiKey: document.getElementById("anthropic-api-key").value
+ approvalMode: document.getElementById("approval-mode").value
});
addLog("Settings saved", hubUrl.value);
});
diff --git a/panel/index.html b/panel/index.html
index ed98ed3..ca1fc9c 100644
--- a/panel/index.html
+++ b/panel/index.html
@@ -107,10 +107,6 @@
Hub URL
<input id="hub-url" value="http://127.0.0.1:3000">
</label>
- <label>
- Anthropic API Key
- <input id="anthropic-api-key" type="password" autocomplete="off" placeholder="sk-ant-...">
- </label>
<label>
Approval Mode
<select id="approval-mode">