Content
# How to Create and Generate MCP DLL Files for CallFunc Invocation
This document describes how to create an MCP DLL file for invocation by the CallFunc method. The MCP DLL file needs to implement the interface `xml.Revit.MCP.Public.IMCPMethod` and interact with Revit's MCP service according to the JSON-RPC 2.0 specification.
## Structure and Implementation of MCP DLL
Create an Implementation Class
Implement the `IMCPMethod` Interface
Here is an example of an implementation class that creates a new level and returns the new level as `ElementModelRequest`:
```C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.DB.Structure;
using Autodesk.Revit.UI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using xml.Revit.MCP.Models;
using xml.Revit.MCP.Public;
using xml.Revit.Toolkit.Attributes;
using xml.Revit.Toolkit.Extensions;
using xml.Revit.Toolkit.Utils;
namespace xml.Revit.MCPServer
{
/// <summary>
/// Class that implements the functionality to add a new level, inheriting from the IMCPMethod interface.
/// </summary>
public sealed class TopLevelAdd : IMCPMethod
{
/// <summary>
/// Constructor that initializes the method name.
/// </summary>
public TopLevelAdd()
{
MethodName = "新增标高";
}
/// <summary>
/// Method name used to identify the current functionality.
/// </summary>
public string MethodName { get; private set; }
/// <summary>
/// Executes the core logic for adding a new level.
/// </summary>
/// <param name="request">JsonRPCRequest object containing request parameters.</param>
/// <param name="uidoc">Current Revit UIDocument object.</param>
/// <returns>Returns a JsonRPCResponse object containing the execution result.</returns>
public JsonRPCResponse Execute(JsonRPCRequest request, UIDocument uidoc)
{
// Initialize response object
var jsonResponse = new JsonRPCResponse();
// Get the current document
var doc = uidoc.Document;
// Default elevation offset in millimeters
double elevationOffset = 3000d;
// Parse elevation offset from request parameters
var obj = request.Params as JObject;
if (obj != null)
{
elevationOffset = obj["offset"].Value<double>();
}
// Get the highest level in the document
var highestLevel = doc.OfClass<Level>().OrderBy(l => l.Elevation).LastOrDefault();
if (highestLevel == null)
{
throw new InvalidOperationException("No valid level found.");
}
// Start a transaction and create a new level
doc.Transaction(t =>
{
var newLevel = Level.Create(
doc,
highestLevel.Elevation + elevationOffset.MMToFeet() // Convert offset to feet
);
// Encapsulate new level information into the response result
jsonResponse.Result = new ElementModelRequest(newLevel);
});
return jsonResponse; // Return response object
}
}
}
```
Compile the project in Visual Studio to generate the .dll file. After compilation, ensure that the generated .dll file is located in the specified MCP folder.

By following the above steps, you can easily create and generate MCP DLL files and integrate them into Revit's MCP service for dynamic invocation.

## mcp-tool
[call_func Click here for source implementation](https://github.com/ZedMoster/revit-mcp/blob/main/xml_revit_mcp/tools.py#L204)
In large models, you can directly achieve this by pressing the prompt word through `CallFunc`
```python
response = call_func(ctx, params=[
{"name": "新增标高", "params": {"offset": 3000}}
])
```
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.
git
A Model Context Protocol server for Git automation and interaction.