Skip to main content
Glama

Majster-AI — 通过 MCP 的汽车 UDS 诊断代理

Python Protocol AI MCP UI Safety License

Car_Diagnostic_AI — 也被称为 CDAMajster-AI — 是一个诊断代理,它通过 UDS/CAN 将大语言模型连接到汽车的控制模块,连接到本地维修手册索引,以及实时网络搜索。这三种能力作为独立的 Model Context Protocol 服务器暴露,并由一个 LangGraph 代理编排,对任何写入车辆的操作都有严格的人机交互门控。

针对 Land Rover Freelander 2 (2010, 2.2 TD4) 进行开发和测试。

它附带一个 Cyber-HUD 网页界面:一个交互式 3D 底盘,其模块引脚位于真实车辆坐标上,实时遥测仪表,以及一个拖拽授权门控,用于任何写入车辆的操作。

Majster-AI Cyber-HUD

⚠️ 默认使用模拟器,并且为 READ_ONLY

全新的克隆无法在真实总线上传输,也无法写入车辆。两者都需要刻意更改配置。在连接到你关心的汽车之前,请阅读 docs/SAFETY.md


它实际做什么

you> The car goes into limp mode on the motorway. What's wrong with it?

  [agent.plan] Calling: read_dtc
  [car.read_dtc] Reading DTCs from ECM
  [agent.plan] Calling: read_live_data
  [agent.plan] Calling: search_manual

majster> Three codes stored in the ECM, and I think two of them are one fault:

  P0299 (confirmed) — turbocharger underboost
  P2015 (confirmed) — intake manifold runner position sensor
  P0401 (pending)   — EGR flow insufficient

  Live data backs up the underboost: manifold pressure reads 101 kPa at idle
  against 100 kPa barometric, so the turbo isn't building any boost at all.

  P0299 and P2015 together on a DW12 is a familiar pattern — both are air-path
  faults and the swirl-flap linkage sits right next to the actuator. The
  manual (fl2_engine.pdf, page 412) says actuator vacuum should reach 0.6 bar
  at idle; that's the measurement that would separate a seized actuator rod
  from a boost leak, and it's a five-minute check before anyone buys a turbo.

  The pending EGR code I'd leave alone for now — it hasn't confirmed, and a
  fouled EGR is a plausible consequence of running underboost rather than a
  separate fault.

注意它没有做什么:猜测,并主动提出清除故障码。


Related MCP server: Codex MCP Server

架构

        +--------------------------------------------------+
        |   Cyber-HUD  (React · Three.js · Framer Motion)   |
        +---------------------------+----------------------+
                                    | WS /ws/diagnostics
        +---------------------------+----------------------+
        |         FastAPI  (telemetry · agent · HITL)       |
        +---------------------------+----------------------+
                                    |
                     +--------------+------------+
                     |     LangGraph agent       |
                     |  Claude Opus 5 / Ollama   |
                     +-------------+-------------+
                                   |
                 +-----------------+-----------------+
                 |                 |                 |
       +---------v------+ +--------v-------+ +-------v--------+
       | Car_Interface  | | RAG_Workshop   | |  Web_Search    |
       |      MCP       | |      MCP       | |      MCP       |
       +---------+------+ +--------+-------+ +-------+--------+
                 |                 |                 |
        UDS over CAN       local manuals      Tavily / DuckDuckGo
  • Car_Interface_MCPpython-can + udsoncan。从任何模块读取 DTC、实时数据和原始 DID;仅通过批准握手清除故障码。五个可互换的后端,外加一个内置的 ECU 模拟器。

  • RAG_Workshop_MCP — 基于你自己的维修手册 PDF 的 ChromaDB。完全在设备上运行;每个答案都带有文件和页码引用。

  • Web_Search_MCP — Tavily,带有无需密钥的 DuckDuckGo 后备,偏向于 Land Rover 论坛。

  • 编排器 — 默认 READ_ONLY;每次写入都会暂停图并等待人工。

完整细节见 docs/ARCHITECTURE.md


安装

git clone https://github.com/Mati83mon/Car_Diagnostic_Ai.git
cd Car_Diagnostic_Ai

python3 -m venv .venv
source .venv/bin/activate           # Windows: .venv\Scripts\activate

pip install -e ".[all,dev]"         # or: pip install -r requirements.txt

cp .env.example .env                # then edit it

在 Termux 或其他无法构建重型附加组件的 ARM 设备上,跳过它们——该项目设计为无需它们也能工作:

pip install -e ".[car,mcp,agent,web]"

检查是否正常工作

majster-ai doctor

也可作为 cdacar-diagnostic-ai 使用,或使用 python main.py <command>


配置

所有内容都位于 .env 中。默认值是安全的,因此空文件也是有效文件。最重要的设置:

# --- safety -----------------------------------------------------------
MAJSTER_WRITE_ENABLED=false      # master switch. Leave false.
MAJSTER_REQUIRE_APPROVAL=true    # human-in-the-loop. Leave true.

# --- vehicle interface -------------------------------------------------
MAJSTER_CAN_BACKEND=virtual      # virtual|socketcan|slcan|serial|j2534|rfcomm
MAJSTER_CAN_CHANNEL=can0
MAJSTER_CAN_BITRATE=500000

# --- LLM ----------------------------------------------------------------
ANTHROPIC_API_KEY=sk-ant-...     # Claude Opus 5; falls back to Ollama if unset
MAJSTER_OLLAMA_MODEL=qwen2.5:7b-instruct

# --- web search ---------------------------------------------------------
TAVILY_API_KEY=tvly-...          # optional; DuckDuckGo is used without it

每个选项的注释见 .env.example


使用

交互式

majster-ai chat

一次性

majster-ai ask "why is the DPF light on?"

直接工具,无 LLM

majster-ai dtc --module ECM              # read fault codes
majster-ai dtc --all                     # scan every module
majster-ai live RPM COOLANT_TEMP MAF     # read live data
majster-ai scan                          # discover which ECUs answer
majster-ai clear --module ECM            # write: prompts for approval

维修手册

