Open-source Revit MCP server: let Claude and other AI assistants read and edit BIM models, with human approval on every change.
Python aecai-agentsautodeskautomationbimclaudeifcmcpmcp-servermodel-context-protocolnavisworksrevitrevit-addinrevit-apirhino
feat: Introduce Revit MCP server and bridge add-in with various automation tools, and update README logos.
A. Sam Mohammad1d2c218c3d6c
diff --git a/README.md b/README.mdindex 8ac400b..d63b0b5 100644--- a/README.md+++ b/README.md@@ -2,13 +2,13 @@<img src="https://raw.githubusercontent.com/modelcontextprotocol/docs/main/logo/light.svg" alt="MCP Logo" width="120"/>-<!-- Official logos: place images in `assets/logos/` with the filenames below to render here -->+<!-- Logos --><p>- <img src="assets/logos/autodesk-revit.png" alt="Autodesk Revit" height="36" style="margin-right:12px;"/>- <img src="assets/logos/microsoft-copilot.png" alt="Microsoft Copilot" height="36" style="margin-right:12px;"/>- <img src="assets/logos/model-context-protocol.svg" alt="Model Context Protocol" height="36" style="margin-right:12px;"/>- <img src="assets/logos/python.svg" alt="Python" height="36" style="margin-right:12px;"/>- <img src="assets/logos/dotnet.svg" alt=".NET" height="36"/>+ <img src="https://upload.wikimedia.org/wikipedia/commons/9/9d/Autodesk_Revit_icon.svg" alt="Autodesk Revit" height="40" style="margin-right:15px;"/>+ <img src="https://upload.wikimedia.org/wikipedia/commons/2/2a/Microsoft_365_Copilot_Icon.svg" alt="Microsoft Copilot" height="40" style="margin-right:15px;"/>+ <img src="https://modelcontextprotocol.io/images/logo.svg" alt="Model Context Protocol" height="40" style="margin-right:15px;"/>+ <img src="https://upload.wikimedia.org/wikipedia/commons/c/c3/Python-logo-notext.svg" alt="Python" height="40" style="margin-right:15px;"/>+ <img src="https://upload.wikimedia.org/wikipedia/commons/7/7d/Microsoft_.NET_logo.svg" alt=".NET" height="40"/></p># 🏗️ RevitMCP: AI-Powered Revit Automationdiff --git a/packages/mcp-server-revit/src/revit_mcp_server/mcp_server.py b/packages/mcp-server-revit/src/revit_mcp_server/mcp_server.pyindex ce24237..8316692 100644--- a/packages/mcp-server-revit/src/revit_mcp_server/mcp_server.py+++ b/packages/mcp-server-revit/src/revit_mcp_server/mcp_server.py@@ -652,6 +652,9 @@ async def call_tool(name: str, arguments: Any) -> list[TextContent]:Tool(name="revit_create_material", description="Create a new material with color and properties", inputSchema={"type": "object", "properties": {"name": {"type": "string"}, "color": {"type": "object", "properties": {"r": {"type": "integer"}, "g": {"type": "integer"}, "b": {"type": "integer"}}}, "transparency": {"type": "integer", "default": 0}, "shininess": {"type": "integer", "default": 50}, "smoothness": {"type": "integer", "default": 50}}, "required": ["name"]}),Tool(name="revit_set_element_material", description="Set material for an element or specific face", inputSchema={"type": "object", "properties": {"element_id": {"type": "integer"}, "material_name": {"type": "string"}, "face_index": {"type": "integer", "description": "Optional face index for face-specific material"}}, "required": ["element_id", "material_name"]}),Tool(name="revit_get_render_settings", description="Get rendering settings from document", inputSchema={"type": "object", "properties": {}}),+ # Batch 7: Family Management+ Tool(name="revit_convert_to_group", description="Convert elements into a group", inputSchema={"type": "object", "properties": {"element_ids": {"type": "array", "items": {"type": "integer"}}, "name": {"type": "string"}}, "required": ["element_ids"]}),+ Tool(name="revit_edit_family", description="Open a family for editing", inputSchema={"type": "object", "properties": {"family_name": {"type": "string"}, "family_symbol_id": {"type": "integer"}, "family_instance_id": {"type": "integer"}}, "required": []}),],"level": arguments.get("level", "L1")}),@@ -814,3 +817,4 @@ if __name__ == "__main__":run_mcp_server()+diff --git a/packages/revit-bridge-addin/src/Bridge/BridgeCommandFactory.cs b/packages/revit-bridge-addin/src/Bridge/BridgeCommandFactory.csindex a3efa99..8bdc723 100644--- a/packages/revit-bridge-addin/src/Bridge/BridgeCommandFactory.cs+++ b/packages/revit-bridge-addin/src/Bridge/BridgeCommandFactory.cs@@ -149,6 +149,10 @@ public static class BridgeCommandFactory"revit.set_element_material" => ExecuteSetElementMaterial(app, payload),"revit.get_render_settings" => ExecuteGetRenderSettings(app),+ // Batch 7: Family Management+ "revit.convert_to_group" => ExecuteConvertToGroup(app, payload),+ "revit.edit_family" => ExecuteEditFamily(app, payload),+_ => new { status = "error", message = $"Unknown tool: {tool}" }};}@@ -288,7 +292,11 @@ public static class BridgeCommandFactory// Batch 6: Materials & Visuals"revit.create_material","revit.set_element_material",- "revit.get_render_settings"+ "revit.get_render_settings",++ // Batch 7: Family Management+ "revit.convert_to_group",+ "revit.edit_family"};}@@ -3693,4 +3701,113 @@ public static class BridgeCommandFactory}return new Color(128, 128, 128); // Default gray}++ // ==================== BATCH 7: FAMILY MANAGEMENT ====================++ private static object ExecuteConvertToGroup(UIApplication app, JsonElement payload)+ {+ var doc = app.ActiveUIDocument?.Document;+ if (doc == null) throw new InvalidOperationException("No active document");++ JsonElement idsElement;+ if (!payload.TryGetProperty("element_ids", out idsElement))+ throw new ArgumentException("element_ids is required");++ var elementIds = new List<ElementId>();+ foreach (var id in idsElement.EnumerateArray())+ {+ elementIds.Add(new ElementId((long)id.GetInt32()));+ }++ if (elementIds.Count == 0)+ throw new ArgumentException("element_ids list cannot be empty");++ var name = payload.TryGetProperty("name", out var n) ? n.GetString() : null;++ using (var trans = new Transaction(doc, "Create Group"))+ {+ trans.Start();++ var group = doc.Create.NewGroup(elementIds);++ if (!string.IsNullOrEmpty(name))+ {+ // Uniqueness check handled by Revit usually, but good practice to handle errors+ try {+ group.GroupType.Name = name;+ } catch {+ // Ignore name conflict if auto-naming is acceptable, or handle specifically+ }+ }++ trans.Commit();++ return new+ {+ group_id = group.Id.Value,+ group_name = group.Name,+ group_type_name = group.GroupType.Name,+ member_count = elementIds.Count+ };+ }+ }++ private static object ExecuteEditFamily(UIApplication app, JsonElement payload)+ {+ var doc = app.ActiveUIDocument?.Document;+ if (doc == null) throw new InvalidOperationException("No active document");++ // This is a special command - it might change the Active Document context+ // This generally works best in the UI context, but for API automation, we open the family document.++ var familyName = payload.TryGetProperty("family_name", out var fn) ? fn.GetString() : null;+ var familySymbolId = payload.TryGetProperty("family_symbol_id", out var fsid) ? (int?)fsid.GetInt32() : null;+ var familyInstanceId = payload.TryGetProperty("family_instance_id", out var fiid) ? (int?)fiid.GetInt32() : null;++ Family family = null;++ if (familyInstanceId.HasValue)+ {+ var instance = doc.GetElement(new ElementId((long)familyInstanceId.Value)) as FamilyInstance;+ family = instance?.Symbol.Family;+ }+ else if (familySymbolId.HasValue)+ {+ var symbol = doc.GetElement(new ElementId((long)familySymbolId.Value)) as FamilySymbol;+ family = symbol?.Family;+ }+ else if (!string.IsNullOrEmpty(familyName))+ {+ family = new FilteredElementCollector(doc)+ .OfClass(typeof(Family))+ .Cast<Family>()+ .FirstOrDefault(f => f.Name.Equals(familyName, StringComparison.OrdinalIgnoreCase));+ }++ if (family == null)+ throw new ArgumentException("Could not identify family to edit from provided arguments");++ if (!family.IsEditable)+ throw new InvalidOperationException($"Family '{family.Name}' is not editable");++ // Open the family document+ var familyDoc = doc.EditFamily(family);++ // In a real UI workflow, this would switch the view. In API context, it returns the document.+ // We can't easily "switch" the user's view via pure API without some hacks,+ // but we can make it the active document if using the OpenAndActivateDocument method (UIApp).+ // For now, we return info that it was opened, but the user might need to manually switch or we can try to activate it.++ // Attempt to activate (only works if no other command is running, tricky in nested context)+ // app.OpenAndActivateDocument(familyDoc.PathName); // PathName might be empty for in-memory edit++ return new+ {+ status = "family_document_opened",+ family_name = family.Name,+ family_document_title = familyDoc.Title,+ is_family_document = familyDoc.IsFamilyDocument,+ categories = new FilteredElementCollector(familyDoc).OfClass(typeof(Category)).Cast<Category>().Select(c => c.Name).Take(10).ToList()+ };+ }}