get_views
Retrieve all views from a Revit model to access architectural plans, sections, and elevations for project analysis and documentation.
Instructions
获取 Revit 模型中的所有视图
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_views"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:201-239 (handler)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, } } } ); } - src/revitService.ts:97-107 (handler)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; // 不使用模拟数据,直接抛出错误 } } - src/revitSocketClient.ts:218-222 (helper)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: {} } }, { - src/index.ts:170-173 (schema)The input schema definition for the 'get_views' tool, specifying an empty object with no properties.
inputSchema: { type: "object", properties: {} }