ifc-sql-mcp
Loads IFC files exported from Autodesk Revit into a normalized database, enabling LLM/MCP access to building model data.
Stores normalized IFC/Revit data in PostgreSQL and exposes it through MCP tools for querying.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
ifc-sql-mcp
A data pipeline that loads building models exported from Autodesk Revit as IFC files into
a normalised PostgreSQL database, checks their data quality against a catalogue of
rules, and lets an LLM query them through an MCP
server, read-only. ifc-sql view shows the models in 3D in your browser.
See the demo, nothing to install, on a phone too: nine questions answered through the MCP server, with no LLM, and recorded. Pick one, and its answer lights up in the four Duplex models.

Question 3 of the demo, "Which walls are external, by type?", picked after questions 1
and 2: a run_sql query, and its 23 walls lit by type. The static copy written by
ifc-sql demo --export on the database scripts/demo.py loads, at commit caa7005, in
Microsoft Edge 158 on Windows 11, 2026-11-24.
flowchart LR
ifc["IFC file<br/>exported by Revit"] --> extract["extract<br/>IfcOpenShell"]
extract --> transform["transform<br/>pure: records and issues"]
transform --> load["load<br/>one transaction, COPY"]
load --> db[("PostgreSQL 16<br/>schema ifc")]
db <--> dq["ifc-sql dq<br/>45 rules, recorded runs"]
db --> mcp["ifc-sql serve<br/>MCP over stdio, read-only role"]
mcp --> llm["MCP client<br/>Claude Desktop, Claude Code"]
db --> view["ifc-sql view<br/>3D on 127.0.0.1, read-only role"]
view --> page["the page in your browser<br/>three.js, vendored"]Revit's IFC exports are valid but awkward: one building comes in three unit systems, names pack family, type and element id into one string, quantities hide in parameters, and unset values are placeholders that look like data. This project stores all of it faithfully, says where it had to make a choice, measures the defects, and gives an LLM tools that are correct by construction for the common questions and a guarded SQL interface for the rest.
Quick start
Requires uv, and Docker or nothing more: for one user,
ifc-sql can run PostgreSQL 16 itself in a folder (IFC_SQL_DATA_DIR, below). On
Windows, without make, follow docs/windows.md. Before exporting from Revit, read
docs/revit-export-settings.md: which options the tool
reads, and what it does without them.
make install # .venv from uv.lock, plus the pre-commit hooks
make up # PostgreSQL 16 in Docker, bound to 127.0.0.1
make dq-samples # download the four sample files, migrate, load and check them
make smoke # start the MCP server as a client would and call a few tools
make view # look at the four models in 3D in your browser (Ctrl+C stops it)
make demo # nine questions through the MCP server, no LLM, each lit in the browserWithout Docker, for one user, skip make up: with IFC_SQL_DATA_DIR set, the commands
start an embedded PostgreSQL 16 in that folder themselves, and stop it when the last one
exits (ADR 13; it takes no passwords, so read
SECURITY.md first).
export IFC_SQL_DATA_DIR=~/.local/share/ifc-sql
make install dq-samples smoke viewmake dq-samples downloads the buildingSMART Duplex Apartment models (CC BY 4.0,
checksum-verified, not stored in this repository), then loads and checks them. It loads
them with ingest --viewer, which also builds each model's 3D scene for the viewer
(ADR 14). On an empty database:
loaded Duplex_A_20110907.ifc as model 1 (ARC): 295 objects, 13,545 property values, 0 issues (run 1); scene built: 218 elements drawn, 0 without shape, 50 openings not drawn, 7 chunks, 0.5 MB
loaded Duplex_MEP_20110907.ifc as model 2 (MEP): 973 objects, 63,683 property values, 46 issues (run 2); scene built: 926 elements drawn, 0 without shape, 0 openings not drawn, 9 chunks, 4.7 MB
loaded Duplex_Electrical_20121207.ifc as model 3 (ELE): 109 objects, 6,862 property values, 88 issues (run 3); scene built: 103 elements drawn, 0 without shape, 0 openings not drawn, 4 chunks, 0.4 MB
loaded Duplex_Plumbing_20121113.ifc as model 4 (PLU): 504 objects, 41,649 property values, 550 issues (run 4); scene built: 498 elements drawn, 0 without shape, 0 openings not drawn, 4 chunks, 4.7 MB
checked model 1 (ARC, Duplex_A_20110907.ifc) in dq run 1: 0 error, 7,651 warning, 551 info findings (model content 0 / 7,651 / 551, loader coverage 0 / 0 / 0)
checked model 2 (MEP, Duplex_MEP_20110907.ifc) in dq run 2: 0 error, 30,035 warning, 1,961 info findings (model content 0 / 30,035 / 1,961, loader coverage 0 / 0 / 0)
checked model 3 (ELE, Duplex_Electrical_20121207.ifc) in dq run 3: 0 error, 90 warning, 3,291 info findings (model content 0 / 90 / 3,291, loader coverage 0 / 0 / 0)
checked model 4 (PLU, Duplex_Plumbing_20121113.ifc) in dq run 4: 0 error, 1,472 warning, 13,223 info findings (model content 0 / 1,472 / 13,223, loader coverage 0 / 0 / 0)A scene's three counts add up to the model's elements: the Duplex ARC model's 268 are 218
drawn (two stairs and a roof among them, drawn through their parts), none without a shape,
and 50 openings, which IfcOpenShell cuts out of their walls. The bytes may differ a little
on another platform. Running it again loads nothing more: each file is identified by its
SHA-256, a repeat is recorded as a skipped run, and a scene that is current is kept (the
check runs again, as a new recorded run).
make smoke then talks to the server over stdio:
connected to ifc-sql-mcp 0.1.0 over stdio (protocol 2026-07-28): 11 tools, 1 resource, 1 resource template, 1 prompt
list_models: 4 models
model 1 ARC Duplex_A_20110907.ifc: elements 268, spaces 21; dq run 1: 0 error, 7,651 warning, 551 info
model 2 MEP Duplex_MEP_20110907.ifc: elements 926, spaces 42; dq run 2: 0 error, 30,035 warning, 1,961 info
…make view (uv run ifc-sql view) then shows the four disciplines together in your
browser, storey by storey, with an element's properties on a click, and lights up what
each call of Claude found (docs/viewer.md). It listens on 127.0.0.1
only, and the address it prints carries a token, new on every start, that the page needs:

