Skip to main content
Glama
helenkwok

Fragment MCP Server

load-frag

Load a .frag file to access Building Information Modeling data converted from IFC files, enabling BIM data querying by category.

Instructions

Load a .frag file. Needs file-system server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesFull path of the file to load with fragments

Implementation Reference

  • main.ts:72-99 (handler)
    The handler function for the 'load-frag' tool. It checks if the file exists and is a .frag file, loads the fragments using the loadFragments helper, and returns a success message with geometry info.
    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)
    Input schema for the 'load-frag' tool defining the filePath parameter.
    {
      filePath: z
        .string()
        .describe('Full path of the file to load with fragments'),
    },
  • main.ts:64-100 (registration)
    Registration of the 'load-frag' tool using server.tool, including description, schema, and handler.
    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)
              )}`,
            },
          ],
        }
      }
    )
  • Helper function loadFragments that reads the .frag file and creates a SingleThreadedFragmentsModel instance.
    export const loadFragments = async (filePath: string) => {
      const file = await fs.promises.readFile(filePath)
    
      const fragments = new FRAGS.SingleThreadedFragmentsModel('model', file)
      return fragments
    }

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/helenkwok/openbim-mcp'

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