Revit & MCP
Github
https://github.com/imkcrevit/RevitMCP_Blog
Introduction
Currently, the internet is flooded with various AI-related information. As recent development work involves AI technology, this article introduces the integration method between MCP and Revit to achieve the “one-click modeling” feature in public accounts.
This is just one of the possible implementation approaches, and other technical paths exist. However, this method allows for rapid deployment, helping teams quickly explore relevant application directions.
Function Call
Before discussing MCP, it’s essential to introduceFunction Calling—a capability provided by LLM APIs. By definingFunction Callspecifications during interactions with the LLM, the model can autonomously select and execute the appropriate functions when needed.
**Picture From:ailydoseofds **
TakingDeepSeekas an example, its API documentation provides a clear guide on how to useFunction Calling.
1 | tools = [ |
The underlying logic is that the LLM, when generating a response, will:
- Select the appropriate function based on the context and generate compliant parameters.
- Execute the function.
- Retrieve the result and return it.
- Summarize the output and deliver it to the client interface.
MCP
Introduce MCP
MCP (Model Context Protocol) is an extension protocol of Function Calling technology. Its core value lies in standardized modeling, enabling developers to write a single Function Call definition that seamlessly adapts to multiple mainstream LLMs (e.g., DeepSeek, ChatGPT, etc.).
How It Works:
- Unified Modeling: Generates platform-agnostic invocation instructions compliant with cross-model specifications.
- Autonomous Execution: The LLM dynamically selects the optimal execution path based on the standardized context.
- Cross-Model Compatibility: Ensures consistent function calling behavior across different model providers.

**图片来源:ailydoseofds **
MCP Framework
The MCP framework consists of three core components:
- Host
- Client
- Server
MCP Server
MCP supports multiple communication methods to adapt to different application scenarios:
1. Stdio (Standard Input/Output)
- Usage: Commonly used for local data exchange via stdin/stdout.
- Application: Suitable for Revit integration—either use the default Stdio mode or implement a custom
IMcpTransportfor Revit-specific optimizations.
2. Stream (HTTP-based Streaming)
- Protocol: Fully compliant with standard HTTP for web-based interactions.
- Advantage: Ideal for real-time data streaming in web applications.
3. SSE (Server-Sent Events)
- Mechanism: Uses HTTP long-polling for persistent remote communication.
- Use Case: Efficient for scenarios requiring server-to-client push updates (e.g., live logs, progress tracking).
MCP Process
Prompt
Introduction
In API-based MCP implementations, prompt engineering plays a decisive role, with its core value reflected in:
1. Tool Selection Accuracy
By dynamically adjusting conversational bias, it guides the LLM to select the most suitable tool in each interaction.
2. Probability Distribution Control
Uses constrained prompts to adjust the model’s output probability distribution, making responses better align with target requirements.
3. Prompt Engineering in API Context
In MCP API calls, prompt engineering is critical—it directly impacts the accuracy of tool (Tools) selection. Each round of dialogue influences the model’s decision-making tendency, and optimized prompts can guide the model to produce more expected results.
4. Example: BIM Expert System
- Role Setting: Defined as “BIM Expert” in
systemto ensure precise selection of design tools. - Additional Constraints: For smoother interaction, further prompt optimization is needed, such as limiting tool scope or adjusting matching logic.
5. Tool Matching Mechanism
The LLM selects based on Tool Description and dynamically matches the most suitable tool through response content, ensuring precise and efficient interactions.
.NET MCP Framework
Since Revit has extensive support for C#, we chose the .NET MCP framework: modelcontextprotocol.
.NET MCP Framework Overview
This is an open-source MCP framework supporting .NET, where the source code can be directly downloaded from GitHub for learning. The framework uses traditional I/O transmission and outputs via the console.
As users, we only need to understand the following interfaces:
Tools
- Use
[McpServerToolType]to define the Tools class - Use
[McpServerTool]to define specific methods - The following method can invoke the LLM to output a string
1
2
3
4
5
6
7
8
9
10[]
public class RevitTool
{
[]
public string RevitCommandTool(string command)
{
Console.WriteLine(command);
//MessageBox.Show($"Revit Command: {command}", "Revit Tool Command", MessageBoxButtons.OK, MessageBoxIcon.Information);
return command;s
}
- Use
Server
- The framework supports both dependency injection and declarative approaches:
- Inject and publish
Tools - Simply put, it allows all your
Toolsto be published without manual integration intoFunction Call. The LLM automatically reads their descriptions and invokes them as needed.1
2
3
4
5
6var builder = Host.CreateApplicationBuilder();
builder.Services.AddMcpServer()
.WithStdioServerTransport()
.WithTools<RevitTool>();
await builder.Build().RunAsync();
Client
- Use Local Path To Execute Service
1 | await using var mcpClient = await McpClientFactory.CreateAsync(new StdioClientTransport(new StdioClientTransportOptions() |
- Implement LLM dialogue and pass the Tools data from the Server to the LLM. Here, I am using DeepSeek’s API to achieve LLM dialogue by calling the API.
1 | var openAiOptions = new OpenAIClientOptions(); |
- Get Values
1 | var res = await client.GetResponseAsync(prompts, chatOptions); |
Bind Revit
Preview
[[Revit & MCP]]
Introduce
When using MCP or FunctionCall in Revit, the code examples demonstrate that the LLM can automatically select and execute the appropriate tools based on input, thereby enabling AI-driven modeling or review operations.
Therefore, I believe this approach is better suited for teams that already have plugin development capabilities or established design workflows. For teams with limited development resources, using MCP may be less time-efficient than direct manual operations or developing plugins with fixed logic.
Bind
1.The previous explanation mentioned that stdio uses standard input/output, but this conflicts with Revit’s inherent mechanism. Directly waking up the server within Revit to fetch data would cause Revit to freeze, as the entire process would be blocked. Therefore, in my case, I resolved this by using a separate process to launch a console, thereby obtaining console input before connecting to Revit.
- The issue likely lies in the use of
TextReader/TextWriterin theTransportcomponent. In the source code, this is located at:
ModelContextProtocol.Protocol.Transport\StreamClientSessionTransport
- The second approach involves connecting to the MCP service via Idling events, where WCF (Windows Communication Foundation) can also enable automated MCP execution. Those interested can implement this themselves.
However, the Idling event’s thread must be properly constrained—otherwise, continuous API feedback polling could still cause Revit to freeze.https://thebuildingcoder.typepad.com/blog/2012/11/drive-revit-through-a-wcf-service.html
- The third approach involves directly modifying the source code to implement a custom
TransportBaseorITransport, specifically tailored for client-side request handling. - The last approach is a more straightforward method, which I find quite effective. Since non-commercial clients typically interact with a single LLM provider, such as
ChatGPTorDeepSeek, usingFunction Calldirectly is also viable. This avoids thread blocking and allows for direct invocation.
Revit
If the Server and Client are already implemented, the key change needed for Revit is to add new input parameter retrieval. Since AI inputs and outputs are entirely text-based, if we want the LLM to drive automatic execution, we must unify the parameter input interface for methods.
In this project, I used JSON as the conversion format. By transforming parameters into JSON, we enable method execution while ensuring minimal future modifications to the methods.
Preparations
Standard Output Format
- As mentioned earlier, JSON is used for input and output. Therefore, modifications were made in the tools to ensure that both the desired method name and parameters are output together. Taking wall creation as an example: the start and end points of the positioning line are obtained. If the parameters are more complex, the description must clearly mark the content to prevent incorrect data or parameters.
Description:
1 | "Generation A Window In A Selection Wall , Define Window Size : 1500 x 1200 d, Need To Calculate The Window-Top Is Small Then Wall-Height , This Command Need Input Args : ElementId , LocationX , LocationY ,LocationZ") |
1 | Tool: |
- In Revit, create a data structure to receive data and convert it into usable data.
1 | public class CreateWallData |
- Create an interface to standardize our plugin commands. Here I’ve simply created one that expects all entry points to accept JSON strings, with data being parsed separately within the methods.
1 | public interface IRevitCommand |
- For the execution function, implement the interface to convert the original coordinate points into JSON strings.
1 | /// <summary> |
- Using reflection, we can locate the methods implementing the
IRevitCommandinterface and create new methods for execution.
1 | // 1. Load DLL |
- If interaction with Revit is needed, simply adding parameters to the
argumentswill enable Revit-LLM interaction. Compared to the above, this involves adding code to select a wall and pass its ID and data to the LLM as a reference for inserting doors and windows.
1 | var args = string.Empty; |
- Use
processExecuteclientand Get Input / OutPut
1 | var process = new Process |
Actual Execution
Execution Content
In this project, I will invoke the LLM to create a wall, then after selecting the wall, continue to call the LLM to insert a window at any position, achieving multi-turn dialogue and bidirectional interaction between Revit and the LLM.
MCP-Server
1 | using System.ComponentModel; |
MCP-Client
1 | using Microsoft.Extensions.AI; |
Revit
1 |
|
Summary
From practical cases, it is evident that the application path of AI in the construction industry has become relatively clear, far from the exaggerated and mystified portrayals in certain articles or videos. As users, we should focus more on AI’s efficiency-enhancing capabilities in specific scenarios, such as code compliance review, batch modeling, and drawing processing.
The purpose of this article is to help readers establish a fundamental understanding of AI technology through a simple case study. Currently, public accounts and online articles are flooded with mixed-quality content, which can easily lead to misconceptions. By demonstrating real-world examples, practitioners can more accurately assess the application scope and depth of AI, thereby effectively identifying and filtering out irrelevant or misleading information.
(Get-Appx




