Skip to main content
Glama

get_current_view_info

Retrieve detailed properties of the active view in Revit, such as view type, name, and scale, using this tool to enhance project navigation and analysis.

Instructions

获取 Revit 当前活动视图的详细信息,包括视图类型、名称、比例等属性。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler for the 'get_current_view_info' tool: connects to Revit, sends 'get_current_view_info' command, returns JSON response or error.
    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)}`, }, ], }; } });
  • Registration function for the get_current_view_info tool, called dynamically from src/tools/register.ts
    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'); }
  • Dynamic registration of all tools including get_current_view_info by importing and calling registerGetCurrentViewInfoTool.
    export async function registerTools(server: McpServer) { // 获取当前文件的目录路径 const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); console.error('[DEBUG] Starting tool registration from directory:', __dirname); try { // 读取tools目录下的所有文件 const files = fs.readdirSync(__dirname); console.error(`[DEBUG] Found ${files.length} files in tools directory`); // 过滤出.ts或.js文件,但排除index文件和register文件 const toolFiles = files.filter((file) => (file.endsWith('.ts') || file.endsWith('.js')) && file !== 'index.ts' && file !== 'index.js' && file !== 'register.ts' && file !== 'register.js'); console.error(`[DEBUG] Filtered to ${toolFiles.length} tool files:`, toolFiles); // 动态导入并注册每个工具 const registeredTools = []; for (const file of toolFiles) { try { console.error(`[DEBUG] Processing tool file: ${file}`); // 构建导入路径 const importPath = `./${file.replace(/\.(ts|js)$/, '.js')}`; console.error(`[DEBUG] Import path: ${importPath}`); // 动态导入模块 const module = await import(importPath); console.error(`[DEBUG] Module imported successfully with keys:`, Object.keys(module)); // 查找并执行注册函数 const registerFunctionName = Object.keys(module).find((key) => key.startsWith('register') && typeof module[key] === 'function'); if (registerFunctionName) { console.error(`[DEBUG] Found register function: ${registerFunctionName}`); await module[registerFunctionName](server); console.error(`[DEBUG] Registered tool from file: ${file}`); registeredTools.push(file); } else { console.warn(`[DEBUG] WARNING: No register function found in file ${file}. Available exports:`, Object.keys(module)); } } catch (error) { console.error(`[DEBUG] ERROR registering tool ${file}:`, error); } } console.error(`[DEBUG] Successfully registered ${registeredTools.length} tools:`, registeredTools); // List all registered tools by tools' names try { // This is a workaround as we don't have direct access to registry in the type definitions const anyServer = server as any; if (anyServer.registry && typeof anyServer.registry.getTools === 'function') { const registeredToolNames = anyServer.registry.getTools().map((t: any) => t.id); console.error(`[DEBUG] Server has ${registeredToolNames.length} registered tools:`, registeredToolNames); } else { console.error('[DEBUG] Could not access server registry to list tools'); } } catch (err) { console.error('[DEBUG] Error trying to list registered tools:', err); } } catch (error) { console.error('[DEBUG] ERROR during tool registration process:', error); throw error; } }

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/ideook/revit-mcp'

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