BTWIN
Stores and queries building time-series observations and utility bills in SQLite databases (.db files), allowing an LLM to persist sensor readings and bills and then run analytical queries (e.g. detecting readings more than 3 sigma from the mean) on existing databases.
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.
BTWIN MCP
BTWIN (Building Twin Interface) is a Model Context Protocol (MCP) server that exposes a Python API for building digital twins to large language model (LLM) applications such as Claude, ChatGPT, OpenAI Codex, GitHub Copilot or local models. Through it, an LLM can create, query and analyse semantic building models based on the BOT, Brick, IFC-OWL, SOSA and EKO ontologies, link them to time-series observations and utility bills, compute energy KPIs, and serialise the results as JSON-LD, RDF/Turtle, SQLite databases and graph images.
The server follows the code-execution pattern for MCP: instead of one tool per API function, it exposes two tools, one to search the API and one to run Python scripts against it (see Architecture).
Installation
BTWIN is a local MCP server (stdio transport). It can be used with any MCP client that supports local servers, independently of the underlying LLM. Supported clients include:
Client | LLM provider | Registered automatically by the installer |
Anthropic | yes | |
Anthropic | yes | |
OpenAI | yes (shared Codex configuration) | |
OpenAI Codex (CLI, IDE extension) | OpenAI | yes |
VS Code (GitHub Copilot), Cursor, Gemini CLI, LM Studio, Cline, … | various, including local models | no, see Manual configuration |
The ChatGPT web and mobile apps only accept remote MCP servers reachable over HTTPS and therefore cannot start BTWIN directly; use the ChatGPT desktop app instead.
Requirements: one of the clients above and an internet connection. Python does not need to be installed beforehand: the installer provides it through uv.
Installation through an AI coding agent
In an agent that can run commands on your computer (e.g. Claude Code, OpenAI Codex, GitHub Copilot agent mode, Gemini CLI), enter:
Install the BTWIN MCP server from https://github.com/angelomassafra/btwin_mcp
The agent follows llms-install.md, runs the installer and registers
BTWIN in the clients found on the computer. After approving the proposed commands,
restart the client.
Windows installer
Click the green
<> Codebutton at the top of this page → Download ZIP.Open the downloaded ZIP and extract it (right-click → Extract All…).
Open the extracted folder, go into
install, and double-clickinstall-windows.bat.If Windows shows "Windows protected your PC", click More info → Run anyway.
Wait until you see "Done! BTWIN is installed." (the first time takes 1–3 minutes). The installer lists the clients in which BTWIN was registered.
Fully quit those clients (right-click their icon near the clock → Quit) and open them again.
irm https://raw.githubusercontent.com/angelomassafra/btwin_mcp/main/install/install-windows.ps1 | iexmacOS installer
Click
<> Code→ Download ZIP, then double-click the ZIP to extract it.Open the folder
installand double-clickinstall-macos.command.If macOS says it "cannot be opened": right-click the file → Open → Open.
Wait for "Done! BTWIN is installed.", then quit the listed clients (Cmd+Q) and reopen them.
curl -LsSf https://raw.githubusercontent.com/angelomassafra/btwin_mcp/main/install/install.sh | shVerification
The client should list a server named btwin with two tools (btwin_exec,
btwin_help): in Claude Desktop under the "+" / tools button, in Claude Code and
Codex with the /mcp command, in the ChatGPT desktop app under Settings → MCP servers.
Then ask:
Use BTWIN to check that everything works: build a small building with 2 floors and 3 rooms per floor, save it as
test.jsonand draw its graph astest.png.
Files created by BTWIN are saved in the Documents → BTWIN folder.
Related MCP server: Tacit MCP
What the installer does
The installer scripts are in install/. They:
install uv (Astral), which provides a suitable Python version and the dependencies in an isolated environment;
download BTWIN and its dependencies (pandas, networkx, rdflib, matplotlib, plotly, openpyxl);
register a
btwinserver in each client found on the computer:Claude Desktop:
claude_desktop_config.json;Claude Code:
claude mcp add --scope user;ChatGPT desktop and OpenAI Codex:
~/.codex/config.toml(or$CODEX_HOME/config.toml).
Existing settings are preserved and each modified file is first copied to a
.bakbackup.
Update: run the installer again. Uninstall: remove the btwin entry from the
client configuration (Claude Desktop: Settings → Developer → Edit Config; Claude Code:
claude mcp remove btwin; ChatGPT desktop / Codex: delete the [mcp_servers.btwin]
table from ~/.codex/config.toml).
Example prompts
"Create a site with one building, 3 storeys and 4 spaces per storey. Export it as JSON-LD and RDF Turtle."
"Add an air handling unit per floor that feeds every room on that floor, and a temperature sensor in each room."
"Here are 12 months of electricity readings in kWh: … Compute the EUI for a 500 m² building and store the readings in a SQLite database."
"Open
office_building/observations.dband find temperature readings more than 3 sigma from the mean.""Load
office_building/graph.json, find the shortest path from space-001 to space-004 and list the rooms fed by ahu-1."
The examples/ folder contains two synthetic datasets
(an office building with HVAC, sensors and two years of bills, and a home with water
bills) and further prompts. To use them, copy them into Documents/BTWIN.
Architecture

