شعار Revit MCP Python

Revit MCP Python

مؤسسة
mcp-servers-for-revit

The system runs as two separate servers working together in a chain:

الناشرmcp-servers-for-revit
المستودعmcp-server-for-revit-python
اللغةPython
التفريعات
111
النجوم
193
الأدوات المتاحة
0
نوع نقل البياناتstdio, streamable-http
الفئات
الترخيصMIT
الروابط
  • اربط الأدوات بسير عمل الذكاء الاصطناعي

    يتيح Revit MCP Python إمكانات MCP التي يمكن لتطبيقات الذكاء الاصطناعي العميلة ووكلاء الذكاء الاصطناعي المتوافقة استخدامها.

  • الأدوات المتاحة: 0

    تصفّح الإجراءات القابلة للاستدعاء أدناه، بما في ذلك أسماؤها وأوصافها عندما يوفّرها الخادم.

  • إعدادات جاهزة للنسخ

    استخدم أمثلة إعداد التثبيت لتهيئة هذا الخادم في تطبيق MCP العميل المفضّل لديك.

  • مؤشرات الاهتمام بالمصدر المفتوح

    النجوم: 193، والنسخ المتفرعة: 111 في المستودع المرتبط.

MCP server for Revit - Python

A pyRevit-oriented implementation of the Model Context Protocol (MCP) for Autodesk Revit

How?

  • This minimal implementation leverages the Routes module inside pyRevit to create a bridge between Revit and Large Language Models (LLMs).
  • It provides a straightforward template to get started quickly, letting you prototype and iterate tools to give LLMs access to your Revit models.
  • These tools are designed to be expanded for your specific use cases. You're very welcome to fork the repo and make your own contributions.
  • Note: The pyRevit Routes API is currently in draft form and subject to change. It lacks built-in authentication mechanisms, so you'll need to implement your own security measures for production use.

Batteries Included

This repo is aimed at:

  • Beginners to the Revit API
  • Python specialists who aren't versed in C#
  • Anyone wanting to prototype and iterate quickly with LLMs and Revit

It contains:

  • A complete Routes implementation for pyRevit
  • A minimal MCP server script to connect to any MCP-compatible client
  • Several test commands to get you started right away

Key Architecture Components

The system runs as two separate servers working together in a chain:

Claude / LLM Client
       |
       |  MCP Protocol (stdio or HTTP)
       v
  main.py  (MCP Server)
       |
       |  HTTP requests (localhost:48884)
       v
  pyRevit Routes  (REST API running inside Revit)
       |
       |  Revit API calls
       v
  Revit Application

main.py is the MCP server. It speaks the MCP protocol so that Claude (or any MCP-compatible client) can call tools. When a tool is called, main.py translates it into an HTTP request and forwards it to Revit.

pyRevit Routes is a lightweight REST API that runs inside the Revit process. It receives those HTTP requests, executes Revit API code (since it has direct access to the running instance), and returns JSON responses.

They never conflict because they serve different roles, speak different protocols, and listen on different ports.

Note: The Launch & Document tools (launch_revit, list_revit_installations) are the exception — they run entirely on the MCP side, using subprocess to start Revit and then polling the pyRevit Routes health endpoint until the bridge is ready.

  1. MCP Server (main.py):
  • Built with FastMCP
  • Handles HTTP communication with Revit Routes API
  • Registers tools from modular tool system
  • Provides helper functions for GET/POST/Image requests
  1. pyRevit Extension (revit-mcp-python.extension/):
  • Contains the Routes API that runs inside Revit
  • Modular route registration in startup.py
  • Individual route modules in revit_mcp/ directory
  1. Tool Registration System (tools/):
  • Modular tool organization by functionality
  • Central registration through tools/__init__.py
  • Each module registers its own tools with the MCP server

Supported Tools

Current Implementation Status

