Logo di RevitMCPSDK

RevitMCPSDK

Community
DTDucas

Revit MCP SDK

AutoreDTDucas
RepositoryRevitMCPSDK
LinguaC#
Fork
12
Stelle
41
Strumenti disponibili
0
Tipo di trasportostdio
LicenzaMIT
Link
  • Collega gli strumenti ai flussi di lavoro IA

    RevitMCPSDK mette a disposizione funzionalità MCP utilizzabili da client e agenti IA compatibili.

  • 0 strumenti disponibili

    Esplora le azioni richiamabili qui sotto, con nomi e descrizioni quando forniti dal server.

  • Configurazione pronta da copiare

    Usa gli esempi di installazione per configurare questo server nel tuo client MCP preferito.

  • Indicatori di interesse open source

    41 stelle e 12 fork nel repository collegato.

RevitMCPSDK

Overview

RevitMCPSDK is a comprehensive software development kit for Autodesk Revit that implements the Model Context Protocol (MCP). This SDK simplifies the development of Revit plugins by providing a robust framework for communication between Revit and external applications through a JSON-RPC 2.0 interface.

Key Features

  • Multi-Version Support: Compatible with Revit 2020-2027
  • JSON-RPC 2.0 Implementation: Standardized communication protocol
  • MVVM Architecture: Clean separation of Model-View-ViewModel for WPF applications
  • SOLID Principles: Follows best practices in software design
  • Command Pattern: Simplified command execution with error handling
  • External Event Framework: Thread-safe execution of Revit API operations
  • Versioning Support: Compatibility management between different Revit versions
  • Comprehensive Error Handling: Standardized error codes and reporting

Installation

NuGet Package

The RevitMCPSDK is available as a NuGet package for each supported Revit version:

Install-Package RevitMCPSDK -Version 2020.0.0.1 // For Revit 2020
Install-Package RevitMCPSDK -Version 2021.0.0.1 // For Revit 2021
Install-Package RevitMCPSDK -Version 2022.0.0.1 // For Revit 2022
Install-Package RevitMCPSDK -Version 2023.0.0.1 // For Revit 2023
Install-Package RevitMCPSDK -Version 2024.0.0.1 // For Revit 2024
Install-Package RevitMCPSDK -Version 2025.0.0.1 // For Revit 2025
Install-Package RevitMCPSDK -Version 2026.0.0.1 // For Revit 2026
Install-Package RevitMCPSDK -Version 2027.0.0.1 // For Revit 2027

Or, if you prefer using PackageReference in your .csproj file:

xml
<PackageReference Include="RevitMCPSDK" Version="$(RevitVersion).*" />

Manual Installation

Alternatively, you can download the appropriate version of the SDK from the GitHub releases page and reference it in your project.

Architecture

RevitMCPSDK is built on the following architectural foundations:

MVVM Pattern

The SDK follows the Model-View-ViewModel pattern to facilitate:

  • Clean separation of concerns
  • Improved testability
  • Better code maintainability
  • UI/UX flexibility

SOLID Principles

  • Single Responsibility: Each class has one responsibility
  • Open/Closed: Open for extension, closed for modification
  • Liskov Substitution: Derived classes can be substituted for base classes
  • Interface Segregation: Focused interfaces for specific purposes
  • Dependency Inversion: Abstractions over implementations

JSON-RPC 2.0

The SDK implements the JSON-RPC 2.0 specification for communication between Revit and external applications:

  • Standardized request/response format
  • Support for notifications
  • Comprehensive error handling
  • Versioned protocol

Core Components

Command System

The command system allows execution of Revit API operations:

csharp
// Register a command
commandRegistry.RegisterCommand(new YourCustomCommand());

// Execute a command
JObject parameters = JObject.FromObject(new { /* your parameters */ });
object result = revitCommand.Execute(parameters, "requestId");

External Events

Thread-safe execution of Revit API operations:

csharp
public class YourExternalEvent : ExternalEventCommandBase
{
    public YourExternalEvent(IWaitableExternalEventHandler handler, UIApplication uiApp)
        : base(handler, uiApp)
    {
    }

    public override string CommandName => "YourCommandName";

    public override object Execute(JObject parameters, string requestId)
    {
        // Extract parameters
        if (!parameters.TryGetValue("parameter1", out JToken param1Value))
            throw new CommandExecutionException("Missing required parameter: parameter1");

        // Raise the external event and wait for completion
        if (!RaiseAndWaitForCompletion())
            throw CreateTimeoutException(CommandName);

        // Return success result
        return CommandResult.CreateSuccess(new { /* result data */ });
    }
}

Versioning Support

