call_func
Execute Revit functions by specifying names and parameters in JSON-RPC format, enabling automation of building model operations through batch processing with parameter validation.
Instructions
调用 Revit 函数服务,支持直接传递功能名称及其参数,遵循 JSON-RPC 2.0 规范。
特性:
支持批量调用多个功能
支持传递参数给每个功能
自动验证参数有效性
完善的错误处理机制
参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"CallFunc" params (List[Dict]): 功能参数列表,必须提供至少一个函数名,每个字典包含: - name (str): 要调用的功能名称 - params (dict, optional): 功能对应的参数,可为空
返回: dict: JSON-RPC 2.0格式的响应
示例: # 调用不需要参数的函数 response = call_func(ctx, params=[ {"name": "ClearDuplicates"}, {"name": "DimensionViewPlanGrids"}, {"name": "DeleteZeroRooms"} ])
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | CallFunc | |
| params | No |
Implementation Reference
- xml_revit_mcp/server.py:50-55 (registration)call_func is included in the GENERAL_TOOLS list, indicating it is one of the general tools to be registered as an MCP tool.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 ]
- xml_revit_mcp/server.py:134-147 (registration)The register_tools function registers all tools from GENERAL_TOOLS (including call_func) to the MCP server using the server.tool() decorator.def register_tools(server: FastMCP) -> None: """注册所有工具到MCP服务器""" # 注册建筑工具 for tool in ARCHITECTURAL_TOOLS: server.tool()(tool) # 注册MEP工具 for tool in MEP_TOOLS: server.tool()(tool) # 注册通用工具 for tool in GENERAL_TOOLS: server.tool()(tool)
- xml_revit_mcp/prompts.py:57-57 (helper)Prompt template mentions using call_func() to call specific functions not predefined.- 对于未预定义的功能,使用call_func()调用特定功能
- tests/CallFunc.py:15-17 (helper)Test file demonstrates calling the underlying Revit RPC method 'CallFunc', likely what the MCP tool proxies."method": "CallFunc", "params": data, }