Tool NameStatusCategoryDescription
get_revit_status✅ ImplementedStatus & ConnectivityCheck if the Revit-MCP API is active and responding
get_revit_model_info✅ ImplementedModel InformationGet comprehensive information about the current Revit model
list_levels✅ ImplementedModel InformationGet all levels with elevation information
get_revit_view✅ ImplementedView & ImageExport a specific Revit view as an image
list_revit_views✅ ImplementedView & ImageGet a list of all exportable views organized by type
place_family✅ ImplementedFamily & PlacementPlace a family instance at specified location with custom properties
list_families✅ ImplementedFamily & PlacementGet a flat list of available family types (with filtering)
list_family_categories✅ ImplementedFamily & PlacementGet a list of all family categories in the model
get_current_view_info✅ ImplementedView InformationGet detailed information about the currently active view
get_current_view_elements✅ ImplementedView InformationGet all elements visible in the current view
create_point_based_element✅ ImplementedElement CreationCreate point-based elements (doors, windows, furniture)
color_splash✅ ImplementedVisualizationColor elements based on parameter values
execute_revit_code✅ ImplementedCode ExecutionExecute IronPython code directly in Revit context
list_revit_installations✅ ImplementedLaunch & DocumentDiscover all Revit versions installed on the system
launch_revit✅ ImplementedLaunch & DocumentLaunch Revit, optionally with a file, and poll for readiness
open_document✅ ImplementedLaunch & DocumentOpen a document in running Revit (supports detach and audit)
close_document✅ ImplementedLaunch & DocumentClose the active document
save_document✅ ImplementedLaunch & DocumentSave or Save As the active document
sync_with_central✅ ImplementedLaunch & DocumentSynchronize a workshared document with central
get_selected_elements🔄 PendingSelection ManagementGet information about currently selected elements
create_line_based_element🔄 PendingElement CreationCreate line-based elements (walls, beams, pipes)
create_surface_based_element🔄 PendingElement CreationCreate surface-based elements (floors, ceilings)
delete_elements🔄 PendingElement ManagementDelete specified elements from the model
modify_element🔄 PendingElement ManagementModify element properties (instance parameters)
reset_model🔄 PendingElement ManagementReset model by deleting process model elements
tag_walls🔄 PendingAnnotationTag all walls in the current view
search_modules🔄 PendingIntegrationSearch for available modules/addins
use_module🔄 PendingIntegrationExecute functionality from external modules

Claude listing model elements in the Desktop interface

Claude getting a view in the Desktop interface

Getting Started

Installing uv:

Refer to ./README_UV.md

Installing the Extension on Revit

Activate pyRevit Routes

  1. In Revit, navigate to the pyRevit tab
  2. Open Settings
  3. Go to Routes > activate Routes Server pyRevit will start listening on port http://localhost:48884/

Install from pyRevit:

  1. In Revit, navigate to the pyRevit tab
  2. Open Extensions
  3. Select the MCP Server for Revit Python Extension > Install extension
  4. Select location, default is %APPDATA%\Roaming\pyRevit\Extensions
  5. Enable and wait for pyRevit to reload. Restart Revit if necessary.

Manual Installation on a custom directory:

  1. Clone the repo in a custom location:
    bash
    git clone https://github.com/mcp-servers-for-revit/mcp-server-for-revit-python
  2. Add .extension to the root folder name
  3. In Revit, navigate to the pyRevit tab
  4. Open Settings
  5. Under "Custom Extensions", add the path to the .extension folder
  6. Save settings and reload pyRevit (you might need to restart Revit entirely)

Testing Your Connection

Once installed, test that the Routes API is working:

  1. Open your web browser and go to:

    http://localhost:48884/revit_mcp/status/
  2. If successful, you should see a response like:

    json
    {"status": "active",
     "health": "healthy",
     "revit_available": true,
     "document_title": "your_revit_filename",
     "api_name": "revit_mcp"}

The Routes Service will now load automatically whenever you start Revit. To disable it, simply remove the extension path from the pyRevit settings.

Using the MCP Client

Testing with the MCP Inspector

The MCP SDK includes a handy inspector tool for debugging:

bash
mcp dev main.py

Then access http://127.0.0.1:6274 in your browser to test your MCP server interactively.

Transport Modes

The MCP server supports multiple transport modes for different use cases:

FlagTransportEndpointsUse Case
(none)stdiostdin/stdoutClaude Desktop / Claude Code default
--sseSSE only/sse, /messages/Legacy clients
--streamable-httpHTTP only/mcpModern HTTP clients
--combinedBothAll aboveMaximum compatibility

