get_current_view_info
Retrieve details about the active view in Revit, including view type, name, and scale, to understand the current working environment.
Instructions
获取 Revit 当前活动视图的详细信息,包括视图类型、名称、比例等属性。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get_current_view_info.ts:7-36 (handler)The core handler logic for the 'get_current_view_info' MCP tool. It handles the tool call by connecting to Revit via withRevitConnection, sending the 'get_current_view_info' command, returning the JSON response as text content, or an error message on failure.server.tool('get_current_view_info', '获取 Revit 当前活动视图的详细信息,包括视图类型、名称、比例等属性。', {}, async (args, extra) => { console.error('[DEBUG] Tool get_current_view_info called with args:', args); try { console.error('[DEBUG] Establishing connection to Revit'); const response = await withRevitConnection(async (revitClient) => { console.error('[DEBUG] Sending get_current_view_info command to Revit'); return await revitClient.sendCommand('get_current_view_info', {}); }); console.error('[DEBUG] Received response from Revit:', JSON.stringify(response).substring(0, 200) + '...'); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { console.error('[DEBUG] Error in get_current_view_info:', error); return { content: [ { type: 'text', text: `get current view info failed: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } });
- src/tools/get_current_view_info.ts:4-39 (registration)The registration function for the 'get_current_view_info' tool. It calls server.tool() to register the tool with its description, empty schema, and inline handler. This function is dynamically imported and invoked by src/tools/register.ts during server startup.export function registerGetCurrentViewInfoTool(server: McpServer) { console.error('[DEBUG] Registering get_current_view_info tool'); server.tool('get_current_view_info', '获取 Revit 当前活动视图的详细信息,包括视图类型、名称、比例等属性。', {}, async (args, extra) => { console.error('[DEBUG] Tool get_current_view_info called with args:', args); try { console.error('[DEBUG] Establishing connection to Revit'); const response = await withRevitConnection(async (revitClient) => { console.error('[DEBUG] Sending get_current_view_info command to Revit'); return await revitClient.sendCommand('get_current_view_info', {}); }); console.error('[DEBUG] Received response from Revit:', JSON.stringify(response).substring(0, 200) + '...'); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { console.error('[DEBUG] Error in get_current_view_info:', error); return { content: [ { type: 'text', text: `get current view info failed: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }); console.error('[DEBUG] get_current_view_info tool registered successfully'); }