The SDK includes utilities for managing compatibility across different Revit versions:

csharp
// Check if the current Revit version is supported
RevitVersionAdapter adapter = new RevitVersionAdapter(application);
bool isSupported = adapter.IsVersionSupported(new[] { "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027" });

// Compare versions
int result = VersionHelper.CompareVersions("2020", "2025"); // Returns -1 (2020 < 2025)

Getting Started

Creating a Basic Revit Plugin

  1. Create a new Class Library project in Visual Studio
  2. Install the RevitMCPSDK NuGet package for your target Revit version
  3. Implement a custom command:
csharp
using Autodesk.Revit.UI;
using Newtonsoft.Json.Linq;
using RevitMCPSDK.API.Base;
using RevitMCPSDK.API.Interfaces;
using RevitMCPSDK.API.Models;

namespace YourNamespace
{
    public class GetElementCommand : ExternalEventCommandBase
    {
        public GetElementCommand(IWaitableExternalEventHandler handler, UIApplication uiApp)
            : base(handler, uiApp)
        {
        }

        public override string CommandName => "GetElement";

        public override object Execute(JObject parameters, string requestId)
        {
            // Extract element ID from parameters
            if (!parameters.TryGetValue("elementId", out JToken elementIdToken))
                return CommandResult.CreateError("Missing elementId parameter");

            int elementId = elementIdToken.Value<int>();

            // Get the document
            var doc = UiApp.ActiveUIDocument.Document;
            
            // Find the element
            var element = doc.GetElement(new Autodesk.Revit.DB.ElementId(elementId));
            
            if (element == null)
                return CommandResult.CreateError($"Element with ID {elementId} not found", 
                    new { ErrorCode = JsonRPCErrorCodes.ElementNotFound });

            // Return element information
            return CommandResult.CreateSuccess(new
            {
                Id = element.Id.IntegerValue,
                Name = element.Name,
                Category = element.Category?.Name
            });
        }
    }
}
  1. Register your command in your Revit external application:
csharp
using Autodesk.Revit.UI;
using RevitMCPSDK.API.Interfaces;
using System;

namespace YourNamespace
{
    public class YourRevitApp : IExternalApplication
    {
        private ICommandRegistry _commandRegistry;

        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                // Initialize the command registry
                _commandRegistry = new CommandRegistry();
                
                // Create and register your commands
                var handler = new YourExternalEventHandler();
                var uiApp = new UIApplication(application.ControlledApplication);
                
                var getElementCommand = new GetElementCommand(handler, uiApp);
                _commandRegistry.RegisterCommand(getElementCommand);
                
                // Initialize communication channel
                // ...
                
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                // Log the error
                return Result.Failed;
            }
        }

        public Result OnShutdown(UIControlledApplication application)
        {
            // Cleanup resources
            return Result.Succeeded;
        }
    }
}

Error Handling

The SDK provides standardized error codes and handling:

csharp
try
{
    // Execute some Revit API operation
}
catch (Exception ex)
{
    return CommandResult.CreateError(
        $"Failed to execute operation: {ex.Message}",
        new { ErrorCode = JsonRPCErrorCodes.RevitApiError }
    );
}

Best Practices

  • Keep Commands Focused: Each command should do one thing well
  • Validate Parameters: Always validate input parameters before execution
  • Handle Errors Gracefully: Use the standardized error system
  • Consider Version Compatibility: Use the versioning system to manage differences between Revit versions
  • Follow UI/UX Guidelines: When building WPF interfaces, follow Revit UI/UX guidelines
  • Optimize Performance: Keep commands lightweight and efficient
  • Use Transactions Properly: Begin transactions only when necessary and commit them as soon as possible

License

RevitMCPSDK is licensed under the MIT License. See the LICENSE file for details.

Support

For support, please open an issue on the GitHub repository.

Author

Duong Tran Quang (DTDucas) contact@dtducas.com · baymax.contact@gmail.com github.com/DTDucas Author: dtducas.com

Copyright © 2025 Duong Tran Quang - DTDucas

Usa MCP RevitMCPSDK con più modelli IA

TypingMind collega gli strumenti MCP a livello di area di lavoro: una volta connesso RevitMCPSDK, puoi usarlo con diversi modelli IA in TypingMind, senza configurarlo separatamente per ogni modello. Questa integrazione MCP viene eseguita localmente sul tuo dispositivo tramite il connettore MCP di TypingMind.

Guida alla configurazione del connettore locale

Usa questo metodo quando il server MCP deve accedere a file locali, app o risorse private sul tuo computer.

1

Apri le impostazioni MCP

