open_document
Access and open Revit project files directly from the specified file path, enabling streamlined interaction with Autodesk Revit for project management and modifications.
Instructions
Open Document
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | No | File Path |
Implementation Reference
- src/tools/open_document.ts:5-42 (registration)The registration function for the 'open_document' MCP tool. It defines the tool name, description, input schema (optional filePath string), and the handler logic which sends an 'open_document' command to the Revit client using withRevitConnection and returns the response as text content or an error message.export function registerOpenDocumentTool(server: McpServer) { server.tool( 'open_document', 'Open Document', { filePath: z.string().optional().describe('File Path'), }, async (args, extra) => { const params = { filePath: args.filePath, }; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand('open_document', params); }); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `document open failed: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } } ); }
- src/tools/open_document.ts:12-40 (handler)Inline handler function that implements the core logic of the 'open_document' tool: prepares params from args, executes the Revit command via connection manager, and formats response or error as MCP content.async (args, extra) => { const params = { filePath: args.filePath, }; try { const response = await withRevitConnection(async (revitClient) => { return await revitClient.sendCommand('open_document', params); }); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `document open failed: ${error instanceof Error ? error.message : String(error)}`, }, ], }; } }
- src/tools/open_document.ts:9-11 (schema)Input schema for the 'open_document' tool, defining an optional 'filePath' parameter as a string.{ filePath: z.string().optional().describe('File Path'), },