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.

feat: multi-Revit-version host switching support

sammohammad578adfb053e3330
diff --git a/docs/build-and-install-scripts.md b/docs/build-and-install-scripts.md
index 12e0714..822889f 100644
--- a/docs/build-and-install-scripts.md
+++ b/docs/build-and-install-scripts.md
@@ -63,7 +63,7 @@ Key behavior:
- creates `.env` from `.env.example` if needed
- checks Python availability
- installs the Python package in editable mode
-- optionally probes `http://127.0.0.1:3000/health` in bridge mode
+- optionally probes the dynamic Revit bridge endpoint from the local registry in bridge mode
- launches `python -m revit_mcp_server`
### `scripts/run-server.ps1`
diff --git a/docs/configuration-reference.md b/docs/configuration-reference.md
index 146f806..2d090b5 100644
--- a/docs/configuration-reference.md
+++ b/docs/configuration-reference.md
@@ -7,14 +7,15 @@ This page documents the main environment variables, package metadata, and runtim
The server supports two runtime modes:
- `mock`: uses the built-in mock bridge for CI, development, and tests.
-- `bridge`: connects to the Revit add-in over HTTP on `127.0.0.1:3000`.
+- `bridge`: connects to a live Revit add-in over its local registry entry or an explicit bridge URL.
## Environment Variables
| Variable | Required | Default | Description |
|---|---:|---|---|
| `MCP_REVIT_MODE` | Yes | `mock` | Selects the active bridge mode. |
-| `MCP_REVIT_BRIDGE_URL` | Bridge mode | `http://127.0.0.1:3000` | URL of the Revit bridge listener. |
+| `MCP_REVIT_BRIDGE_URL` | No | auto-discovered | Explicit URL of the Revit bridge listener. Overrides registry discovery. |
+| `MCP_REVIT_HOST_VERSION` | No | newest live Revit | Revit year to select from the local registry, such as `2024` or `2026`. |
| `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. |
@@ -42,7 +43,7 @@ The current package name is `aec-model-bridge`, and the official repository URL
"args": ["-m", "revit_mcp_server.mcp_server"],
"env": {
"MCP_REVIT_MODE": "bridge",
- "MCP_REVIT_BRIDGE_URL": "http://127.0.0.1:3000",
+ "MCP_REVIT_HOST_VERSION": "2026",
"MCP_REVIT_WORKSPACE_DIR": "C:\\RevitProjects",
"MCP_REVIT_ALLOWED_DIRECTORIES": "C:\\RevitProjects"
}
@@ -54,4 +55,5 @@ The current package name is `aec-model-bridge`, and the official repository URL
## Notes
- The server should be run from the repository root or an environment where the package is installed in editable mode.
-- For Revit integration, make sure the Revit add-in is installed and Revit is running before testing the bridge endpoint.
+- For Revit integration, make sure the Revit add-in is installed and the requested Revit version is running before testing.
+- Configure separate MCP client entries with different `MCP_REVIT_HOST_VERSION` values to target multiple open Revit versions side by side.
diff --git a/docs/install.md b/docs/install.md
index b25fd6b..550c063 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -96,7 +96,9 @@ installation above.
## Configure an MCP Client
-The server requires a bridge URL and an allowed workspace:
+The server requires an allowed workspace. In bridge mode it auto-discovers the
+newest open Revit instance; set `MCP_REVIT_HOST_VERSION` to target a specific
+Revit year:
```json
{
@@ -106,7 +108,16 @@ The server requires a bridge URL and an allowed workspace:
"args": ["-m", "revit_mcp_server.mcp_server"],
"env": {
"MCP_REVIT_MODE": "bridge",
- "MCP_REVIT_BRIDGE_URL": "http://127.0.0.1:3000",
+ "MCP_REVIT_WORKSPACE_DIR": "C:\\RevitProjects",
+ "MCP_REVIT_ALLOWED_DIRECTORIES": "C:\\RevitProjects"
+ }
+ },
+ "aec-model-bridge-revit-2026": {
+ "command": "C:\\path\\to\\aec-model-bridge\\.venv\\Scripts\\python.exe",
+ "args": ["-m", "revit_mcp_server.mcp_server"],
+ "env": {
+ "MCP_REVIT_MODE": "bridge",
+ "MCP_REVIT_HOST_VERSION": "2026",
"MCP_REVIT_WORKSPACE_DIR": "C:\\RevitProjects",
"MCP_REVIT_ALLOWED_DIRECTORIES": "C:\\RevitProjects"
}
@@ -124,10 +135,13 @@ release. The Revit add-in must still be installed separately.
## Verify the Bridge
-Restart Revit after installing or replacing the add-in. Open a model and run:
+The add-in writes a live endpoint file under
+`%LOCALAPPDATA%\AECModelBridge\registry` when Revit starts:
```powershell
-Invoke-RestMethod http://127.0.0.1:3000/health
+$registry = Get-ChildItem "$env:LOCALAPPDATA\AECModelBridge\registry\revit-*.json" | Select-Object -First 1
+$switch = Get-Content $registry.FullName -Raw | ConvertFrom-Json
+Invoke-RestMethod "$($switch.endpoint)/health"
```
The response should include:
diff --git a/docs/marketplaces.md b/docs/marketplaces.md
index 623155c..119eda3 100644
--- a/docs/marketplaces.md
+++ b/docs/marketplaces.md
@@ -45,7 +45,7 @@ The workspace config is already committed at `.vscode/mcp.json`.
For user-level install:
```powershell
-code --add-mcp "{`"name`":`"revit`",`"type`":`"stdio`",`"command`":`"python`",`"args`":[`"-m`",`"revit_mcp_server.mcp_server`"],`"env`":{`"MCP_REVIT_MODE`":`"bridge`",`"MCP_REVIT_BRIDGE_URL`":`"http://127.0.0.1:3000`",`"MCP_REVIT_WORKSPACE_DIR`":`"C:\\RevitProjects`",`"MCP_REVIT_ALLOWED_DIRECTORIES`":`"C:\\RevitProjects`"}}"
+code --add-mcp "{`"name`":`"revit-2026`",`"type`":`"stdio`",`"command`":`"python`",`"args`":[`"-m`",`"revit_mcp_server.mcp_server`"],`"env`":{`"MCP_REVIT_MODE`":`"bridge`",`"MCP_REVIT_HOST_VERSION`":`"2026`",`"MCP_REVIT_WORKSPACE_DIR`":`"C:\\RevitProjects`",`"MCP_REVIT_ALLOWED_DIRECTORIES`":`"C:\\RevitProjects`"}}"
```
### Claude Desktop, Cursor, Windsurf, Cline, Roo Code, Continue, and Similar Clients
@@ -60,7 +60,7 @@ Most desktop MCP clients accept this shape:
"args": ["-m", "revit_mcp_server.mcp_server"],
"env": {
"MCP_REVIT_MODE": "bridge",
- "MCP_REVIT_BRIDGE_URL": "http://127.0.0.1:3000",
+ "MCP_REVIT_HOST_VERSION": "2026",
"MCP_REVIT_WORKSPACE_DIR": "C:\\RevitProjects",
"MCP_REVIT_ALLOWED_DIRECTORIES": "C:\\RevitProjects"
}
@@ -78,7 +78,7 @@ If the Python package was installed from PyPI, the console script can be used in
"command": "aec-model-bridge",
"env": {
"MCP_REVIT_MODE": "bridge",
- "MCP_REVIT_BRIDGE_URL": "http://127.0.0.1:3000",
+ "MCP_REVIT_HOST_VERSION": "2026",
"MCP_REVIT_WORKSPACE_DIR": "C:\\RevitProjects",
"MCP_REVIT_ALLOWED_DIRECTORIES": "C:\\RevitProjects"
}
diff --git a/packages/mcp-server-revit/README.md b/packages/mcp-server-revit/README.md
index 923f4a9..cbe6dd5 100644
--- a/packages/mcp-server-revit/README.md
+++ b/packages/mcp-server-revit/README.md
@@ -15,7 +15,8 @@ Environment variables (prefix `MCP_REVIT_`) include:
- `MCP_REVIT_WORKSPACE_DIR`
- `MCP_REVIT_ALLOWED_DIRECTORIES`
- `MCP_REVIT_MODE` (`mock` or `bridge`)
-- `MCP_REVIT_BRIDGE_URL` (required for `bridge` mode)
+- `MCP_REVIT_HOST_VERSION` (optional Revit year selector, for example `2024` or `2026`)
+- `MCP_REVIT_BRIDGE_URL` (optional explicit endpoint override for `bridge` mode)
- `MCP_REVIT_AUDIT_LOG`
- `MCP_REVIT_LOG_LEVEL`
diff --git a/packages/mcp-server-revit/src/revit_mcp_server/bridge/discovery.py b/packages/mcp-server-revit/src/revit_mcp_server/bridge/discovery.py
index 98a42a7..41e799d 100644
--- a/packages/mcp-server-revit/src/revit_mcp_server/bridge/discovery.py
+++ b/packages/mcp-server-revit/src/revit_mcp_server/bridge/discovery.py
@@ -3,7 +3,7 @@ import logging
import os
from datetime import datetime, timezone
from pathlib import Path
-from typing import Dict
+from typing import Dict, List
import ctypes
from pydantic import BaseModel, ValidationError
@@ -58,13 +58,14 @@ def _is_stale(info: SwitchInfo) -> bool:
return not is_pid_alive(info.pid)
-def discover_switches(registry_dir: Path = REGISTRY_DIR) -> Dict[str, SwitchInfo]:
+def discover_switches(registry_dir: Path | None = None) -> Dict[str, SwitchInfo]:
"""
Scans the registry directory for valid switch files.
Prunes stale files.
Returns a dict mapping provider_id to SwitchInfo.
"""
switches: Dict[str, SwitchInfo] = {}
+ registry_dir = registry_dir or REGISTRY_DIR
if not registry_dir.exists():
return switches
@@ -106,3 +107,71 @@ def discover_switches(registry_dir: Path = REGISTRY_DIR) -> Dict[str, SwitchInfo
return switches
+
+def discover_switch_list(registry_dir: Path | None = None) -> List[SwitchInfo]:
+ """Return every live switch entry, sorted from newest to oldest."""
+ switches: List[SwitchInfo] = []
+ registry_dir = registry_dir or REGISTRY_DIR
+
+ if not registry_dir.exists():
+ return switches
+
+ for file_path in registry_dir.glob("*.json"):
+ try:
+ with open(file_path, "r", encoding="utf-8") as f:
+ data = json.load(f)
+
+ info = SwitchInfo(**data)
+
+ if _is_stale(info):
+ logger.info("Pruning stale switch registry entry: %s", file_path)
+ try:
+ file_path.unlink()
+ except OSError as e:
+ logger.warning("Failed to delete stale entry %s: %s", file_path, e)
+ continue
+
+ switches.append(info)
+ except (json.JSONDecodeError, ValidationError) as e:
+ logger.warning("Malformed registry entry %s: %s", file_path, e)
+ except PermissionError as e:
+ logger.warning("ACL denied access to registry entry %s: %s", file_path, e)
+ except Exception as e:
+ logger.error("Unexpected error reading %s: %s", file_path, e)
+
+ def started_at(info: SwitchInfo) -> datetime:
+ try:
+ return datetime.fromisoformat(info.started_at.replace("Z", "+00:00"))
+ except ValueError:
+ return datetime.min.replace(tzinfo=timezone.utc)
+
+ return sorted(switches, key=started_at, reverse=True)
+
+
+def select_switch(
+ provider_id: str = "revit",
+ host_version: str | None = None,
+ registry_dir: Path | None = None,
+) -> SwitchInfo | None:
+ """Select the newest live switch for a provider, optionally by host version."""
+ requested_version = host_version.strip().lower() if host_version else None
+ for switch in discover_switch_list(registry_dir):
+ if switch.provider_id != provider_id:
+ continue
+ switch_version = switch.host_version.lower()
+ if requested_version and switch_version != requested_version and not switch_version.startswith(requested_version):
+ continue
+ return switch
+ return None
+
+
+def available_host_versions(provider_id: str = "revit", registry_dir: Path | None = None) -> List[str]:
+ """Return live host versions for a provider, sorted newest first without duplicates."""
+ versions: List[str] = []
+ for switch in discover_switch_list(registry_dir):
+ if switch.provider_id != provider_id:
+ continue
+ if switch.host_version not in versions:
+ versions.append(switch.host_version)
+ return versions
+
diff --git a/packages/mcp-server-revit/tests/test_discovery.py b/packages/mcp-server-revit/tests/test_discovery.py
index 1dbd914..e7a7aeb 100644
--- a/packages/mcp-server-revit/tests/test_discovery.py
+++ b/packages/mcp-server-revit/tests/test_discovery.py
@@ -5,7 +5,7 @@ from unittest import mock
import pytest
-from revit_mcp_server.bridge.discovery import discover_switches
+from revit_mcp_server.bridge.discovery import available_host_versions, discover_switch_list, discover_switches, select_switch
@pytest.fixture
@@ -15,18 +15,26 @@ def registry_dir(tmp_path):
return registry
-def create_mock_registry(path: Path, provider: str, pid: int, age_days: int = 0, is_malformed: bool = False):
+def create_mock_registry(
+ path: Path,
+ provider: str,
+ pid: int,
+ age_days: int = 0,
+ is_malformed: bool = False,
+ host_version: str = "2024",
+ started_offset_seconds: int = 0,
+):
file_path = path / f"{provider}-{pid}.json"
if is_malformed:
file_path.write_text("{ malformed json", encoding="utf-8")
return file_path
- started_at = datetime.now(timezone.utc) - timedelta(days=age_days)
+ started_at = datetime.now(timezone.utc) - timedelta(days=age_days) + timedelta(seconds=started_offset_seconds)
data = {
"provider_id": provider,
"endpoint": f"http://127.0.0.1:{3000 + pid}",
"pid": pid,
- "host_version": "2024",
+ "host_version": host_version,
"connector_version": "1.0",
"protocol_version": 2,
"capability_digest": "abcdef",
@@ -76,3 +84,56 @@ def test_acl_denied(registry_dir):
with mock.patch("builtins.open", side_effect=PermissionError("Access denied")):
switches = discover_switches(registry_dir)
assert "revit" not in switches
+
+
+def test_discover_switch_list_keeps_multiple_revit_versions(registry_dir):
+ with mock.patch("revit_mcp_server.bridge.discovery.is_pid_alive", return_value=True):
+ create_mock_registry(registry_dir, "revit", 1234, host_version="2024")
+ create_mock_registry(registry_dir, "revit", 2345, host_version="2026", started_offset_seconds=10)
+
+ switches = discover_switch_list(registry_dir)
+
+ assert [switch.host_version for switch in switches] == ["2026", "2024"]
+
+
+def test_select_switch_by_host_version(registry_dir):
+ with mock.patch("revit_mcp_server.bridge.discovery.is_pid_alive", return_value=True):
+ create_mock_registry(registry_dir, "revit", 1234, host_version="2024")
+ create_mock_registry(registry_dir, "revit", 2345, host_version="2026", started_offset_seconds=10)
+
+ switch = select_switch("revit", "2024", registry_dir)
+
+ assert switch is not None
+ assert switch.host_version == "2024"
+ assert switch.pid == 1234
+
+
+def test_select_switch_without_host_version_prefers_newest(registry_dir):
+ with mock.patch("revit_mcp_server.bridge.discovery.is_pid_alive", return_value=True):
+ create_mock_registry(registry_dir, "revit", 1234, host_version="2024")
+ create_mock_registry(registry_dir, "revit", 2345, host_version="2026", started_offset_seconds=10)
+
+ switch = select_switch("revit", registry_dir=registry_dir)
+
+ assert switch is not None
+ assert switch.host_version == "2026"
+
+
+def test_select_switch_supports_minor_host_version_match(registry_dir):
+ with mock.patch("revit_mcp_server.bridge.discovery.is_pid_alive", return_value=True):
+ create_mock_registry(registry_dir, "revit", 1234, host_version="2024.3")
+
+ switch = select_switch("revit", "2024", registry_dir)
+
+ assert switch is not None
+ assert switch.host_version == "2024.3"
+
+
+def test_available_host_versions(registry_dir):
+ with mock.patch("revit_mcp_server.bridge.discovery.is_pid_alive", return_value=True):
+ create_mock_registry(registry_dir, "revit", 1234, host_version="2024")
+ create_mock_registry(registry_dir, "revit", 2345, host_version="2026", started_offset_seconds=10)
+
+ versions = available_host_versions("revit", registry_dir)
+
+ assert versions == ["2026", "2024"]
diff --git a/packages/revit-bridge-addin/src/Bridge/AdditionalCommands.cs b/packages/revit-bridge-addin/src/Bridge/AdditionalCommands.cs
index 43c3d93..0801f63 100644
--- a/packages/revit-bridge-addin/src/Bridge/AdditionalCommands.cs
+++ b/packages/revit-bridge-addin/src/Bridge/AdditionalCommands.cs
@@ -75,7 +75,7 @@ namespace RevitBridge.Bridge
dialog.SetTitle("Bridge Configuration", "Current local settings");
dialog.AddInfoSection("Server Configuration",
- "Address: http://127.0.0.1:3000/\n" +
+ $"Address: {(App.Server != null ? $"http://127.0.0.1:{App.Server.Port}/" : "dynamic localhost port")}\n" +
"Startup: Automatic with Revit\n" +
"Transport: Localhost HTTP\n" +
"Revit dispatch: ExternalEvent");
diff --git a/scripts/configure-mcp-clients.ps1 b/scripts/configure-mcp-clients.ps1
index 0b45dfd..78c1c5b 100644
--- a/scripts/configure-mcp-clients.ps1
+++ b/scripts/configure-mcp-clients.ps1
@@ -7,23 +7,45 @@ $ErrorActionPreference = "Stop"
Write-Host "Configuring MCP clients for AEC Model Bridge..." -ForegroundColor Cyan
Write-Host " Python binary: $PythonPath" -ForegroundColor Gray
-# Define MCP server configurations
-$serverConfigStdio = [ordered]@{
- command = $PythonPath
- args = @("-m", "revit_mcp_server.mcp_server")
- env = [ordered]@{
- MCP_REVIT_MODE = "bridge"
- MCP_REVIT_BRIDGE_URL = "http://127.0.0.1:3000"
+function New-ServerConfig {
+ param(
+ [string]$HostVersion,
+ [switch]$VSCode
+ )
+
+ $envConfig = [ordered]@{
+ MCP_REVIT_MODE = "bridge"
+ }
+ if ($HostVersion) {
+ $envConfig["MCP_REVIT_HOST_VERSION"] = $HostVersion
+ }
+
+ $config = [ordered]@{
+ command = $PythonPath
+ args = @("-m", "revit_mcp_server.mcp_server")
+ env = $envConfig
}
+ if ($VSCode) {
+ $config = [ordered]@{
+ type = "stdio"
+ command = $PythonPath
+ args = @("-m", "revit_mcp_server.mcp_server")
+ env = $envConfig
+ }
+ }
+ return $config
}
-$serverConfigVSCode = [ordered]@{
- type = "stdio"
- command = $PythonPath
- args = @("-m", "revit_mcp_server.mcp_server")
- env = [ordered]@{
- MCP_REVIT_MODE = "bridge"
- MCP_REVIT_BRIDGE_URL = "http://127.0.0.1:3000"
+function Add-RevitServers {
+ param(
+ [Parameter(Mandatory = $true)]
+ [System.Collections.IDictionary]$Servers,
+ [switch]$VSCode
+ )
+
+ $Servers["aec-model-bridge"] = New-ServerConfig -VSCode:$VSCode
+ foreach ($year in @("2024", "2025", "2026", "2027")) {
+ $Servers["aec-model-bridge-revit-$year"] = New-ServerConfig -HostVersion $year -VSCode:$VSCode
}
}
@@ -58,7 +80,7 @@ try {
}
}
- $claudeConfig["mcpServers"]["aec-model-bridge"] = $serverConfigStdio
+ Add-RevitServers -Servers $claudeConfig["mcpServers"]
$claudeConfig | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $claudeConfigFile -Force
Write-Host " Configured Claude Desktop: $claudeConfigFile" -ForegroundColor Green
}
@@ -89,7 +111,7 @@ if (Test-Path $codeUserDir) {
}
}
}
- $vscConfig["servers"]["aec-model-bridge"] = $serverConfigVSCode
+ Add-RevitServers -Servers $vscConfig["servers"] -VSCode
$vscConfig | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $vscMcpFile -Force
Write-Host " Configured VS Code MCP file: $vscMcpFile" -ForegroundColor Green
}
@@ -114,7 +136,7 @@ if (Test-Path $codeUserDir) {
}
}
}
- $userConfig["servers"]["aec-model-bridge"] = $serverConfigVSCode
+ Add-RevitServers -Servers $userConfig["servers"] -VSCode
$userConfig | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $userMcpFile -Force
Write-Host " Configured VS Code User mcp.json: $userMcpFile" -ForegroundColor Green
}
@@ -144,7 +166,7 @@ if (Test-Path $codeUserDir) {
$mcpServersObj[$prop.Name] = $prop.Value
}
}
- $mcpServersObj["aec-model-bridge"] = $serverConfigStdio
+ Add-RevitServers -Servers $mcpServersObj
$settingsConfig["mcp.servers"] = $mcpServersObj
$settingsConfig | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $settingsFile -Force
Write-Host " Configured VS Code settings.json: $settingsFile" -ForegroundColor Green
diff --git a/scripts/install.ps1 b/scripts/install.ps1
index 70b9791..be7320c 100644
--- a/scripts/install.ps1
+++ b/scripts/install.ps1
@@ -180,7 +180,7 @@ Write-Host " Config: $configTarget\default.json"
Write-Host "`nNext steps:" -ForegroundColor Yellow
Write-Host " 1. Restart Revit $RevitVersion" -ForegroundColor White
Write-Host " 2. Open a project in Revit" -ForegroundColor White
-Write-Host " 3. Verify bridge: curl http://127.0.0.1:3000/health" -ForegroundColor White
+Write-Host " 3. Verify bridge: read %LOCALAPPDATA%\AECModelBridge\registry\revit-*.json and call its /health endpoint" -ForegroundColor White
Write-Host " 4. Expected response: {`"status`":`"healthy`",`"revit_version`":`"$RevitVersion`",...}" -ForegroundColor Gray
Write-Host "`nTo install MCP server:" -ForegroundColor Yellow
diff --git a/scripts/package.ps1 b/scripts/package.ps1
index d5f3a37..0b823ad 100644
--- a/scripts/package.ps1
+++ b/scripts/package.ps1
@@ -175,7 +175,7 @@ The installer writes binaries to
## Verify Installation
1. Start Revit
-2. In PowerShell: ``curl http://127.0.0.1:3000/health``
+2. In PowerShell, read ``%LOCALAPPDATA%\AECModelBridge\registry\revit-*.json`` and call the listed ``/health`` endpoint.
3. The response should report ``healthy`` and the running Revit version.
## Run MCP Server
diff --git a/scripts/start-server.ps1 b/scripts/start-server.ps1
index b010205..9a4ab6b 100644
--- a/scripts/start-server.ps1
+++ b/scripts/start-server.ps1
@@ -1,5 +1,6 @@
param(
- [string]$Mode = "bridge"
+ [string]$Mode = "bridge",
+ [string]$RevitVersion
)
$ErrorActionPreference = "Stop"
@@ -67,15 +68,39 @@ Get-Content $envFile | Where-Object { $_ -notmatch "^#" -and $_ -match "\S" } |
Write-Host " $_" -ForegroundColor Gray
}
$env:MCP_REVIT_MODE = $Mode
+if ($RevitVersion) {
+ $env:MCP_REVIT_HOST_VERSION = $RevitVersion
+}
# Check if Revit is running (if bridge mode)
if ($Mode -eq "bridge") {
Write-Host "`nChecking Revit bridge..." -ForegroundColor Yellow
try {
- $response = Invoke-WebRequest -Uri "http://127.0.0.1:3000/health" -Method GET -TimeoutSec 2 -UseBasicParsing
+ $registryDir = Join-Path $env:LOCALAPPDATA "AECModelBridge\registry"
+ $switches = @()
+ if (Test-Path -LiteralPath $registryDir) {
+ $switches = Get-ChildItem -LiteralPath $registryDir -Filter "*.json" -File |
+ ForEach-Object {
+ try { Get-Content -LiteralPath $_.FullName -Raw | ConvertFrom-Json } catch { $null }
+ } |
+ Where-Object {
+ $_ -and $_.provider_id -eq "revit" -and
+ (-not $RevitVersion -or $_.host_version -like "$RevitVersion*")
+ } |
+ Sort-Object started_at -Descending
+ }
+
+ if (-not $switches -or $switches.Count -eq 0) {
+ $target = if ($RevitVersion) { "Revit $RevitVersion" } else { "a Revit bridge" }
+ throw "Could not find $target in $registryDir"
+ }
+
+ $switch = $switches | Select-Object -First 1
+ $response = Invoke-WebRequest -Uri "$($switch.endpoint)/health" -Method GET -TimeoutSec 2 -UseBasicParsing
$health = $response.Content | ConvertFrom-Json
Write-Host "Bridge status: $($health.status)" -ForegroundColor Green
Write-Host "Revit version: $($health.revit_version)" -ForegroundColor Green
+ Write-Host "Bridge endpoint: $($switch.endpoint)" -ForegroundColor Green
if ($health.active_document) {
Write-Host "Active document: $($health.active_document)" -ForegroundColor Green
}
@@ -83,7 +108,7 @@ if ($Mode -eq "bridge") {
catch {
Write-Host "WARNING: Cannot connect to Revit bridge!" -ForegroundColor Red
Write-Host "Make sure Revit is running with a project open." -ForegroundColor Yellow
- Write-Host "The bridge should be available at http://127.0.0.1:3000" -ForegroundColor Yellow
+ Write-Host "The bridge should be registered under %LOCALAPPDATA%\AECModelBridge\registry." -ForegroundColor Yellow
Write-Host "`nContinuing anyway... (server will fail on first tool call)`n" -ForegroundColor Gray
}
}