Running with combined transport (recommended for HTTP):

bash
uv run --with "mcp[cli]" main.py --combined

This starts the server on http://127.0.0.1:8000 with both SSE and streamable-HTTP endpoints available.

Testing the endpoints:

bash
# Test streamable-http
curl -X POST http://localhost:8000/mcp

# Test SSE
curl http://localhost:8000/sse

Connecting to Claude Desktop

The simplest way to install your MCP server in Claude Desktop:

bash
mcp install main.py

Or for manual installation:

  1. Open Claude Desktop → Settings → Developer → Edit Config
  2. Add this to the mcpServers section:
json
{
  "mcpServers": {
    "Revit Connector": {
      "command": "uv",
      "args": [
        "run",
        "--with",
        "mcp[cli]",
        "mcp",
        "run",
        "/absolute/path/to/main.py"
      ]
    }
  }
}

For HTTP transport mode, configure Claude Desktop with:

json
{
  "mcpServers": {
    "Revit Connector": {
      "url": "http://localhost:8000/mcp"
    }
  }
}

Connecting to Claude Code

bash
claude mcp add -s user "Revit-Connector" -- uv run --with "mcp[cli]" mcp run /absolute/path/to/main.py

Creating Your Own Tools

The modular architecture of this project makes adding functionalities relatively simple. The provided LLM.txt file also gives your language model the necessary context to get started right away.

The process involves three main parts:

Part 1: Create the Route Module in Revit

Create a new Python file within the revit-mcp-python.extension/revit_mcp/ directory (e.g., revit_mcp/your_module.py). This module will contain all the related functions you want to expose.

python
# In revit-mcp-python.extension/revit_mcp/your_module.py

# -*- coding: UTF-8 -*-
"""
Your Module for Revit MCP
Handles your specific functionality.
"""
from pyrevit import routes, revit, DB
import json
import logging

# Standard logger setup
logger = logging.getLogger(__name__)

def register_your_routes(api):
    """Register all your routes with the API."""

    # ---- Example 1: A GET request for reading data ----
    @api.route('/your_endpoint/', methods=["GET"])
    def get_project_title(doc):
        """Gets the project title from the Revit model."""
        try:
            value = doc.Title
            return routes.make_response(data={"status": "success", "data": value})
        except Exception as e:
            logger.error("Get project title failed: {}".format(str(e)))
            return routes.make_response(data={"error": str(e)}, status=500)

    # ---- Example 2: A POST request for modifying the model ----
    @api.route('/modify_model/', methods=["POST"])
    def modify_model(doc, request):
        """Handles POST requests for modifying the Revit model."""
        try:
            data = json.loads(request.data) if isinstance(request.data, str) else request.data

            # Use a transaction for all model modifications
            t = DB.Transaction(doc, "Modify Model via MCP")
            t.Start()

            try:
                element_id = data.get("element_id")
                new_value = data.get("new_value")
                element = doc.GetElement(DB.ElementId(int(element_id)))
                param = element.LookupParameter("Comments")
                param.Set(new_value)

                t.Commit()
                return routes.make_response(data={"status": "success", "result": "Element modified."})

            except Exception as tx_error:
                if t.HasStarted() and not t.HasEnded():
                    t.RollBack()
                raise tx_error

        except Exception as e:
            logger.error("Modify model failed: {}".format(str(e)))
            return routes.make_response(data={"error": str(e)}, status=500)

    logger.info("Your custom routes were registered successfully.")

Part 2: Create the MCP Tool Module

Create the corresponding tools for the MCP server in the tools/ directory (e.g., tools/your_tools.py). This module will use the revit_get and revit_post helpers from main.py.

python
# In tools/your_tools.py
# -*- coding: utf-8 -*-
"""Your tools for the MCP server."""

from mcp.server.fastmcp import Context
from .utils import format_response

