Skip to main content
Glama
ZedMoster

Revit MCP Server

by ZedMoster

parameter_elements

Retrieve parameter data from Revit elements, enabling batch queries for specific or all parameters to support building model analysis and automation.

Instructions

获取Revit元素的参数信息,支持批量查询和特定参数查询,遵循JSON-RPC 2.0规范。 mcp_tool使用时params不要有任何注释信息

特性:

  • 支持批量查询多个元素的参数

  • 可查询特定参数或元素所有参数

  • 返回参数哈希码、名称和值的完整信息

  • 完善的错误处理机制

参数: ctx (Context): FastMCP上下文对象 method (str): JSON-RPC方法名,默认为"ParameterElements" params (List[Dict]): 查询参数列表,每个字典包含: - elementId (Union[int, str]): 要查询的元素ID - parameterName (str, optional): 要查询的特定参数名称

返回: dict: JSON-RPC 2.0格式的响应,结构为: 成功时: { "jsonrpc": "2.0", "result": { "elementId1": [ { "hashCode": int, "parameterName": str, "parameterValue": str, } ], ... }, "id": request_id } 失败时: { "jsonrpc": "2.0", "error": { "code": int, "message": str, "data": any }, "id": request_id }

示例: # 查询多个元素的参数 response = parameter_elements(ctx, params=[ {"elementId": 212792, "parameterName": "注释"}, # 获取特定参数 {"elementId": 212781} # 获取所有参数 ])

# 输出示例
{
    "jsonrpc": "2.0",
    "result": {
        "212792": [
            {
                "hashCode": 12345,
                "parameterName": "注释",
                "parameterValue": "示例注释",
            }
        ],
        "212781": [
            {
                "hashCode": 23456,
                "parameterName": "长度",
                "parameterValue": "5000",
            },
            ...
        ]
    },
    "id": 1
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
methodNoParameterElements
paramsNo

Implementation Reference

  • 'parameter_elements' tool is registered as part of the GENERAL_TOOLS list in server.py. These tools are registered to the MCP server using the register_tools function.
    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
    ]
  • The register_tools function registers all tools in GENERAL_TOOLS (including parameter_elements) using the FastMCP tool decorator.
    # 注册通用工具
    for tool in GENERAL_TOOLS:
        server.tool()(tool)
  • The RevitConnection.send_command method is used by tool handlers to forward tool calls (like 'parameter_elements') to the Revit plugin via TCP/JSON-RPC.
    def send_command(self, command_type: str, params: Union[Dict[str, Any], List[Dict[str, Any]]] = None) -> Dict[
        str, Any]:
        """
        向Revit发送命令并返回响应
    
        参数:
            command_type (str): 命令类型
            params (Dict[str, Any] 或 List[Dict[str, Any]]): 命令参数
    
        返回:
            Dict[str, Any]: 命令响应
    
        异常:
            ConnectionError: 连接错误
            TimeoutError: 请求超时
            ValueError: 参数或响应无效
            Exception: 其他错误
        """
        # 确保连接
        if not self.sock and not self.connect():
            raise ConnectionError("无法连接到Revit")
    
        try:
            logger.info(f"发送命令: {command_type}")
            logger.debug(f"命令参数: {params}")
    
            # 导入并创建请求对象
            from .rpc import JsonRPCRequest, JsonRPCResponse
            command = JsonRPCRequest(method=command_type, params=params)
            command_json = json.dumps(command.__dict__)
    
            # 发送命令
            self.sock.sendall(command_json.encode('utf-8'))
            logger.debug("命令已发送,等待响应...")
    
            # 使用 receive_full_response 接收完整数据流
            response_data = self.receive_full_response()
            logger.debug(f"已接收 {len(response_data)} 字节数据")
    
            # 解析响应
            try:
                response_dict = json.loads(response_data.decode('utf-8'))
                response = JsonRPCResponse(
                    id=response_dict.get("id"),
                    result=response_dict.get("result"),
                    error=response_dict.get("error")
                )
            except json.JSONDecodeError as e:
                logger.error(f"无法解析Revit响应: {str(e)}")
                if response_data:
                    logger.error(f"原始响应 (前200字节): {response_data[:200]}")
                raise ValueError(f"无效的Revit响应: {str(e)}")
    
            # 处理错误
            if response.error:
                error_message = response.error.get("message", "未知错误")
                error_code = response.error.get("code", -1)
                error_data = response.error.get("data")
    
                logger.error(f"Revit错误 (代码: {error_code}): {error_message}")
                if error_data:
                    logger.error(f"错误数据: {error_data}")
    
                raise Exception(f"Revit错误: {error_message}")
    
            return response.result or {}
    
        except socket.timeout:
            self.sock = None
            raise TimeoutError("等待Revit响应超时 - 请尝试简化请求")
    
        except (ConnectionError, BrokenPipeError, ConnectionResetError) as e:
            self.sock = None
            raise ConnectionError(f"与Revit的连接丢失: {str(e)}")
    
        except json.JSONDecodeError as e:
            logger.error(f"Revit响应的JSON无效: {str(e)}")
            if 'response_data' in locals() and response_data:
                logger.error(f"原始响应 (前200字节): {response_data[:200]}")
            raise ValueError(f"Revit响应无效: {str(e)}")
    
        except (ValueError, TimeoutError, ConnectionError) as e:
            self.sock = None
            raise
    
        except Exception as e:
            logger.error(f"与Revit通信时出错: {str(e)}")
            self.sock = None
            raise Exception(f"与Revit通信错误: {str(e)}")
  • Final call to register_tools which includes parameter_elements.
    register_tools(mcp)
    mcp.list_tools = types.MethodType(list_tools, mcp)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds useful context: it mentions JSON-RPC 2.0 compliance, batch querying capabilities, error handling, and that it returns hash codes, names, and values. However, it doesn't cover important behavioral aspects like rate limits, authentication needs, whether it's read-only or destructive, or performance characteristics. The description provides some behavioral insight but leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections (特性, 参数, 返回, 示例) but is overly verbose. It includes implementation details like 'mcp_tool使用时params不要有任何注释信息' (when using mcp_tool, params should not have any comment information) and JSON-RPC formatting specifics that aren't essential for tool selection. The example is detailed but could be more concise. Some sentences don't earn their place for an AI agent's decision-making.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 0% schema coverage and no output schema, the description does a good job compensating. It explains parameter semantics, provides a detailed return structure with success/error cases, and includes a comprehensive example. However, it lacks context on when to use this tool (guidelines) and some behavioral aspects (transparency), which slightly reduces completeness for a query tool with no annotations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must fully compensate. It does this effectively: it explains that 'params' is a list of dictionaries containing 'elementId' and optional 'parameterName', and provides clear examples. It also clarifies that 'method' defaults to 'ParameterElements'. This adds substantial meaning beyond the bare schema, though it could briefly explain the 'ctx' parameter's role as a FastMCP context object.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '获取Revit元素的参数信息,支持批量查询和特定参数查询' (Get parameter information for Revit elements, supporting batch queries and specific parameter queries). It specifies the verb (获取/query), resource (Revit元素参数/Revit element parameters), and scope (批量/batch, 特定/specific). However, it doesn't explicitly differentiate from sibling tools like 'find_elements' or 'get_view_data', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. While it mentions batch querying and specific parameter queries, it doesn't explain when to choose this over sibling tools like 'find_elements' (which might locate elements) or 'get_view_data' (which might get view-specific data). There's no mention of prerequisites, constraints, or typical use cases beyond the basic functionality.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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