Content
# iso26262-agent
**AI-powered ISO 26262 Functional Safety Agent for Automotive**
An MCP (Model Context Protocol) server that provides AI-assisted functional safety engineering tools for automotive ECU development. Generates HARA, FMEA, safety requirements, and compliance checks using RAG + LLM — grounded in ISO 26262 standards.
Built for engineers working on safety-critical systems: inverters, motor controllers, TCUs, ADAS, autonomous drive platforms, and battery management systems.
---
## 🎯 What It Does
| Tool | Input | Output |
|------|-------|--------|
| **HARA Generator** | System/function description | Hazard events + ASIL classification (A/B/C/D) |
| **FMEA Generator** | Component description | Full FMEA table (Failure Mode, S, O, D, RPN, Actions) |
| **Safety Requirements** | Function + ASIL level | ISO 26262-compliant FSR/TSR/SWSR requirements |
| **Compliance Checker** | Your existing requirements | Gap analysis vs ISO 26262 with clause references |
---
## 🏗️ Architecture
```
┌─────────────────────────────────────────────┐
│ MCP Client (IDE/CLI) │
└──────────────────┬──────────────────────────┘
│ MCP Protocol
┌──────────────────▼──────────────────────────┐
│ iso26262-agent (MCP Server) │
│ │
│ ┌─────────┐ ┌─────────┐ ┌──────────────┐ │
│ │ HARA │ │ FMEA │ │ Requirements │ │
│ │Generator│ │Generator│ │ Generator │ │
│ └────┬────┘ └────┬────┘ └──────┬───────┘ │
│ │ │ │ │
│ ┌────▼────────────▼─────────────▼────────┐ │
│ │ RAG Pipeline │ │
│ │ Query → Embed → Search → Context │ │
│ └────────────────┬───────────────────────┘ │
│ │ │
│ ┌────────────────▼───────────────────────┐ │
│ │ LLM (Gemini API) │ │
│ │ Context + Prompt → Structured Output │ │
│ └────────────────────────────────────────┘ │
└──────────────────────────────────────────────┘
│
┌──────────────────▼──────────────────────────┐
│ Knowledge Base (194 chunks) │
│ │
│ • ISO 26262 Parts 1-12 concepts │
│ • ASIL determination tables (S/E/C → ASIL) │
│ • Automotive failure mode patterns │
│ • Safety requirement templates │
│ • HARA methodology & examples │
└──────────────────────────────────────────────┘
```
---
## 🛠️ Tech Stack
- **Python 3.11+**
- **MCP Protocol** — Model Context Protocol server (standardized AI tool interface)
- **Gemini API** — LLM for reasoning and generation
- **RAG Pipeline** — Semantic embeddings + vector search (with TF-IDF fallback)
- **Pydantic** — Structured data models and validation
- **Rich** — Formatted CLI output
---
## 🚀 Quick Start
### 1. Clone & Install
```bash
git clone https://github.com/Abinash009/iso26262-agent.git
cd iso26262-agent
pip install -r requirements.txt
```
### 2. Set API Key
```bash
export GOOGLE_API_KEY=your_gemini_api_key_here
```
Or create a `.env` file:
```
GOOGLE_API_KEY=your_key_here
```
### 3. Run Demo
```bash
python3 demo.py
```
This runs all 3 tools with example automotive inputs and shows formatted output.
### 4. Run as MCP Server
```bash
python3 src/server.py
```
---
## 📋 Usage Examples
### HARA Generator
```
Input: "Torque control function in traction inverter for electric truck"
Output:
┌──────────────────────────────────────────────────────────────┬──────┐
│ Hazard │ ASIL │
├──────────────────────────────────────────────────────────────┼──────┤
│ Unintended forward over-torque while vehicle is stationary │ D │
│ Unintended excessive negative torque (regen braking) │ C │
│ Sudden total loss of drive torque during overtaking │ B │
│ Unintended reverse torque while forward gear engaged │ D │
│ Unintended forward motion when reverse gear engaged │ A │
└──────────────────────────────────────────────────────────────┴──────┘
```
### FMEA Generator
```
Input: "DC-DC converter 800V to 12V for auxiliary systems"
Output:
┌───────────────────────────────────────┬───┬───┬───┬─────┬──────────────────────────┐
│ Failure Mode │ S │ O │ D │ RPN │ Recommended Action │
├───────────────────────────────────────┼───┼───┼───┼─────┼──────────────────────────┤
│ HV to LV Isolation Breakdown │10 │ 2 │ 4 │ 80 │ Reinforced galvanic iso │
│ Loss of Output (Zero Voltage) │ 9 │ 4 │ 3 │ 108 │ Dual 12V output paths │
│ Uncontrolled Output Overvoltage │ 8 │ 3 │ 2 │ 48 │ Redundant OV protection │
│ Shoot-Through (High/Low Side) │ 8 │ 3 │ 2 │ 48 │ HW-enforced dead-time │
│ Excessive Junction Temperature │ 6 │ 4 │ 2 │ 48 │ Dual NTC sensors │
└───────────────────────────────────────┴───┴───┴───┴─────┴──────────────────────────┘
```
### Safety Requirements Generator
```
Input: function="Emergency braking torque delivery", ASIL=D
Output:
[FSR-001] [FSR] The system shall prevent unintended emergency braking torque delivery
[FSR-002] [FSR] The system shall deliver requested torque within specified time
[FSR-003] [FSR] The system shall maintain symmetrical braking torque delivery
[TSR-001] [TSR] Dual-channel cross-validation of torque demand signals
[TSR-002] [TSR] Dual independent power supply for hydraulic actuation
[TSR-003] [TSR] Redundant pressure sensors for left/right monitoring
```
---
## 📁 Project Structure
```
iso26262-agent/
├── README.md # This file
├── demo.py # Quick demo script (run this!)
├── requirements.txt # Python dependencies
├── src/
│ ├── __init__.py # Package initialization
│ ├── server.py # MCP protocol server + CLI
│ ├── tools.py # 4 safety tools + SafetyAgent class
│ ├── rag.py # RAG pipeline (embeddings + search)
│ └── models.py # Pydantic data models
├── knowledge_base/
│ ├── asil_determination.md # ASIL classification tables
│ ├── failure_modes_automotive.md # ECU failure mode patterns
│ ├── hara_methodology.md # HARA process & examples
│ ├── iso26262_overview.md # ISO 26262 Parts 1-12 summary
│ └── safety_requirements_patterns.md # Requirement templates
├── tests/
│ └── test_tools.py # Unit tests
└── docs/
```
---
## 🔑 Key Design Decisions
| Decision | Rationale |
|----------|-----------|
| MCP Protocol | Standardized AI tool interface — works with any MCP client |
| RAG over fine-tuning | Updatable knowledge base, no retraining needed, source traceability |
| TF-IDF fallback | Works without API key for demos and testing |
| Pydantic models | Type-safe, validated, serializable structured output |
| Automotive-specific KB | Not generic FMEA — tailored to ECU failure patterns |
| Separated concerns | RAG, Tools, Models, Server — each independently testable |
---
## 🎯 Supported Automotive Domains
- **Power Electronics** — Inverters, DC-DC converters, motor controllers
- **Connectivity** — TCU, V2X, telematics
- **ADAS / Autonomous Drive** — Camera, radar, sensor fusion, path planning
- **Battery Management** — BMS, cell balancing, thermal management
- **Braking / Steering** — Brake-by-wire, EPS, stability control
- **Body Electronics** — Lighting, door control, climate
---
## ⚠️ Disclaimer
This tool **assists** engineers in safety analysis — it does **not replace** human judgement for safety-critical decisions. All outputs should be reviewed by qualified functional safety engineers before use in production.
---
## 👤 Author
**Abinash Kumar** — AI & Automotive Connectivity Engineer
- LinkedIn: [abinash-kumar-26261657](https://www.linkedin.com/in/abinash-kumar-26261657/)
- GitHub: [Abinash009](https://github.com/Abinash009)
### Related Projects
- [sync-spec-agent](https://github.com/Abinash009/sync-spec-agent) — RAG + MCP agent for telecom standards
- [tcu-test-agent](https://github.com/Abinash009/tcu-test-agent) — Automotive ECU test automation (Robot Framework)
---
## 📄 License
MIT License
Connection Info
You Might Also Like
No recommendations available