cp ~/manuals/*.pdf data/manuals/
majster-ai ingest
majster-ai search "swirl flap removal procedure"

手册在本地索引和搜索。不会上传任何内容。

网页界面

cd frontend && npm install && npm run build   # once
majster-ai web                                # http://127.0.0.1:8000

对于前端开发,请同时运行 Vite 开发服务器:

majster-ai web            # terminal 1 — API on :8000
cd frontend && npm run dev  # terminal 2 — UI on :5173, proxying to :8000

UI 流式显示实时遥测,在 3D 底盘上显示模块健康状况,并在任何写入之前暂停等待拖拽授权手势。点击故障码会将相机飞到其指向的组件——例如 C0034 这样的底盘码会飞到右前轮传感器,而不是发动机舱中的 ABS 模块。

majster-ai web 默认绑定到 127.0.0.1。任何能访问该端口的设备都可以要求代理提议写入;批准门控仍然有效,但提示将由那里的任何人回答。只在你控制的网络上使用 --host 0.0.0.0

作为另一个客户端的 MCP 服务器

majster-ai serve car_interface           # stdio transport

用于 Claude Desktop 等客户端的配置见 docs/ARCHITECTURE.md


安全模型

模型与车辆之间有四个独立的层。写入必须通过所有层。

保证

1. 主开关

默认 MAJSTER_WRITE_ENABLED=false。写入被直接拒绝,不发放令牌,不显示提示。代理无法更改此设置。

2. 令牌握手

第一次调用总是失败,并返回影响摘要和一个一次性令牌,该令牌绑定到确切参数的哈希,并在五分钟后过期。对 ECM 的批准不能清除 ABS 模块。

3. 人工暂停

图通过 interrupt() 挂起。拒绝、空回答、关闭的 stdin、崩溃的 UI、非交互式会话——都意味着

4. 系统提示

告诉模型其他三层将做什么。被视为最弱的层,因为它确实如此。

浏览器只是另一个批准者。滑块发送一个布尔值;确认令牌在服务器进程内创建和兑换,永远不会出现在任何 WebSocket 帧中。客户端可以回答服务器选择提出的问题——它永远不能提出问题,也永远不能铸造执行写入的凭据。

Approval gate

第 2 层位于 MCP 服务器后面的服务中,因此即使不是此代理在驱动,它也能保护汽车。

========================================================================
  WRITE OPERATION - HUMAN APPROVAL REQUIRED
========================================================================
  Operation : clear_dtc
  Module    : ECM (Engine Control Module - 2.2 TD4)
  Scope     : ALL stored DTCs in this module
  Risk      : MEDIUM        Reversible: NO
  Will erase 3 code(s):
      - P0299-00     Turbocharger/Supercharger A Underboost Condition
      - P2015-00     Intake Manifold Runner Position Sensor/Switch Circuit
      - P0401-00     Exhaust Gas Recirculation Flow Insufficient Detected

  Consequences:
      ! Freeze-frame data captured when the fault occurred will be lost.
      ! Readiness monitors reset; the vehicle may fail an emissions test.
      ! Clearing does not repair anything. If the fault is still present
        the code will return.
========================================================================

  Type 'yes' to authorise, anything else to decline:

完整细节见 docs/SAFETY.md


硬件

后端

接口

平台

virtual

无——内置模拟器

任意平台

j2534

Tactrix Openport 2.0

Linux、Windows

socketcan

USB2CAN、CANable、PiCAN

Linux

slcan

CANable/CANtact(slcan 固件)

Linux、macOS、Windows

rfcomm

通过蓝牙的 ELM327 / OBDLink

Linux、Termux

Freelander 2 使用 ISO 15765-4 CAN,500 kbit/s,11 位标识符,位于 OBD-II 引脚 6(CAN-H)和 14(CAN-L)上。

每种硬件的设置,以及 Termux、Raspberry Pi 和哪些 ELM327 适配器实际可用:见 docs/HARDWARE.md


关于本仓库中的数据

任何汽车上只有两个诊断地址是立法规定的,因此是确定的:动力总成地址 0x7E0/0x7E80x7E1/0x7E9。内置模块映射中的其他所有内容都来自社区,并标记为 verified: false

实时数据缩放也是如此:SAE J1979 PID 是标准的,并标记为已验证;制造商 DID 是专有的,完全没有提供,因为一个自信的错误数字是诊断工具最糟糕的输出。

要找出你的汽车的实际情况:

majster-ai scan

然后在 data/modules.json 中记录响应的内容。见 docs/FREELANDER2.md


开发

make install-dev
make check                # black --check, flake8, pytest
make test-cov             # coverage report

整个测试套件针对进程内 ECU 模拟器运行——无需硬件、无需 API 密钥、无需网络:

736 passed, 1 skipped

模拟器是真正的 UDS 实现,而不是模拟,因此重试逻辑、DTC 编解码器、MCP 工具和 HITL 门控都针对它们在真实总线上会看到的相同字节流运行。故障注入使不稳定的总线路径变得确定性:

ecm.inject_faults(drop_next=2)      # two silent timeouts, then fine
ecm.inject_faults(pending_next=3)   # three NRC 0x78, then the answer
ecm.inject_faults(busy_next=1)      # one NRC 0x21 busyRepeatRequest

CI 运行 lint、在 Python 3.10/3.11/3.12 上的测试套件、作为独立任务的安全不变量,以及一个将 MCP 服务器作为真实子进程启动的集成任务。


项目布局

majster_ai/
├── agent/              LangGraph orchestrator, HITL, LLM providers
├── mcp_servers/
│   ├── car_interface/  UDS/CAN — the safety gate lives in service.py
│   ├── rag_workshop/   local manual retrieval
│   └── web_search/     Tavily / DuckDuckGo
├── web/                FastAPI + /ws/diagnostics, WebSocketApprover
├── config.py           settings and the two safety gates
└── cli.py
frontend/               React + Three.js Cyber-HUD (see frontend/README.md)
tests/                  736 tests, all hardware-free
docs/                   ARCHITECTURE, SAFETY, HARDWARE, FREELANDER2

免责声明

本项目仅供教育和研究目的。 它不是经过认证的诊断工具,也不能替代制造商的设备或合格的技术人员。

作者对因使用本软件而导致的车辆损坏、控制模块损坏、维修失败、保修失效或人身伤害不承担任何责任。你有责任在命令到达你的汽车总线之前理解其作用。如果不确定,就不要发送。

免责声明

本项目仅供教育和研究目的。 作者对因使用本软件而导致的任何车辆损坏、控制模块(ECU)损坏或人身伤害不承担任何责任。

始终确保你了解哪些命令——尤其是 写入 命令——被发送到你汽车的 CAN 总线上。


许可证

MIT — 见 LICENSE

维修手册受版权保护,不随本项目分发。data/manuals/ 已被 gitignore;请合法获取你自己的手册。

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables LLMs to interact with vehicle CAN bus and OBD-II data through a simulated ECU environment. Provides tools for reading frames, decoding messages via DBC files, monitoring signals, and querying automotive diagnostics without requiring physical hardware.
    13
    MIT
  • F
    license
    B
    quality
    D
    maintenance
    Connects AI assistants to a local Codex engine for performing deep, project-level code reviews and automated refactoring. It enables context-aware bug fixes and multi-file analysis through a standardized bridge between modern AI clients and local development environments.
    4
    2
  • F
    license
    A
    quality
    D
    maintenance
    Enables LLMs to automatically diagnose coding errors through codebase search, test execution, and live debugger integration (DAP/V8 CDP). Provides a secure, policy-gated environment for investigating failures while preventing destructive operations.
    9
  • F
    license
    A
    quality
    B
    maintenance
    An MCP server that exposes vehicle-diagnostic and CAN-bus domain logic as agent tools, with a LangGraph orchestration layer and a human-in-the-loop eval harness.
    4

View all related MCP servers

Related MCP Connectors

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.

  • Sovereign Agent OS — Persistent Memory, Governance & Compliance for AI Agents.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Mati83mon/Car_Diagnostic_Ai'

If you have feedback or need assistance with the MCP directory API, please join our Discord server