Exposing each of the ~100 API functions as a separate MCP tool would place several thousand tokens of tool definitions in the model's context. BTWIN instead follows the code execution with MCP pattern and exposes two tools:
Tool | What it does |
| Searches the BTWIN API by keyword (space, equipment, kpi, graph…) so the model only loads what it needs. |
| Runs a short Python script in which all BTWIN classes are pre-loaded. Intermediate objects stay inside the server; only the final |
This reduces the tool definitions from about 7,800 to about 480 tokens (−94%) and allows
multi-step modelling operations to be executed in a single call. The full API (90 functions + helpers) is documented in
docs/API.md.
Security note.
btwin_execruns Python code written by the LLM on your computer, with your user's permissions (like any local MCP server). Configure the client to ask for approval before each tool call (the default in Claude Desktop, ChatGPT and Codex): read the script if in doubt, and only work with files you trust.
Manual configuration
All clients start the server with the same command, which requires only uv:
uvx --from https://github.com/angelomassafra/btwin_mcp/archive/refs/heads/main.zip btwin-mcpIf a client cannot find uvx, use its full path (Windows:
C:\Users\<you>\.local\bin\uvx.exe, macOS/Linux: ~/.local/bin/uvx).
claude mcp add --scope user btwin -- uvx --from https://github.com/angelomassafra/btwin_mcp/archive/refs/heads/main.zip btwin-mcp
codex mcp add btwin -- uvx --from https://github.com/angelomassafra/btwin_mcp/archive/refs/heads/main.zip btwin-mcp[mcp_servers.btwin]
command = "uvx"
args = ["--from", "https://github.com/angelomassafra/btwin_mcp/archive/refs/heads/main.zip", "btwin-mcp"]
startup_timeout_sec = 120Add to the client's MCP configuration file (Claude Desktop: claude_desktop_config.json;
Cursor: ~/.cursor/mcp.json; Gemini CLI: ~/.gemini/settings.json; LM Studio: mcp.json):
{
"mcpServers": {
"btwin": {
"command": "uvx",
"args": ["--from", "https://github.com/angelomassafra/btwin_mcp/archive/refs/heads/main.zip", "btwin-mcp"]
}
}
}VS Code uses the same entry under a "servers" key in .vscode/mcp.json.
pip install "btwin-mcp @ https://github.com/angelomassafra/btwin_mcp/archive/refs/heads/main.zip"
btwin-mcp # starts the server on stdioor download btwin_mcp.py, pip install pandas openpyxl networkx rdflib matplotlib plotly
and configure the client to run python /absolute/path/to/btwin_mcp.py.
BTWIN requires an LLM with tool-calling support that can write short Python scripts. Small local models may need more attempts to produce correct scripts.
Settings
Environment variable | Default | Meaning |
|
| Folder where relative file paths are read and saved. |
Add it to the "env" block of the server entry, e.g. "env": {"BTWIN_WORKDIR": "D:\\Projects\\twin"}.
Troubleshooting
Problem | Solution |
BTWIN does not appear in the client | Make sure you fully quit the application (tray icon / Cmd+Q), not just closed the window, and that it was installed and opened at least once before running the installer. In Claude Desktop, Settings → Developer shows the server status and a link to the logs. |
"Server disconnected" right after starting | Run the installer again: it downloads everything in advance. Check your internet connection / proxy. |
Installer says the config is not valid JSON | The existing |
Windows blocks | Click More info → Run anyway, or use the PowerShell one-liner above. |
macOS blocks | Right-click → Open, or use the Terminal one-liner above. |
The model cannot find a file | Put it in Documents/BTWIN, or give the full path. |
| The |
Script times out | Ask the model to use a larger |
Still stuck? Open an issue and attach the log of the MCP client (Claude Desktop: Settings → Developer → btwin → Open Logs Folder).
For developers
git clone https://github.com/angelomassafra/btwin_mcp && cd btwin_mcp
uv run --with pytest pytest # end-to-end test over stdio
uv run python examples/generate_examples.py # regenerate the synthetic examplesThe whole server is a single file, btwin_mcp.py, with no MCP SDK
dependency (plain JSON-RPC over stdio, protocol 2024-11-05).
Version history
Version | Tools | Notes |
1.0.0 | 8 | SpatialElement only |
2.0.0 | 36 | Point, Observation, PropertySet, Property, Scenario, Schema, Serialization |
3.0.0 | 82 | Document, Equipment, KPISet/KPI, Graph, Plot — single file |
4.0.0 | 109 | Hierarchy, graph query, JSON-LD ops, batch, CSV, analytics, adjacency |
5.0.0 | 2 | Code-execution pattern — |
5.1.0 | 2 | Packaged for |
Citation
If you use BTWIN in research, please cite it (see CITATION.cff; GitHub
shows a "Cite this repository" button).
License
Copyright © 2025–2026 Angelo Massafra. Released under the GNU General Public License v3.0 or later.
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
AI-powered life cycle assessment and modelling: connect to LCA databases, build and analyze systems
Design buildings as IFC4 BIM models from a brief: an AI architect that plans, builds and edits.
Universal Document Intelligence: 70+ formats & 75+ languages to LPG/RDF entities & tables (13 tools)
Heating, ventilation and energy engineering calculations and diagnostics for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with OpenStudio building energy models through natural language, allowing users to load, inspect, and manipulate OSM files including building geometry, HVAC systems, materials, schedules, and internal loads.11MIT
- AlicenseAqualityDmaintenanceConnects AI assistants to Tacit building digital twins to query buildings, equipment, sensors, and zones using natural language. It provides tools for exploring Brick-compliant knowledge graphs, fetching historical sensor data, and accessing site documents.4MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to interact with the aedifion cloud platform for building performance optimization and IoT data management. It provides over 95 tools for monitoring timeseries data, managing project components, and executing building analytics or controls.100MIT
- FlicenseNot gradedqualityAmaintenanceEnables natural language interaction with OpenStudio building energy simulation, allowing creation, querying, and modification of models, running EnergyPlus simulations, and analyzing results.59-