def register_your_tools(mcp, revit_get, revit_post, revit_image=None):
    """Register your tools with the MCP server."""

    # ---- Tool for the GET request ----
    @mcp.tool()
    async def get_revit_project_title(ctx: Context) -> str:
        """
        Retrieves the title of the currently open Revit project.
        """
        response = await revit_get("/your_endpoint/", ctx)
        return format_response(response)

    # ---- Tool for the POST request ----
    @mcp.tool()
    async def modify_revit_element_comment(
        element_id: int,
        new_value: str,
        ctx: Context = None
    ) -> str:
        """
        Modifies the 'Comments' parameter of a specific element.

        Args:
            element_id: The ID of the element to modify.
            new_value: The new comment to apply to the element.
        """
        payload = {"element_id": element_id, "new_value": new_value}
        response = await revit_post("/modify_model/", payload, ctx)
        return format_response(response)

Part 3: Register Your New Modules

1. Register the Route Module

Open revit-mcp-python.extension/startup.py and add your new route registration function.

python
# In revit-mcp-python.extension/startup.py

# ... (other imports)
# Import the registration function from your new module
from revit_mcp.your_module import register_your_routes

def register_routes():
    """Register all MCP route modules"""
    api = routes.API('revit_mcp')
    try:
        # ... (existing route registrations)

        # Register your new routes (this registers all functions inside)
        register_your_routes(api)

        logger.info("All MCP routes registered successfully")
    except Exception as e:
        logger.error("Failed to register MCP routes: {}".format(str(e)))
        raise

2. Register the Tool Module

Open tools/__init__.py and add your new tool registration function.

python
# In tools/__init__.py

# ... (other tool imports)
# Import the registration function from your new tool module
from .your_tools import register_your_tools

def register_tools(mcp_server, revit_get_func, revit_post_func, revit_image_func):
    """Register all tools with the MCP server"""

    # ... (existing tool registrations)
    # Register your new tools (this registers all tools inside)
    register_your_tools(mcp_server, revit_get_func, revit_post_func, revit_image_func)

    return mcp_server

Roadmap

This is a work in progress and more of a demonstration than a fully-featured product. Future improvements could include:

  • Creating a Client inside Revit
  • Implementing compatibilities with other language Models
  • Authentication and security enhancements
  • More advanced Revit tools and capabilities
  • Better error handling and debugging features
  • Benchmarking with local models
  • Documentation and examples for common use cases
  • ...

Contributing

Contributions are welcome! Feel free to submit pull requests or open issues for any bugs or feature requests. Feel free to reach out to me if you have any questions, ideas

التثبيت

TypingMind
المتطلبات المسبقة:

Node.js 18+

{
  "mcpServers": {
    "revit-mcp-revit-mcp-python": {
      "command": "",
      "args": []
    }
  }
}

استخدم MCP الخاص بـ Revit MCP Python مع نماذج ذكاء اصطناعي متعددة

يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا بمجرد توصيل Revit MCP Python، يمكنك استخدامه مع نماذج ذكاء اصطناعي مختلفة في TypingMind بدلًا من إعداده لكل نموذج على حدة. يمكنك تشغيل MCP محليًا على جهازك أو الاتصال بعنوان URL لخادم MCP بعيد.

الخيار 1: استخدام الموصل المحلي

استخدم هذا الخيار عندما يحتاج خادم MCP إلى الوصول إلى ملفات محلية أو تطبيقات أو موارد خاصة على جهاز الكمبيوتر لديك.

1

فتح إعدادات MCP

في TypingMind، انتقل إلى «الإعدادات»، ثم «الإعدادات المتقدمة»، ثم «بروتوكول سياق النموذج»، واختر «إعداد الموصل».

  1. افتح TypingMind في متصفحك.
  2. انقر على أيقونة الإعدادات.
  3. انتقل إلى الإعدادات المتقدمة.
  4. افتح قسم بروتوكول سياق النموذج.
  5. انقر على «إعداد الموصل» واختر «هذا الجهاز».
شاشة إعداد موصل MCP في TypingMind مع تحديد «هذا الجهاز»
2

تنفيذ أمر الموصل

اختر «هذا الجهاز»، وانسخ الأمر من TypingMind وشغّله في Terminal. أبقِ العملية قيد التشغيل أثناء استخدام MCP.

  1. انسخ أمر الإعداد الذي يعرضه TypingMind.
  2. افتح Terminal على macOS أو Windows Terminal على Windows.
  3. الصق الأمر ونفّذه.
  4. وافق على تثبيت الحزمة إذا طلب منك Terminal تأكيد المتابعة.
  5. أبقِ نافذة Terminal والعملية التي تعمل فيها قيد التشغيل أثناء استخدام أدوات MCP.
