Revit MCP Bridge
# Revit MCP Bridge for Google Antigravity
[](https://deepmind.google/)
[](https://www.autodesk.com/products/revit/)
[](https://pyrevitlabs.notion.site/)
[](https://modelcontextprotocol.io/)
[](https://www.python.org/)
[](https://opensource.org/licenses/MIT)
A dedicated, high-performance **Model Context Protocol (MCP)** bridge engineered natively for **Google Antigravity** (and compatible with Claude Desktop, Cursor, Cline, and Windsurf) to connect autonomous AI agents with **Autodesk Revit**.
> **Communication-First Architecture:** This standalone variant delivers a pure, rock-solid communication layer for Revit automation ā free of external voice/speech-to-text models, audio recording, or bloated dependencies. All multimodal interaction (visual markup, view inspection, interactive element selection) happens directly through the MCP protocol and Antigravity's multimodal reasoning engine.
---
## š Built for Google Antigravity
Antigravity operates as an autonomous BIM engineering assistant with continuous feedback loops directly inside Autodesk Revit:
```
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Google Antigravity AI Agent ā
ā (Autonomous BIM Coding & Multimodal Vision) ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā stdio (MCP JSON-RPC)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Revit MCP Server Bridge (Python) ā
ā revit_mcp/server.py ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā HTTP / JSON (127.0.0.1:40001+)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā Autodesk Revit (pyRevit) ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Revit MCP Floating HUD (Visual State & Control) ā ā
ā ā - šÆ Interactive Pick Elements (User Input) ā ā
ā ā - āļø Screen Snip & Visual Markup (Multimodal) ā ā
ā ā - š”ļø Modal Dialog Lock Detection ā ā
ā ā - š¦ Live Busy/Idle State Indicator ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā ExternalEvent ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāāāāāāā ā
ā ā Revit Main UI Thread Execution Engine ā ā
ā ā (doc, uidoc, uiapp, app, Transactions) ā ā
ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
```
### Key Antigravity Agent Capabilities
1. **Two-Way Interactive User Requests**:
- **šÆ Interactive Element Picking (`revit_request_user_selection`)**: When Antigravity needs the user to designate a specific element (e.g., room boundary, clashing pipe, equipment), the Revit HUD button flashes gold/purple. The user clicks the element in Revit, and its ID, category, and metadata are immediately returned to Antigravity without manual typing.
- **āļø Visual Snip & Markup (`revit_request_user_snip`)**: Antigravity can ask the user to visually circle or annotate areas of interest. The user draws arrows/boxes using the built-in screen snipper, and the annotated image is piped straight into Antigravity's vision context.
2. **Visual Busy State Lifecycle (`revit_set_busy`)**:
- The Revit HUD panel turns Gray while Antigravity is processing or executing transactions, and switches back to Green when Antigravity is done and awaiting user input.
3. **Modal Dialog Safety**:
- If a modal window opens in Revit (e.g. warning dialog or file dialog), Revit MCP immediately detects it via Win32 API and returns `HTTP 423 Locked`, alerting Antigravity instead of hanging the agent indefinitely.
4. **Deterministic Multi-Instance Binding**:
- Running multiple Revit versions or multiple documents concurrently? Each instance binds to an incremental port (`40001`, `40002`, ...), and Antigravity locks its session strictly to the target model without accidental cross-project execution.
---
## š Features
- ā” **Direct Revit API Execution**: Run arbitrary Python scripts on the Revit main UI thread safely using `ExternalEvent`. Access `doc`, `uidoc`, `uiapp`, and `app`.
- š **Multi-Instance Support**: Multiple open Revit models automatically receive incremental ports (`40001`, `40002`, ...).
- šÆ **Interactive Element Selection**: AI agents can ask the user to pick elements in Revit (`revit_request_user_selection`).
- āļø **Visual Screen Snip & Markup**: Prompt the user to snip screen regions and annotate them with arrows, boxes, and freehand sketches (`revit_request_user_snip`).
- š”ļø **Modal Dialog Protection**: Win32 detection checks whether Revit is blocked by a modal dialog, reporting HTTP 423 Locked instead of freezing requests indefinitely.
- šø **Automated High-Res Screenshots**: Capture the active Revit view as a PNG image directly into the agent's context.
- šŖ **Minimal Floating HUD**: Clean WPF window displaying server status, active port, request counter, latency, pin (always-on-top), and compact minimize mode.
---
## š Quick Start
### Step 1: Install the pyRevit Extension
1. Ensure [pyRevit](https://github.com/eirannejad/pyRevit) is installed in Autodesk Revit.
2. Copy or symlink the folder `pyrevit_extension/RevitMCP.extension` into your pyRevit extensions directory:
```powershell
# Default pyRevit extension directory:
%APPDATA%\pyRevit\Extensions\RevitMCP.extension
```
Or attach it via pyRevit CLI:
```bash
pyrevit extend ui RevitMCP path/to/pyrevit_extension/RevitMCP.extension
```
3. In Revit, click the **Revit MCP** button on the ribbon tab to start the server. The floating HUD will appear and display **Ready for commands** on `127.0.0.1:40001`.
---
### Step 2: Install the Python MCP Server
Clone this repository and install dependencies:
```bash
git clone https://github.com/AndreyStartsev/revit-mcp.git
cd revit-mcp
# Install dependencies or install in editable mode
pip install -e .
```
Verify connection to Revit:
```bash
python tests/test_connection.py
```
---
### Step 3: Configure Your AI Agent
#### š¤ Google Antigravity
Add the Revit MCP server to your Antigravity configuration or workspace MCP settings:
```json
{
"mcpServers": {
"revit": {
"command": "python",
"args": ["-m", "revit_mcp"]
}
}
}
```
#### š£ Claude Desktop
Add to `%APPDATA%\Claude\claude_desktop_config.json` (Windows) or `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):
```json
{
"mcpServers": {
"revit": {
"command": "python",
"args": ["-m", "revit_mcp"]
}
}
}
```
#### š¦ Cursor (.cursor/mcp.json)
```json
{
"mcpServers": {
"revit": {
"command": "python",
"args": ["-m", "revit_mcp"]
}
}
}
```
---
## š ļø Available MCP Tools
| Tool | Description |
|------|-------------|
| `revit_ping` | Checks connection health and reports the active Revit instance and document. |
| `revit_list_instances` | Lists all active Revit instances across ports `40001`..`40010`. |
| `revit_set_active_instance` | Binds the session to a specific instance by port or model name. |
| `revit_get_active_model` | Retrieves metadata about the active model (title, path, view, levels). |
| `revit_execute_python` | Executes arbitrary Python in Revit via Revit API (`doc`, `uidoc`, `uiapp`, `app`). |
| `revit_get_selection` | Returns currently selected elements, categories, and parameters. |
| `revit_get_element_geometry` | Retrieves exact bounding boxes (mm), locations, rotations, and levels. |
| `revit_get_warnings` | Retrieves all active model warnings and failing element IDs. |
| `revit_capture_screenshot` | Captures an automated high-resolution PNG of the active Revit view. |
| `revit_get_latest_screenshot` | Retrieves metadata and file path of the most recent screenshot or snip. |
| `revit_request_user_selection` | Prompts user in Revit to click element(s) with optional category filtering. |
| `revit_request_user_snip` | Prompts user to snip screen area and annotate with built-in markup tools. |
| `revit_set_busy` | Controls the visual busy indicator and theme color in the Revit HUD. |
---
## š” Python Execution Pattern
When using `revit_execute_python`, you write standard Revit API Python code. Always use transactions when modifying the model:
```python
from Autodesk.Revit.DB import Transaction, FilteredElementCollector, BuiltInCategory
# 1. Access objects in scope: doc, uidoc, uiapp, app
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType()
# 2. Modify with Transaction
t = Transaction(doc, "Set Comments")
t.Start()
for wall in collector:
param = wall.LookupParameter("Comments")
if param and not param.IsReadOnly:
param.Set("Verified by Antigravity")
t.Commit()
# 3. Return results via response_data
response_data["wall_count"] = collector.GetElementCount()
response_data["status"] = "Success"
```
---
## š„ļø Direct Python Client
If you want to communicate with Revit without an MCP client (for testing or automation scripts), use the included `RevitClient`:
```python
from revit_mcp import RevitClient
client = RevitClient(port=40001)
# Health check
print(client.ping())
# Execute code
res = client.execute_python("""
response_data['doc_title'] = doc.Title if doc else 'No Document'
""")
print(res['data'])
```
---
## š License
This project is licensed under the [MIT License](LICENSE).
TDQS
Scored across 13 tools
Each tool targets a distinct action or resource: screenshot capture, user selection request, user snip request, HUD state, instance management, model metadata, code execution, selection retrieval, geometry retrieval, and warnings. The potential overlap between capturing screenshots and retrieving the latest screenshot is resolved by clear action boundaries, and requesting selection versus getting current selection is explicitly differentiated.
All tools use snake_case with a consistent revit_ prefix, and most follow a verb_noun pattern. Minor deviations exist: revit_ping is verb-only and revit_set_busy uses an adjective rather than a noun, but overall the set is highly predictable.
The 13 tools are well-scoped for a Revit bridge that handles instance management, user interaction, screenshots, model inspection, and Python execution. No tool appears redundant, and the count fits comfortably within a focused operational set.
The surface covers core bridge workflows including connection management, user-driven selection/snipping, screenshot capture, model metadata, selection/geometry retrieval, warnings, and arbitrary Python execution for modifications. Direct CRUD tools for elements and transaction helpers are absent, but revit_execute_python provides a broad escape hatch.