BMW AI Bridge
by PolcioHubi
README.md
<div align="center">
<p align="right"><strong>English</strong> | <a href="README.pl.md">Polski</a></p>
# BMW AI Bridge (`bmw-ai-bridge`)
### Native AI MCP Server for BMW E-Sys, PSdZData, ISTA+ & EDIABAS (Tool32)
Connect **Claude Desktop, Cursor, Codex, Antigravity**, or any **Model Context Protocol (MCP)** client directly to your local BMW diagnostic, coding, and programming stack on Windows x64 — backed by **multi-layer fail-closed safety guards** and a **Zero-Write Web UI Cockpit**.
[](#requirements)
[](#requirements)
[](#architecture)
[](#architecture)
[](#feature-matrix)
[](#quick-setup-one-command)
[-6366F1?style=flat-square)](#zero-write-web-ui-cockpit)
[](LICENSE)
[Feature Matrix](#-feature-matrix) • [Architecture](#-architecture) • [Safety Model](#-how-safety-works) • [Quick Setup](#-quick-setup-one-command) • [Supported Vehicles](#-supported-vehicles--presets) • [Roadmap](#-roadmap--known-limitations)
</div>
---
> [!WARNING]
> **Pre-Live-Vehicle Testing Notice:**
> This project has passed extensive static analysis, red-team security audits, and automated tests (**73/73 passing**), **but has NOT yet been extensively tested on a live vehicle**. Live car testing is planned over the next few days.
>
> Diagnostics, offline lookups, and FDL/VO coding pipelines are designed to be solid, **but if anything crashes, fails to connect, or behaves unexpectedly, please [open a GitHub Issue](https://github.com/PolcioHubi/bmw-ai-bridge/issues) with logs — feedback and bug reports are very welcome!**
> [!NOTE]
> **Code Structure Note:**
> Two main files (`src/bmw_ai_bridge/server.py` and `workers/esys-java/EsysPsdzWorker.java`) are currently large/monolithic. This is temporary — once live vehicle testing confirms everything works reliably, they will be refactored into clean, modular folders.
---
## Feature Matrix
### E-Sys 25.10 & PSdZData 4.62.12 (BMW Coding, VO/FA, TAL & Programming MCP)
| Status | Capability | Details / MCP Tools |
| :---: |---|---|
| ✅ | **VCM Read (FA, SVT_ist, I-Step, VIN)** | Live read over ENET / ICOM + auto-discovery (`esys_read_vcm`, `vehicle_discover_enet`) |
| ✅ | **FA / VO Editing (Retrofits)** | Add/remove SALAPA options, HO-Wort, Zeitkriterium, offline FP decode (`esys_fa_edit`) |
| ✅ | **SVT_soll & TAL Calculation** | Full target topology & TAL calculation + XML inspection (`esys_svt_tal_calculate`) |
| ✅ | **CAFD Search & Un-Trimming** | 587 community **OpenCAFDMap** tables + **23 XML Cheat Sheets** (`esys_cafd_inspect_search`) |
| ✅ | **FDL Patching (Coding 1 / 2 / 3)** | Bitmask/symbolic `.ncd` patching, **CPS update**, **RT-3 fail-closed BTLD signing**, `SubCVN` (`esys_fdl_patch_ncd`) |
| ✅ | **Coding Plan, Diff & Live Coding** | Pre-write NCD/FA/SVT diff + dry-run plan hash + live execution (`esys_coding_plan_diff`, `esys_diff_compare`, `esys_coding_execute`) |
| ✅ | **TAL Execution (Flashing / Deployment)** | Filtered TAL execution with DME `0x12`/`0x13` guard & `>= 13.2 V` gate (`esys_tal_execute`) |
| ✅ | **Golden Backup & Restore Verification** | Full FA + SVT + live NCDs with SHA-256 manifest (`vehicle_snapshot_backup`, `vehicle_backups_manage`) |
| ✅ | **KIS / ODX Offline Explorer** | I-Step horizons, SWE dependency lookup, ODX inspection (`esys_kis_explorer`) |
| ✅ | **FSC / SWT & Secure Diagnostics** | SWT status, Service 29 auth, KDS check, Programming Token requests, SFA dictionary (`esys_fsc_swt`, `esys_secure_diagnostics`, `esys_ecu_advanced`) |
| ⏳ | **Live Vehicle Verification (Coding / Flash)** | Automated tests 73/73 passing; real-car validation scheduled next |
| ☐ | **Secure Coding 2.0 (NCD 2.0) Online Backend** | Requires official BMW backend token/signing service (not available offline) |
---
### ISTA+ 4.62.11 & EDIABAS 7.7.3 (BMW Diagnostics, Repair Manuals, Wiring & Tool32 MCP)
| Status | Capability | Details / MCP Tools |
| :---: |---|---|
| ✅ | **Offline ISTA+ SQLite Knowledge Base** | Instant 2-phase BM25 FTS5 search across `xmlvalueprimitive` & `streamdataprimitive` (`ista_search_documents`, `ista_get_document`) |
| ✅ | **DTC Fault Lookup & VIN Decoder** | Hex/decimal fault lookup + offline ISO 3779 BMW Group VIN decoding (`ista_fault_lookup`, `ista_vin_decode`) |
| ✅ | **Interactive SVG Wiring Diagrams (SSP)** | Search, extract, highlight components/pins, pan & zoom (`ista_wiring_diagram`, `ista_component_lookup`) |
| ✅ | **Tightening Torques & Fluid Specs** | Structured Nm / angle / bolt-replacement flags & Longlife oil/fluid specs (`ista_torques_and_specs`) |
| ✅ | **Vehicle Test, Test Plan & Measures Plan** | Automated ISTA+ `TestAutomation.exe` workflows + XML/JSON/HTML report parsing (`ista_vehicle_test`, `ista_calculate_test_plan`, `ista_measures_plan`, `ista_test_automation_workflow`) |
| ✅ | **ABL Service Functions (23,437 Modules)** | Search, inspect, and run ISTA+ ABL procedures (`ista_service_functions_list`, `ista_abl_session`) |
| ✅ | **Native EDIABAS 64-bit (`api64.dll`)** | Direct job execution over ENET, ICOM, and dedicated **D-CAN (`EdiabasLib`)** worker (`ediabas_run_job`, `ediabas_clear_faults`) |
| ✅ | **Tool32 BEST/2 Offline Inspector** | Inspect 1,433 `.prg` & 433 `.grp` files (jobs, arguments, results, tables) without a car (`ediabas_sgbd_catalog`, `ediabas_sgbd_inspect_deep`) |
| ✅ | **Live Telemetry & Health / Pre-Purchase Audit** | Multi-ECU live telemetry, full Vehicle Health Report, and Pre-Purchase Forensic Audit (`ediabas_live_telemetry`, `vehicle_health_report`, `vehicle_pre_purchase_audit`) |
| ✅ | **Zero-Write Web UI Cockpit (PL / EN)** | Local `127.0.0.1:8765` live dashboard, ECU matrix, SVG viewer & gauges (`bmw_ai_bridge.cli ui`) |
| ⏳ | **Live Vehicle Verification (ENET / D-CAN)** | Automated tests 73/73 passing; real-car validation scheduled next |
| ☐ | **Modular Folder Refactor** | Splitting monolithic `server.py` & `EsysPsdzWorker.java` right after live testing |
---
## Architecture
```mermaid
flowchart LR
AI["AI Client<br/>Claude / Cursor / Codex / Antigravity"] <-->|MCP stdio| MCP["bmw-ai-bridge MCP Server<br/>Python 3.11+ (40 Tools)"]
UI["Zero-Write Web UI Cockpit<br/>127.0.0.1:8765 (PL / EN)"] -.->|SSE Read-Only| MCP
subgraph Safety["Fail-Closed Safety Layer"]
SG["SafetyGate<br/>Voltage / RPM=0 / DME Lock<br/>Golden Backup / plan_hash"]
ARB["VehicleBusArbiter<br/>OS Mutex / External App Guard<br/>UNKNOWN Latch"]
end
MCP --> Safety
Safety --> JAVA["Java 11 PSdZ Worker<br/>E-Sys 25.10 + PSdZData 4.62"]
Safety --> DOTNET["C# .NET 4.8.1 x64 Worker<br/>ISTA+ 4.62 + EDIABAS 7.7.3<br/>WorkerSafetyGuard (HMAC-SHA256)"]
MCP --> KB["Offline SQLite KB<br/>ISTA+ FTS5 + OpenCAFDMap<br/>+ 23 XML Cheat Sheets"]
JAVA <-->|ENET / ICOM| CAR["BMW / MINI / RR Vehicle"]
DOTNET <-->|ENET / ICOM / D-CAN| CAR
```
---
## How Safety Works
Every vehicle-mutating operation passes through multiple independent **fail-closed** guards designed so nothing gets bricked:
| Layer | Protection Mechanism |
|---|---|
| **1. `SafetyGate` (Python)** | Enforces live battery voltage (`>= 12.2 V` coding/service, `>= 13.2 V` flash/security lifecycle), **engine off (`RPM == 0`)**, and **vehicle stationary (`0 km/h`)** from fresh measured telemetry. |
| **2. DME / DDE Lock (`0x12`/`0x13`)** | Engine ECUs are blocked from writes across coding, flashing, FSC, EDIABAS, and ABL unless explicitly overridden. |
| **3. Golden Backup SHA-256** | Requires a recent, verified Golden Backup matching the exact 17-character VIN before mutating operations. |
| **4. Two-Step `confirm_plan_hash`** | Every write tool defaults to `dry_run=True` and issues a single-use cryptographic `plan_hash` bound to the target VIN and artifact SHA-256 hashes (eliminates TOCTOU tampering). |
| **5. `VehicleBusArbiter`** | Cross-process OS mutex prevents E-Sys, ISTA+, EDIABAS, and UI from colliding on the bus; detects external BMW apps (`E-Sys.exe`, `ISTAGUI.exe`, `Tool32`); **never force-kills (`taskkill`) a live ECU write** — latches bus `UNKNOWN` instead. |
| **6. Native Worker Guards** | C# `WorkerSafetyGuard` verifies per-process **HMAC-SHA256** tokens + strict read-only allowlists; Java 11 enforces symmetric 17-char live VIN verification, XXE-safe XML, atomic writes, and **RT-3 fail-closed BTLD signing**. |
| **7. Zero-Write Web UI** | Local `127.0.0.1` dashboard has **zero write endpoints** and automatically yields the bus whenever AI starts an operation. |
---
## Supported Vehicles & Presets
- **Universal Multi-Series Support:** Covers **258 BMW, MINI, Rolls-Royce, and BMW Motorrad chassis codes** across all **23 PSdZ `mainseries` (E / F / G / U / I / NA / MINI / RR / Motorrad)**.
- **Universal Presets (All Series):** Includes **32 universal EDIABAS service procedures** (battery registration, IBS status, CBS, diesel DPF/SCR, ACSM EDR, etc.) and **9 universal telemetry presets** using official `.grp` auto-routing (`g_motor`, `d_motor`, `g_kombi`, `g_cas`, `g_dsc`, `g_egs`) so they automatically select the right ECU `.prg` for your car.
- **Model-Specific Example Presets:** Also includes an extended preset pack for **BMW X1 F48 / UKL2** (43 service procedures, 5 telemetry presets, 12 FDL coding presets) as a reference template.
---
## Requirements
| Component | Recommended / Tested Version |
|---|---|
| OS | Windows 10 / 11 (64-bit) |
| Python | 3.11+ (64-bit) |
| JDK (to compile Java worker) | JDK 11+ or 21 (e.g. Eclipse Temurin) |
| .NET SDK (to compile C# worker) | .NET SDK 8/9 + **.NET Framework 4.8.1 Developer Pack** |
| BMW E-Sys | **25.10** (local installation required) |
| BMW PSdZData | **4.62.12** (Lite for coding / Full for flashing) |
| BMW ISTA+ | **4.62.11** (with `SQLiteDBs` & `Testmodule`) |
| EDIABAS | **7.7.3** (included with ISTA+ or standalone) |
> **No proprietary BMW files are included in this repository.** You must have your own local installations of E-Sys, PSdZData, ISTA+, and EDIABAS.
---
## Quick Setup (One Command)
```powershell
git clone https://github.com/PolcioHubi/bmw-ai-bridge.git
cd bmw-ai-bridge
.\setup.ps1
```
`setup.ps1` automatically detects your BMW installations, creates `.venv`, compiles both native workers (`BmwIstaBridge.exe` + `EsysPsdzWorker.class`), generates `config/bridge.toml`, runs `bridge doctor`, and prints a ready-to-paste MCP JSON snippet for **Claude Desktop, Cursor, Antigravity, or Codex**.
### Useful CLI Commands
```powershell
# Environment diagnostics
.\.venv\Scripts\python.exe -X utf8 -m bmw_ai_bridge.cli doctor
# Run MCP server (stdio)
.\.venv\Scripts\python.exe -X utf8 -m bmw_ai_bridge.cli serve
# Launch Zero-Write Web UI Cockpit (http://127.0.0.1:8765)
.\.venv\Scripts\python.exe -X utf8 -m bmw_ai_bridge.cli ui
# Run full automated test suite (73 tests)
.\.venv\Scripts\pytest.exe -q
```
---
## Zero-Write Web UI Cockpit
Launch `bmw_ai_bridge.cli ui` and open `http://127.0.0.1:8765` for a 100% offline, **Zero-Write** companion workbench with a **PL / EN language switcher** in the top bar:
- **Overview:** Live AI activity stream, ECU topology matrix, and automatic AI context spotlight.
- **ISTA+ KB:** Instant offline DTC lookup, repair manuals with zoomable photos, and interactive SVG wiring diagrams.
- **Telemetry:** Live read-only gauges, dual real-time charts, 0–100 km/h timer, desk simulation mode, and CSV export.
- **E-Sys Offline:** SVT tree viewer, 23 searchable XML Cheat Sheets, OpenCAFDMap browser, Golden Backup viewer, and FSC/SFA dictionaries.
- **Safety:** Live `VehicleBusArbiter` lock monitor, `SafetyGate` limits, and security audit log.
---
## Roadmap & Known Limitations
- [ ] Complete live vehicle validation across ENET and D-CAN (diagnostics, Golden Backup, FDL coding, service functions).
- [ ] Refactor monolithic `server.py` and `EsysPsdzWorker.java` into clean modular subpackages once live testing is complete.
- [ ] Expand model-specific preset packs beyond universal `.grp` + F48.
---
## Community Data Credits & Attribution
This repository includes only open community coding metadata (no proprietary BMW binaries):
- **OpenCAFDMap** (`data/opencafdmap/`) — untrimmed CAFD mapping tables and FA/SA metadata from the open-source [OpenCAFDMap](https://github.com/d00m2k/OpenCAFDMap) project (see `data/opencafdmap/LICENSE`).
- **BMW E-Sys XML Cheat Sheets** (`data/cheatsheets/`) — community FDL cheat sheet XMLs authored by Almaretto and the BMW coding community (E-Sys Launcher / BimmerUtility / Bimmerpost contributors; individual author credits are preserved inside each XML file).
---
## License
This project is licensed under the **[PolyForm Noncommercial License 1.0.0](LICENSE)** (`PolyForm-Noncommercial-1.0.0`).
- You are free to use, study, fork, and modify this software for **personal, educational, and non-commercial purposes**.
- **Commercial use is not permitted** without explicit written permission from the author (e.g., paid workshops, commercial coding services, or selling derivative products).
- Bundled third-party community data under `data/opencafdmap/` remains subject to its own upstream license in `data/opencafdmap/LICENSE`.
---
## Disclaimer
This software is provided **"AS IS"**, without warranty of any kind. Vehicle diagnostics, FDL/VO coding, and ECU flashing carry inherent risk. Always use a stabilized battery power supply when coding or flashing, verify every dry-run plan before confirming, and use this tool strictly at your own risk.
<!-- Keywords: BMW MCP, ISTA MCP, ISTA+ MCP, E-Sys MCP, ESys MCP, EDIABAS MCP, Tool32 MCP, PSdZData MCP, BMW coding AI, BMW programming MCP, BMW diagnostics Model Context Protocol, FDL coding, VO coding, OpenCAFDMap -->
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues