iso26262-agent
by Abinash009
README.md
# 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
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues