Skip to main content
Glama
ZedMoster

Revit MCP Server

by ZedMoster

get_commands

Retrieve all available commands in the Revit MCP Server, including names, descriptions, and tooltips, to discover automation capabilities for building models.

Instructions

获取所有功能商店里的功能,每个功能包含名称、描述和提示信息,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息

特性:

  • 获取Revit插件中所有可用功能的完整列表

  • 返回每个功能的名称、描述和提示信息

  • 无需额外参数,直接获取所有功能

  • 完善的错误处理机制

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"GetCommands"

返回: dict: JSON-RPC 2.0格式的响应,结构为: 成功时: { "jsonrpc": "2.0", "result": [ { "name": "功能名称", "description": "功能描述", "tooltip": "功能提示" }, ... ], "id": request_id } 失败时: { "jsonrpc": "2.0", "error": { "code": int, "message": str, "data": any }, "id": request_id }

示例: # 获取所有功能 response = get_commands(ctx)

# 输出示例
{
    "jsonrpc": "2.0",
    "result": [
        {
            "name": "创建墙",
            "description": "创建基本墙元素",
            "tooltip": "点击创建标准墙"
        },
        {
            "name": "创建门",
            "description": "在墙上创建门",
            "tooltip": "选择墙后点击创建门"
        },
        ...
    ],
    "id": 1
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNoGetCommands

Implementation Reference

  • List of general MCP tools including the 'get_commands' tool, used for registration.
    GENERAL_TOOLS = [
        get_commands, execute_commands, call_func,
        find_elements, update_elements, delete_elements, parameter_elements, get_locations, move_elements,
        show_elements, active_view, get_selected_elements,
        link_dwg_and_activate_view, get_view_data
    ]
  • Registers all tools in GENERAL_TOOLS (including get_commands) to the FastMCP server using the @tool decorator.
    # 注册通用工具
    for tool in GENERAL_TOOLS:
        server.tool()(tool)
  • Inspects the get_commands tool function to generate its metadata (name, description, parameters) for listing available tools.
    for tool in GENERAL_TOOLS:
        sig = inspect.signature(tool)
        params = []
        for param_name, param in sig.parameters.items():
            if param_name != 'ctx':
                param_info = {
                    "name": param_name,
                    "required": param.default == inspect.Parameter.empty,
                    "default": None if param.default == inspect.Parameter.empty else param.default
                }
                params.append(param_info)
    
        doc = inspect.getdoc(tool)
        description = doc.split('\n')[0] if doc else "无描述"
    
        tool_info = {
            "name": tool.__name__,
            "description": description,
            "full_doc": doc,
            "parameters": params
        }
        tools_info["general"].append(tool_info)
  • Prompt documentation instructing users to use get_commands() to get all available functions.
    def asset_creation_strategy() -> str:
        """定义在Revit中创建资产的首选策略"""
        return """创建Revit模型元素时,请遵循以下策略和最佳实践:
    
        0. 在创建任何元素前,优先检查当前项目状态:
           - 使用get_commands()获取所有可用功能
           - 使用get_selected_elements()检查当前选中的元素
           - 使用find_elements()查找特定类别的现有元素
    
        1. 始终遵循正确的创建顺序:
           1. 基础参考系统
              - 使用create_levels()创建必要的标高
              - 使用create_grids()创建轴网系统
              - 使用create_floor_plan_views()为每个标高创建平面视图
    
           2. 主体结构元素
              - 使用create_walls()创建墙体,注意指定正确的起点、终点、高度和宽度
              - 使用create_floors()创建楼板,确保边界点形成封闭环路
    
           3. 二次构件
              - 使用create_door_windows()在墙体上创建门窗
                注意:门窗族需要指定宿主墙,所以必须先有墙再创建门窗
              - 使用get_locations()获取墙体的位置信息,以便正确放置门窗
    
           4. MEP系统
              - 使用create_ducts()创建风管
              - 使用create_pipes()创建管道
              - 使用create_cable_trays()创建电缆桥架
    
           5. 内部划分和标注
              - 使用create_rooms()在封闭区域创建房间
              - 使用create_room_tags()添加房间标签
    
           6. 文档整理
              - 使用create_sheets()创建图纸
              - 使用active_view()切换到需要的视图
              - 使用link_dwg_and_activate_view()链接DWG图纸
    
        2. 操作现有元素时的最佳实践:
           - 使用parameter_elements()获取元素参数,然后使用update_elements()修改
           - 使用move_elements()调整元素位置
           - 使用show_elements()在视图中高亮显示特定元素
           - 使用delete_elements()移除不需要的元素
    
        3. 创建复杂组件时:
           - 使用create_family_instances()创建参数化族实例
           - 对于未预定义的功能,使用call_func()调用特定功能
    
        4. 所有元素创建后的检查与验证:
           - 检查元素参数是否符合要求
           - 确保结构完整性和空间关系合理性
           - 使用show_elements()检查关键元素
           - 使用active_view()切换到需要的视图
    
        仅在以下情况使用原生RevitAPI:
        - 上述函数不能满足特定需求
        - 需要创建自定义参数或复杂约束
        - 需要进行高级计算或特殊几何操作
        - 需要与其他应用程序进行数据交换
        - 如果获取BuiltInCategory失败可以通过get_all_builtin_category查找
        """
  • Imports all tool functions including get_commands from the tools module.
    from .tools import *

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZedMoster/revit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server