3

أضف Revit MCP Python كخادم

عندما تظهر حالة الموصل «جاهز»، انقر على «تعديل الخوادم» والصق إعدادات خادم MCP.

  1. انتظر حتى تظهر حالة الموصل «جاهز».
  2. انقر على «تعديل الخوادم».
  3. الصق إعدادات خادم MCP الخاص بـ Revit MCP Python.
  4. احفظ قائمة الخوادم.
  5. حدّث الحالة إذا أردت التأكد من أن الموصل لا يزال جاهزًا.
إعدادات MCP في TypingMind تعرض خادمًا نشطًا وزر «تعديل الخوادم»
{
  "mcpServers": {
    "revit-mcp-revit-mcp-python": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-server-for-revit"
      ]
    }
  }
}
4

استخدام الاتصال مع نماذج مختلفة

احفظ قائمة الخوادم، وافتح «الإضافات»، وفعّل أدوات MCP الخاصة بـ Revit MCP Python، ثم اختر أي نموذج ذكاء اصطناعي مدعوم في TypingMind واستخدم الأدوات في المحادثة أو أسندها إلى وكيل ذكاء اصطناعي.

  1. افتح صفحة الإضافات في TypingMind.
  2. فعّل أدوات MCP الخاصة بـ Revit MCP Python.
  3. ابدأ محادثة واختر نموذج الذكاء الاصطناعي الذي تريد استخدامه.
  4. استخدم أدوات MCP في المحادثة أو عيّنها لوكيل ذكاء اصطناعي.
  5. انتقل إلى نموذج ذكاء اصطناعي آخر عند الحاجة دون إعادة الاتصال بـ MCP.
محادثة في TypingMind تستخدم أدوات MCP المفعّلة مع نموذج ذكاء اصطناعي محدّد
هل يمكنك استخدام Revit MCP Python لمساعدتي في هذه المهمة؟
Revit MCP Python
بالتأكيد. قرأته.
إليك ما وجدته باستخدام Revit MCP Python.

الخيار 2: إضافة عنوان URL لخادم MCP

استخدم هذا الخيار عندما يكون Revit MCP Python مستضافًا بالفعل عن بُعد أو عندما يريد فريقك موصلًا مشتركًا واحدًا يمكن لعدة مستخدمين الوصول إليه.

1

فتح موصلات MCP

في TypingMind، انتقل إلى «الإضافات»، وافتح «موصلات MCP»، ثم اختر «إضافة رابط».

  1. افتح TypingMind في متصفحك.
  2. انتقل إلى الإضافات.
  3. افتح موصلات MCP.
  4. انقر على «إضافة عنوان URL».
نموذج إضافة عنوان URL لخادم MCP مخصص في TypingMind
2

لصق عنوان URL للخادم

أدخل عنوان URL لخادمك في حقل «رابط الخادم». أضف اسمًا للاتصال أو وصفًا أو أيقونة أو ترويسات HTTP مخصصة أو إعدادات عميل OAuth إذا كان الخادم يتطلب ذلك.

  1. ألصق عنوان URL لخادمك في حقل «رابط الخادم».
  2. أدخل اسمًا لاتصال Revit MCP Python.
  3. أضف وصفًا وأيقونة لتسهيل التعرّف على الاتصال إن أردت.
  4. أضف ترويسات HTTP مخصصة أو تفاصيل عميل OAuth إذا كان الخادم يتطلب المصادقة.
3

إنشاء الاتصال

انقر على «إنشاء اتصال»، ثم عُد إلى قائمة الإضافات وتأكد من أن اتصال MCP الجديد نشط.

  1. انقر على «إنشاء اتصال».
  2. عُد إلى قائمة موصلات MCP.
  3. تأكد من ظهور اتصال Revit MCP Python بحالة «نشط».
  4. حدّث قائمة الإضافات إذا لم يظهر الاتصال فورًا.
4

تبديل النماذج دون إعادة الاتصال

ابدأ محادثة مع نموذجك المفضل، وفعّل أدوات Revit MCP Python من «الإضافات»، وانتقل إلى نموذج آخر عند الحاجة. يظل اتصال MCP متاحًا في مساحة عمل TypingMind.

  1. ابدأ محادثة جديدة في TypingMind.
  2. اختر نموذج الذكاء الاصطناعي الذي تريد استخدامه.
  3. فعّل أدوات Revit MCP Python من قسم الإضافات.
  4. اطلب من النموذج استخدام الأداة عند الحاجة.
  5. انتقل إلى نموذج ذكاء اصطناعي آخر وأعد استخدام اتصال MCP نفسه.
محادثة في TypingMind تستخدم أدوات MCP المفعّلة مع نموذج ذكاء اصطناعي محدّد
هل يمكنك استخدام Revit MCP Python لمساعدتي في هذه المهمة؟
Revit MCP Python
بالتأكيد. قرأته.
إليك ما وجدته باستخدام Revit MCP Python.

الأسئلة الشائعة

ما استخدامات خادم MCP Revit MCP Python؟

Revit MCP Python هو خادم MCP يتيح لتطبيقات الذكاء الاصطناعي المتوافقة الاتصال بأدوات ومصادر سياق خارجية. في TypingMind، يمكنك إضافة خادم MCP هذا مرة واحدة وإتاحة أدواته في مساحة عملك للذكاء الاصطناعي.

هل يمكنني استخدام خادم MCP Revit MCP Python مع نماذج ذكاء اصطناعي متعددة في TypingMind؟

نعم. يربط TypingMind أدوات MCP على مستوى مساحة العمل، لذا يمكنك استخدام Revit MCP Python مع نماذج ذكاء اصطناعي مختلفة مثل Claude أو ChatGPT أو Gemini أو غيرها من النماذج التي أعددتها في TypingMind، دون إعداد خادم MCP لكل نموذج على حدة.

لماذا تستخدم موصل MCP Revit MCP Python مع TypingMind؟

يُعد TypingMind من أفضل واجهات المحادثة مع النماذج اللغوية الكبيرة، إذ يجمع نماذج ذكاء اصطناعي متعددة ومطالبات وإضافات ووكلاء ذكاء اصطناعي ومفاتيح API وأدوات MCP في مساحة عمل واحدة. بعد توصيل Revit MCP Python، يمكنك استخدام أدوات MCP الخاصة به عبر نماذجك المفضلة مع الحفاظ على سير عمل محادثاتك منظمًا في TypingMind.

كيف أوصّل خادم MCP Revit MCP Python بـ TypingMind؟

يمكن توصيل Revit MCP Python بـ TypingMind باستخدام موصل MCP المحلي أو بإضافة عنوان URL لخادم MCP بعيد. استخدم الموصل المحلي عندما يحتاج الخادم إلى الوصول إلى ملفات أو تطبيقات أو موارد خاصة على جهازك، واستخدم عنوان URL للخادم عندما يكون خادم MCP مستضافًا عن بُعد.

ما الأدوات التي يوفّرها خادم MCP Revit MCP Python في TypingMind؟

يتيح Revit MCP Python إمكانات MCP يمكنك تفعيلها من صفحة الإضافات في TypingMind واستخدامها في المحادثات أو تعيينها لوكلاء ذكاء اصطناعي.

هل أحتاج إلى مشاركة مفاتيح API الخاصة بي مع TypingMind لاستخدام خادم MCP Revit MCP Python؟

لا. يعطي TypingMind الأولوية للعمل المحلي ويُبقي مزوّدي النماذج ومفاتيح API والمطالبات وإعدادات MCP تحت تحكمك. إذا كان Revit MCP Python يتطلب مصادقة، فأضف الترويسات أو إعدادات OAuth أو الإعدادات المحلية المطلوبة لخادم MCP هذا عند إنشاء الاتصال.

خوادم MCP ذات صلة

عرض الكل

أنشئ مساحة عملك للذكاء الاصطناعي الآن

اشترك في نشرتنا البريدية لتصلك أخبار الميزات الجديدة والهدايا القادمة 👇