load-frag
Load a .frag file into the Fragment MCP Server to process and query Building Information Modeling (BIM) data by category. Requires the file path of the fragment file.
Instructions
Load a .frag file. Needs file-system server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Full path of the file to load with fragments |
Implementation Reference
- main.ts:72-99 (handler)The handler function for the 'load-frag' tool. Validates the .frag file path, loads the fragments using loadFragments, stores in global variable, and returns loaded stats.async ({ filePath }) => { if (!fs.existsSync(filePath) || filePath.endsWith('.ifc')) { return { content: [ { type: 'text', text: `No .frag file found. Please call convert-ifc-to-frag first: Input file path: ${filePath.replace( '.frag', '.ifc' )}; Output file path: ${filePath.replace('.ifc', '.frag')}`, }, ], } } fragments = await loadFragments(filePath) return { content: [ { type: 'text', text: `Loaded fragments from ${filePath}. Loaded ${fragments.getItemsWithGeometry().length} items with geometry: ${JSON.stringify( fetchCategoriesWithGeometry(fragments) )}`, }, ], } }
- main.ts:67-71 (schema)Zod input schema defining the filePath parameter for load-frag tool.{ filePath: z .string() .describe('Full path of the file to load with fragments'), },
- main.ts:64-100 (registration)Registers the load-frag tool on the MCP server including name, description, schema, and handler reference.server.tool( 'load-frag', 'Load a .frag file. Needs file-system server', { filePath: z .string() .describe('Full path of the file to load with fragments'), }, async ({ filePath }) => { if (!fs.existsSync(filePath) || filePath.endsWith('.ifc')) { return { content: [ { type: 'text', text: `No .frag file found. Please call convert-ifc-to-frag first: Input file path: ${filePath.replace( '.frag', '.ifc' )}; Output file path: ${filePath.replace('.ifc', '.frag')}`, }, ], } } fragments = await loadFragments(filePath) return { content: [ { type: 'text', text: `Loaded fragments from ${filePath}. Loaded ${fragments.getItemsWithGeometry().length} items with geometry: ${JSON.stringify( fetchCategoriesWithGeometry(fragments) )}`, }, ], } } )
- fragments.ts:24-29 (helper)Core helper that asynchronously reads the .frag file and initializes the SingleThreadedFragmentsModel.export const loadFragments = async (filePath: string) => { const file = await fs.promises.readFile(filePath) const fragments = new FRAGS.SingleThreadedFragmentsModel('model', file) return fragments }