ekkodale/IFC-MCP
If you are the rightful owner of IFC-MCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The IFC-MCP Service is a toolkit designed to facilitate the extraction and aggregation of data from IFC models used in Building Information Modeling (BIM).
Introduction
The IFC-MCP Service is a toolkit for extracting and aggregating data from Industry Foundation Classes (IFC) models used in Building Information Modeling (BIM). It provides an MCP with tools that can be used by an LLM. It enables users to access, filter, and analyze building elements and their properties in a structured way. This service is designed to support developers and analysts working with BIM data, making it easier to perform data-driven tasks on complex building models.
Architects and other building professionals often need to retrieve specific information from construction plans to support their work. For example, an architect may want to know how many windows, doors, chimneys, or ramps a building has; a glass cleaning company might need details about the largest window to select the right equipment; construction workers may be interested in the number of walls above a certain height to determine which ladders to bring; and painters require the total wall area to estimate the amount of paint needed. Currently, this kind of information can only be obtained by manually analyzing complex and non-human-readable IFC files or by using a combination of IFC viewer tools, which often do not provide all the desired data in one place. This makes the process time-consuming and inefficient for experts in the building industry.
The proposed solution is to implement an MCP that integrates seamlessly with a large language model (LLM) and is accessible to users through OpenWebUI. This approach allows users to ask any question about the building site in natural language, without needing technical expertise or familiarity with specialized tools. The system provides easy access and delivers answers to a wide range of queries, automatically handling the information retrieval and presenting results in a clear, human-readable format.
At this point, queries can include questions about the overall building inventory, quantities of specific entity types, filtering based on properties, and aggregations such as total sums or maximal and minimal values of properties.
Getting Started
To get started with the IFC-MCP Service, follow these steps:
Software Dependencies
Ensure you have the following installed:
- Node.js (v16 or higher)
- npm (v7 or higher)
- Docker (optional, for containerized deployment)
- Local development: pip & uvicorn
Running the Project Locally
-
Ensure you run a virtual environment for Python
- VS code:
- Create virtual environment:
python -m venv .venv - Activate virtual environment
.venv\Scripts\acitvate(on Windows)
- Create virtual environment:
- VS code:
-
Install dependencies:
pip install -r requirements.txt -
Run:
python .\app\main.py -
Update requirements.txt
pip freeze > requirements.txt
Running with Python Debugger in VS Code
Add the following configuration to the launch.json file in .vscode:
{
"name": "Python: Run FastMCP",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/app/main.py",
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}/app"
}
}
Use VS Code Copilot as Client
Create a mcp.json file in the .vscode folder. And add the following content:
{
"servers": {
"ifc-mcp": {
"url": "http://0.0.0.0:8000/mcp/"
}
}
}
Run the server with the Python debugger or
fastmcp run app/main.py:mcp
Start the MCP by selecting Agent mode in VS Code Copilot and make sure to select the ifc-mcp tool by clicking the Tools-Icon.
MCP Tools
-
get_entity_types
Retrieves all entity types present in an IFC file, allowing users to see what kinds of elements are available for analysis. -
get_entities
Retrieves entities of a specific type from an IFC file, with optional filtering by attributes, enabling targeted queries for elements like walls, slabs, or furniture. -
get_entity_info
Provides detailed information about a specific entity in an IFC file, supporting both basic and recursive data extraction for a given element. -
get_property_sets
Returns property sets or a subset of specified properties for a specific entity, helping users access detailed property data for individual elements. -
get_property_names
Lists the property names available for a specific entity type, making it easier to understand what data can be queried or filtered. -
get_entities_with_properties
Retrieves entities of a specific type, optionally filtered by attributes and properties, and includes specified property data and statistics for advanced analysis. -
analyze_building_inventory
Generates a comprehensive inventory of all building elements in the IFC file, providing counts and basic statistics for each entity type to support
Testing
Test Data
Retrieve test data from: buildingSMART: Sample-Test-Files
Unit Testing
- run in Service directory in virtual environment.
pytest .\tests\
-s: disables this output capturing, allowing you to see print statements and other output directly in the console during the test run.-v: increases the verbosity of pytest's output, providing more detailed information about each test, including the names of the tests and their outcome
Test Case Builder
To verify the results of the MCP, you can compute any results of a given IFC file and given instructions by:
- Add an IFC file to the
ifcsfolder - Add an instruction to
instructions.json - Run the script by:
- Ensuring PYTHONPATH=/app:
$env:PYTHONPATH="{path_to_project}\IfcMCP\app" python .\tests\build_test_cases.pyor- using Python debugger by adding the configuration
- Ensuring PYTHONPATH=/app:
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/tests/build_test_cases.py",
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}/app"
}
},