uv run ifc-sql view with four calls made through ifc-sql serve with the feed on, by a
script in Claude's place; the newest, a run_sql query of the doors by type, lit, and
how it was answered. At commit caa7005, in Microsoft Edge 158 on Windows 11,
2026-11-24.
make demo (uv run python scripts/demo.py) loads the Duplex, checks it, and asks nine
questions through the MCP server with no LLM, lighting each answer in the page
(docs/viewer.md). make demo-audit (scripts/demo.py --script audit) does the same with four questions on the audit's Revit exports, which
stay local. make demo-export writes the Duplex demo as the static copy that GitHub Pages
publishes (docs/viewer.md). With IFC_SQL_VIEWER_FEED=1, the server your own client starts does the same
for every call, and the page shows the calls of every client on the database
(docs/mcp.md).
To give Claude Code the server (the full instructions, also for Claude Desktop, are in docs/mcp.md):
claude mcp add --env IFC_SQL_DATABASE_URL=postgresql+psycopg://localhost:5432/ifc \
--env IFC_SQL_READER_PASSWORD=ifc-reader-dev-only \
--transport stdio ifc-sql -- /path/to/uv run --directory /path/to/Ifc_Sql_Mcp ifc-sql serveThe passwords in this repository are public development defaults, safe only because
PostgreSQL listens on loopback. Anywhere else, set your own (.env.example,
SECURITY.md).
After pulling a new version, run ifc-sql migrate (make migrate): ifc-sql serve
refuses a database at an older revision and says so. Migration 0020 adds the viewer's
schema, ifc_viewer; a model loaded before it gets its scene from
ifc-sql ingest <file> --discipline … --viewer, which builds it in place.
Related MCP server: Horizun Revit MCP
What the sample files show
File | Discipline | Unit declared | Elements | Spaces | Property values | Transform issues | Findings (warning / info) |
| ARC | m | 268 | 21 | 13,545 | 0 | 7,651 / 551 |
| MEP | m | 926 | 42 | 63,683 | 46 | 30,035 / 1,961 |
| ELE | ft | 103 | 1 | 6,862 | 88 | 90 / 3,291 |
| PLU | mm | 498 | 1 | 41,649 | 550 | 1,472 / 13,223 |
No errors. The rules keep the error severity for something in the file that did not reach the database, such as a skipped object; none of the 58,274 findings is one, and none is a gap in the loader's coverage.
Units are normalised. The four files declare metres, feet and millimetres; every length, area and volume is stored in m, m² and m³, and Level 2 sits at 3.100 m in all four (data-model.md).
Placeholders dominate the findings. Revit 2011 fills unset text parameters with their own name (
BarCode = 'BarCode'): 29,967 of MEP's 31,975 findings. Revit 2013 writes'N/A'instead.Material totals are not element totals. By element, the architectural model's area is 1,505.0 m²; by material it is 4,797.5 m², because a layered material covers the element's face once per layer. Plasterboard alone comes to 931.9 m², more than the 587.7 m² of all the walls. The takeoff tool says which kind of total it reports.
The figures come from the commands above, and make test-samples pins them, so the
documentation cannot drift from the code.
How it is built
Each part has a design record in docs/adr/ with the alternatives that were rejected.
Store (ADR 1): PostgreSQL 16 through SQLAlchemy Core, psycopg 3 and Alembic. The database enforces the model: keys, foreign keys with cascades, CHECK constraints on formats and ranges (no blank identifiers, no NaN), and references checked at commit. Pending migrations run in one transaction, and tests compare the migrated database with
schema.pyand check every CHECK by name.Data model (ADR 2, data-model.md): 14 tables and 8 views in schema
ifc, every one commented. Oneobjectsupertable for spatial elements and physical elements, so properties, quantities, classifications and findings all have real foreign keys. Property values are a typed entity-attribute-value table; quantities have a fixed vocabulary with their source and a precedence (ADR 3); materials keep their layer order and thickness.Ingest (ADR 4): extract is the only module that touches IfcOpenShell; transform is pure and returns records that already satisfy every constraint; load writes one model in one transaction (COPY for the bulk tables, chosen by measurement). Every attempt is recorded, including failed and skipped ones; a concurrent ingest of the same file loses cleanly on the unique constraint. What the transform could not represent is stored as an issue with a stable code (revit-ifc-quirks.md goes through every quirk).
Data quality (ADR 5, data-quality.md): 45 rules in one strictly loaded YAML catalogue, one per issue code plus sixteen SQL rules: placeholders, empty values, elements without a storey, quantities that disagree, and handover requirements (quantities, rooms, fire ratings, real materials, project information). Each rule's scope says whether a finding is the model's gap or the loader's. Each run is recorded and evaluated set-based, so quality can be compared over time; a removed rule is retired, not deleted, while findings cite it.
MCP server (ADR 6, ADR 9, docs/mcp.md): nine fixed tools (models, storeys, element search and detail, takeoffs, schedules, room schedule, data quality report, comparison of two exports) handle the common questions with tested SQL, and
run_sqlthe rest, withdescribe_schemaas its map and errors that name the tables and columns that exist. The server connects only as a read-only role, opens a new session per call, and bounds every result.run_sqlpasses four layers, each tested on its own against PostgreSQL: a sqlglot validator with a function allowlist, a cursor that PostgreSQL accepts only for one SELECT, a read-only transaction with timeouts, and the role's privileges.Viewer (ADR 14, docs/viewer.md):
ingest --viewertriangulates every element and space with IfcOpenShell and stores the scene as glTF chunks per storey in schemaifc_viewer.ifc-sql viewserves them on 127.0.0.1 to a page of plain ES modules with three.js, which draws each chunk as two BatchedMeshes: file B's 11,297 elements in 76 draw calls. The port answers only its own Host, every data route needs the start's token, and the page sets IFC text only as text. WithIFC_SQL_VIEWER_FEED=1,servepublishes each call as a PostgreSQL notification;viewchecks every one as untrusted, and lights what the call found with the tools' own SQL.ifc-sql demoplays nine questions on the Duplex through the real server, and CI checks each answer on Linux and Windows;--script auditplays four on the audit's exports, which themoderntests check.
Asking through MCP
The fixed tools answer most questions in one call. For the rest, run_sql takes one
read-only query, with describe_schema as its map. Which walls of
the architectural model are external, by type:
SELECT e.revit_type, count(*) AS walls, round(sum(e.area_m2)::numeric, 1) AS area_m2
FROM v_element AS e JOIN property AS p ON p.object_id = e.object_id
WHERE e.model_id = 1 AND e.ifc_class_base = 'IfcWall'
AND p.pset_name = 'Pset_WallCommon' AND p.prop_name = 'IsExternal' AND p.value_bool
GROUP BY e.revit_type ORDER BY area_m2 DESC[["Exterior - Brick on Block", 12, 272.0], ["Foundation - Concrete (417mm)", 4, 64.4],
["Party Wall - CMU Residential Unit Dimising Wall", 4, 61.9], ["Foundation - Concrete (435mm)", 3, 12.5]]Anything else is refused before it reaches the database, with a reason the LLM can act
on: DELETE FROM ifc.property gets query refused: only a query that reads data is allowed (SELECT, WITH … SELECT, TABLE, UNION, INTERSECT, EXCEPT or VALUES); this is a DELETE statement.
Quality
Tests: 1,650 unit and integration tests at 100 % branch coverage, plus 155 on the real files: the four Duplex models (
make test-samples) and the audit's five Revit 2019–2022 exports, whose acceptance tests pin every audit and re-check finding (make test-modern, docs/audit/). Integration tests run against real PostgreSQL in throwaway databases they create and migrate, never against the development database, and nothing in the safety layers is mocked. Races (two ingests of one file, two catalogue syncs at once) are staged with real blocked transactions.Checks: ruff (with the bandit rules and Google docstrings), mypy
--strict, and pytest with warnings as errors, run bymake checkand by CI on GitHub Actions with a PostgreSQL 16 service. A Windows job runs the Windows quick start on the embedded database on every push, and fetches a chunk of a scene fromifc-sql viewthere. ruff and mypy also run as pre-commit hooks.Reproducible: dependencies locked in
uv.lock, CI actions pinned to commit SHAs, sample files pinned to an upstream commit and verified by SHA-256.
Repository layout
src/ifc_sql_mcp/
cli.py ifc-sql: migrate, ingest, dq, watch, serve, view, demo
config.py settings from IFC_SQL_* environment variables
logging_config.py key=value logs on stderr (stdout is the MCP protocol)
watch.py ifc-sql watch: load and check each export saved to a folder
db/ schema.py, engines, embedded PostgreSQL, migrations 0001-0020, view SQL
ingest/ extract (IfcOpenShell), transform (pure), load, pipeline
viewer/ 3D scenes (ingest --viewer) and ifc-sql view: its app, its port's
checks, the feed of MCP calls and what they light, the scripted
demo and its static copy, and the page in static/, three.js and
Nunito vendored
dq/ rule catalogue, sync, runs
rules/dq_rules.yaml the 45 data quality rules
server/ MCP server: tools, run_sql, SQL validator, schema description
tests/
unit/ no database needed
integration/ real PostgreSQL, throwaway databases
samples/ the four Duplex files (pytest -m sample)
modern/ the audit's Revit 2019-2022 exports (pytest -m modern)
fixtures/ a synthetic Revit-style IFC file and the script that writes it
support/ helpers the suites share: sample files, an MCP client, builders
scripts/ sample downloads, the demo, quirks report, load benchmark, MCP and view smoke tests
docs/ data model, Revit quirks, data quality, MCP server, ADRs, auditDocumentation
Document | Covers |
The schema, its conventions, the views, loading, the read-only role, migrations | |
Each Revit export habit, how often it occurs in the samples, and what the pipeline does | |
The rule catalogue, severities, runs and the findings on the samples | |
Running the server, registering it with a client, every tool, resource and the prompt | |
| |
The Revit export options the tool reads, the habits that keep answers right, and | |
The quick start in PowerShell, without | |
Fourteen architecture decision records | |
Audit on Revit 2021 and 2022 exports (IFC4, IFC2X3): an architect's workflow, what works and what does not, and a prioritised backlog | |
The audit's workflow repeated on the fixed tool, and the four findings it made (R1–R4) | |
How the audit's backlog and the re-check's findings were implemented: per finding, the issue, the commits and the figures before and after | |
The threat model: LLM-written SQL, prompt injection through IFC content, credentials, the viewer's port, its feed and the static demo |
make help lists every target.
Limitations
Built and tested against Revit exports: 2011 and 2013 in IFC2X3 (the four Duplex files), and 2019, 2021 and 2022 in IFC2X3 and IFC4 (the audit's five files,
make test-modern). Files from other exporters are untested.Quantities come from the file: IFC base quantities first, then Revit's parameters and a door's or window's size (ADR 3, ADR 8). A value that breaks a physical bound of its set is flagged and not used (ADR 7). A file exported without quantities can be measured instead, with
ifc-sql ingest --geometry(ADR 10): about a minute for 15,000 objects on 4 cores, and only for walls, slabs, spaces and other solids. A file already loaded is measured into the same model (ADR 12).A changed file is a new model version.
--replacesmarks the current one, andcompare_modelslists what changed between two; versions are not merged, and old data quality runs are kept until deleted.The MCP server is for one local user: stdio only, no authentication.
ifc-sql viewlistens on 127.0.0.1 only, behind a token (SECURITY.md).The viewer's feed reaches every login to the database, which can also send to it; it is off unless
IFC_SQL_VIEWER_FEED=1(SECURITY.md).The demo on GitHub Pages is a recording: the visitor picks its scripted questions, and it asks nothing; Claude does not run there, and the page says so. It holds every element's class, name and storey but everything only of the one wall its questions look up. Only the Duplex is published (DATA_ATTRIBUTION.md).
Licences
Code: MIT. three.js r187, vendored in
src/ifc_sql_mcp/viewer/static/vendor/three/ for the viewer's page: MIT, its
licence beside it. The page's font,
Nunito, vendored in vendor/nunito/: SIL Open
Font License 1.1, its licence beside
it. Sample data: buildingSMART International, CC BY 4.0, used unmodified and downloaded on
demand; the page's one picture made from it, a still of the Duplex, is CC BY 4.0 too
(its licence); see
DATA_ATTRIBUTION.md.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Convert Revit files to XKT, IFC, or DWG and query BIM data via natural language.
Revit model integration via APS — elements, parameters, schedules, clashes, IFC export.
Read and edit the Revit 2024–2027 model on your PC. Needs the free Revit MCP add-in.
Hosted PostgreSQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to load, query, and analyze IFC building model files, including spatial structures, elements, properties, materials, and geometry.201MIT
- -licenseNot gradedqualityNot gradedmaintenanceConnects MCP clients like Claude, Codex, and Cursor to a running Autodesk Revit session for typed BIM queries, verified model edits, family authoring, exports, and Power BI workflows. It is open-source, Apache-2.0, and designed for reliable, verified outcomes.-
- AlicenseAqualityDmaintenanceAn MCP server that lets users query, validate, convert, and compare IFC/BIM files using natural language. Runs fully locally and integrates with AI agents like Claude.8MIT
- FlicenseNot gradedqualityCmaintenanceMCP server for processing electrical BIM data from DXF and JSON files, sanitizing and storing it in Supabase, and enabling AI-powered querying through a conversational assistant.-