RevitMCP (Revit Model Content Protocol) is a pyRevit extension that allows external applications, such as AI assistants or other services, to interact with a running instance of Autodesk Revit. It achieves this by exposing an HTTP API from within Revit using pyRevit's "Routes" functionality. An external server component (typically server.py
in this project) acts as an intermediary, which the external application communicates with. This intermediary server then makes calls to the API hosted by pyRevit within Revit.
- Element Selection and Filtering: Find and select elements by category, properties, or custom filters
- Project Information Access: Retrieve project metadata and document properties
- Element Parameter Management: Read and update element parameters with type validation
- Sheet and View Management: Automatically place views on new sheets with smart numbering
- Natural Language Integration: Compatible with AI assistants for intuitive Revit automation
The latest feature allows you to place views onto sheets using simple commands like:
- "Place detail foundation onto a sheet"
- "Put section A-A on a new sheet"
The tool automatically:
- Finds views by name (fuzzy matching)
- Creates new sheets with appropriate numbering (D001, S001, etc.)
- Places views in the center of sheets
- Handles titleblock selection and viewport creation
See Sheet_Placement_Tool_Documentation.md
for complete usage details.
This README provides instructions on how to set up and use the RevitMCP.extension
.
- Autodesk Revit: A compatible version of Autodesk Revit must be installed.
- pyRevit: pyRevit must be installed for your Revit version. If you don't have it, download and install it from
pyrevitlabs.io.
-
Install pyRevit:
- Follow the official installation guide on the
pyRevit website.
- Follow the official installation guide on the
-
Install the
RevitMCP.extension
:- Locate your pyRevit extensions folder. You can typically find this by:
- Opening pyRevit Settings in Revit (pyRevit Tab -> Settings).
- Going to the "Extensions" section. It might show registered extension paths.
- Common default locations include:
%APPDATA%/pyRevit/Extensions
%PROGRAMDATA%/pyRevit/Extensions
- Copy the entire
RevitMCP.extension
folder (which containsstartup.py
,lib/
, etc.) into one of your pyRevit extensions directories.
- Locate your pyRevit extensions folder. You can typically find this by:
-
Reload pyRevit / Restart Revit:
- After copying the extension, either "Reload" pyRevit (from the pyRevit tab in Revit) or restart Revit to ensure the extension is recognized and its
startup.py
script is executed.
- After copying the extension, either "Reload" pyRevit (from the pyRevit tab in Revit) or restart Revit to ensure the extension is recognized and its
-
Enable pyRevit Routes Server:
- Open Revit.
- Go to the pyRevit Tab -> Settings.
- Find the section related to "Routes" or "Web Server" or "API".
- Enable the Routes server.
- Note the default port number, which is typically
48884
for the first Revit instance. Subsequent Revit instances will use incrementing port numbers (e.g.,48885
,48886
). Your external server (server.py
) must be configured to point to the correct port. - Restart Revit after enabling the Routes server if prompted or to ensure the settings take effect. The
startup.py
script inRevitMCP.extension
defines the API endpoints when pyRevit loads.
-
Firewall/Network Access:
- When the pyRevit Routes server starts for the first time, your operating system's firewall might ask for permission to allow Revit (or the Python process within Revit) to open a network port and listen for incoming connections. You must allow this access for the system to work.
- Ensure that no other firewall or security software is blocking connections to the port used by the pyRevit Routes server (e.g.,
48884
).
The system consists of two main parts that need to be running:
-
The Revit-Side API (Managed by
RevitMCP.extension
and pyRevit):- When Revit starts and pyRevit loads the
RevitMCP.extension
, thestartup.py
script within the extension automatically runs. - This script defines the necessary API endpoints (e.g.,
/revit-mcp-v1/project_info
) and registers them with the pyRevit Routes server running inside Revit. - You can verify this by checking pyRevit logs for messages from
startup.py
(see Troubleshooting below).
- When Revit starts and pyRevit loads the
-
The External Intermediary Server (e.g.,
server.py
):- This is a separate Python application (likely a Flask or FastAPI server) that the end-user application (e.g., AI Assistant) communicates with.
- This server is responsible for:
- Receiving requests from the end-user application.
- Making HTTP calls to the pyRevit Routes API running inside Revit (e.g., to
http://localhost:48884/revit-mcp-v1/...
). - Processing the response from Revit and sending it back to the end-user application.
- Launching this server: The
RevitMCP.extension
includes a UI panel in Revit (e.g., "Server.panel") with a button like "Launch RevitMCP". This button is typically configured to start this externalserver.py
script.- Click this button in the Revit UI to start the intermediary server.
- Check the console output of this server to ensure it starts correctly and is listening on its configured port (e.g., your logs showed it running on port
8000
).
User Interface for the External Server:
- Once the external server (
server.py
) is running, you typically interact with it through a web-based chat interface (often served athttp://localhost:PORT
wherePORT
is the one forserver.py
, e.g.,8000
). - This interface usually provides:
- A dropdown menu to select the desired AI model (e.g., Anthropic, OpenAI, Google Generative AI).
- A settings area or popup where you can input your API keys for the selected AI model provider. These keys are necessary for the server to make requests to the AI services.
Workflow Summary:
AI Assistant/Client App
-> External Server (server.py on e.g., port 8000)
-> pyRevit Routes API (in Revit on e.g., port 48884)
-
Route Not Found Errors (
RouteHandlerNotDefinedException
):- Ensure
RevitMCP.extension/startup.py
exists and contains the route definitions. - Reload pyRevit or Restart Revit after any changes to
startup.py
. - Check pyRevit logs for messages from
startup.py
indicating it ran and defined the routes. - Ensure the pyRevit Routes server is enabled in pyRevit Settings and Revit was restarted.
- Use the diagnostic script (provided during development) in a pyRevit-aware Python console within Revit to check
routes.get_routes("revit-mcp-v1")
androutes.get_active_server()
.
- Ensure
-
Connection Refused / Cannot Connect to pyRevit Routes API:
- Verify the pyRevit Routes server is enabled in pyRevit Settings.
- Confirm the port number used by the external server to call the pyRevit API matches the port the pyRevit Routes server is actually listening on (default
48884
). - Check firewall settings.
-
Check Logs:
- pyRevit Logs: (pyRevit Tab -> Settings -> Logging) for errors related to
RevitMCP.extension
loading,startup.py
execution, or the Routes server. - External Server (
server.py
) Logs: Check the console output of yourserver.py
for errors when it tries to communicate with the pyRevit Routes API or when it's handling requests from the client application.
- pyRevit Logs: (pyRevit Tab -> Settings -> Logging) for errors related to
This README should help users set up and understand the RevitMCP system.