Skip to main content
Glama

get_views

Retrieve all views from a Revit model to access architectural plans, sections, and elevations for project analysis and documentation.

Instructions

获取 Revit 模型中的所有视图

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP server request handler for CallToolRequestSchema. Dynamically converts tool name 'get_views' to 'getViews' and invokes the corresponding method on RevitService instance.
      this.server.setRequestHandler(
        CallToolRequestSchema,
        async (request) => {
          // 获取工具名称
          const toolName = request.params.name;
    
          // 将工具名称转换为 camelCase 方法名
          const methodName = toolName.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
    
          // 检查 RevitService 是否有对应的方法
          if (typeof (this.revitService as any)[methodName] !== 'function') {
            throw new McpError(
              ErrorCode.MethodNotFound,
              `未知工具: ${toolName}`
            );
          }
    
          try {
            // 动态调用对应的方法
            const result = await (this.revitService as any)[methodName](request.params.arguments || {});
            //const result = '';
            return {
              content: [{
                type: "text",
                text: JSON.stringify(result, null, 2)
              }]
            };
          } catch (error) {
            return {
              content: [{
                type: "text",
                text: `Revit API 错误: ${error instanceof Error ? error.message : String(error)}`
              }],
              isError: true,
            }
          }
        }
      );
    }
  • The specific getViews() method on RevitService class, executed as the tool handler logic for 'get_views'. Delegates the call to the underlying RevitSocketClient.
    /**
     * 获取所有视图
     */
    async getViews(): Promise<any[]> {
      try {
        return await this.client.getViews();
      } catch (error) {
        console.error('[RevitService] 获取视图失败:', error);
        throw error; // 不使用模拟数据,直接抛出错误
      }
    }
  • The RevitSocketClient.getViews() helper method that sends the 'get_views' command with empty arguments to the Revit socket server and returns the response.
     */
    public async getViews(): Promise<any[]> {
      const response = await this.sendRequest<any[]>('get_views', {});
      return response;
    }
  • src/index.ts:167-174 (registration)
    The tool registration entry for 'get_views' in the ListToolsRequestSchema response, including name, description, and input schema.
    }, {
      name: "get_views",
      description: "获取 Revit 模型中的所有视图",
      inputSchema: {
        type: "object",
        properties: {}
      }
    }, {
  • The input schema definition for the 'get_views' tool, specifying an empty object with no properties.
    inputSchema: {
      type: "object",
      properties: {}
    }

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/PiggyAndrew/revit_mcp'

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