In TypingMind, vai su Impostazioni, Impostazioni avanzate, poi su Model Context Protocol e scegli Configura MCP.

  1. Apri TypingMind nel tuo browser.
  2. Fai clic sull'icona Impostazioni.
  3. Vai a Impostazioni avanzate.
  4. Apri la sezione Model Context Protocol.
  5. Fai clic su Configura MCP e scegli Questo dispositivo.
Schermata di configurazione del connettore MCP di TypingMind con Questo dispositivo selezionato
2

Esegui il comando del connettore

Scegli Questo dispositivo, copia il comando da TypingMind ed eseguilo nel terminale. Lascia il processo in esecuzione mentre usi MCP.

  1. Copia il comando di configurazione mostrato da TypingMind.
  2. Apri Terminale su macOS o Windows Terminal su Windows.
  3. Incolla ed esegui il comando.
  4. Conferma l'installazione del pacchetto se il terminale ti chiede di procedere.
  5. Tieni aperta la finestra del terminale con il processo in esecuzione mentre usi gli strumenti MCP.
3

Aggiungi RevitMCPSDK come server

Quando lo stato del connettore è Pronto, fai clic su Modifica server e incolla la configurazione del server MCP.

  1. Attendi che lo stato del connettore sia Pronto.
  2. Fai clic su Modifica server.
  3. Incolla la configurazione del server MCP di RevitMCPSDK.
  4. Salva l'elenco dei server.
  5. Aggiorna per verificare che il connettore sia ancora pronto.
Impostazioni MCP di TypingMind con un server attivo e il pulsante Modifica server
{
  "mcpServers": {
    "revitmcpsdk": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Usa la connessione con diversi modelli

Salva l'elenco dei server, apri Plugin, abilita gli strumenti MCP di RevitMCPSDK, poi seleziona un modello IA supportato in TypingMind e usa gli strumenti in chat o assegnali a un agente IA.

  1. Apri la pagina Plugin in TypingMind.
  2. Abilita gli strumenti MCP di RevitMCPSDK.
  3. Avvia una chat e scegli il modello IA che vuoi usare.
  4. Usa gli strumenti MCP in chat o assegnali a un agente IA.
  5. Passa a un altro modello IA quando serve, senza riconnettere MCP.
Chat di TypingMind che usa gli strumenti MCP abilitati con un modello IA selezionato
Puoi usare RevitMCPSDK per aiutarmi con questa attività?
RevitMCPSDK
Certo. Ho letto.
Ecco cosa ho trovato con RevitMCPSDK.

Domande frequenti

A cosa serve il server MCP RevitMCPSDK?

RevitMCPSDK è un server MCP che consente ai client IA compatibili di accedere a strumenti e informazioni di contesto esterni. In TypingMind puoi aggiungere questo server MCP una sola volta e rendere disponibili i suoi strumenti nella tua area di lavoro IA.

Posso usare RevitMCPSDK MCP con più modelli IA in TypingMind?

Sì. TypingMind collega gli strumenti MCP a livello di area di lavoro, quindi puoi usare RevitMCPSDK con diversi modelli IA come Claude, ChatGPT, Gemini o altri modelli che hai configurato in TypingMind, senza dover configurare il server MCP separatamente per ogni modello.

Perché usare il connettore MCP RevitMCPSDK con TypingMind?

TypingMind è una delle migliori interfacce per chattare con gli LLM perché riunisce più modelli IA, prompt, plugin, agenti IA, chiavi API e strumenti MCP in un'unica area di lavoro. Collegando RevitMCPSDK, puoi usare i suoi strumenti MCP con i tuoi modelli preferiti e mantenere organizzato il tuo flusso di lavoro in chat su TypingMind.

Come collego RevitMCPSDK MCP a TypingMind?

RevitMCPSDK funziona tramite il connettore MCP locale di TypingMind. È la soluzione ideale quando il server MCP deve accedere a file locali, app desktop, strumenti da riga di comando o risorse private sul tuo computer.

Quali strumenti offre RevitMCPSDK MCP in TypingMind?

RevitMCPSDK mette a disposizione funzionalità MCP che puoi attivare dalla pagina Plugin di TypingMind e usare in chat o assegnare agli agenti IA.

Devo condividere le mie chiavi API con TypingMind per usare RevitMCPSDK MCP?

No. TypingMind privilegia il funzionamento in locale e ti permette di mantenere il controllo su fornitori di modelli, chiavi API, prompt e configurazione MCP. Se RevitMCPSDK richiede l'autenticazione, aggiungi le intestazioni, le impostazioni OAuth o la configurazione locale necessarie per quel server MCP quando crei la connessione.

Server MCP correlati

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