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
Below is an example of an implementation class that creates a new level and returns the new level as an `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 = "Add New Level";
}
/// <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">A JsonRPCRequest object containing the request parameters.</param>
/// <param name="uidoc">The 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 implement it by pressing the prompt word through `CallFunc`
```python
response = call_func(ctx, params=[
{"name": "Add New Level", "params": {"offset": 3000}}
])
```
Connection Info
You Might Also Like
MarkItDown MCP
Converting files and office documents to Markdown.
Time
Obtaining current time information and converting time between different...
Filesystem
Model Context Protocol Servers
Sequential Thinking
Offers a structured approach to dynamic and reflective problem-solving,...
Git
Model Context Protocol Servers
Context 7
Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors