mcu-docs-mcp
by rar-zip
README.md
# mcu-docs-mcp
[](https://github.com/rar-zip/mcu-docs-mcp/actions/workflows/ci.yml)
[](./LICENSE)
[](./pyproject.toml)
[](https://github.com/modelcontextprotocol/ext-apps)
**Line-Level MCU PDF Manual Locator + Interactive MCP App Viewer + CMSIS-SVD / Pin AF / Silicon Calculators + CubeMX `.ioc` & Keil `.uvprojx` Semantic Diff & Hardware Auditor**
[简体中文文档](./README.zh-CN.md) · [Changelog](./CHANGELOG.md) · [Contributing](./CONTRIBUTING.md)
---
<p align="center">
<img src="./docs/assets/hero-demo.gif" alt="mcu-docs-mcp live demo: AI answers with exact TIM1_BDTR register math while opening RM0090 Page 3 highlighted at Line 10" width="960" />
</p>
## Why `mcu-docs-mcp`?
Firmware bugs don't just crash a web tab—a misconfigured `TIM1_BDTR.DTG[7:0]` dead-time bit or silent `APB1` clock divider shift can destroy power MOSFETs or take a CAN bus offline.
Yet existing embedded AI tools suffer from three structural gaps:
1. **Register & Math Hallucinations**: LLMs frequently guess wrong register offsets or miscalculate STM32's 4-range nonlinear dead-time formula.
2. **Unverifiable PDF Answers**: Chunked vector RAG shreds multi-column register tables and strips out timing diagrams—forcing engineers to manually `Ctrl+F` 2,000-page PDFs anyway.
3. **Unreadable `.ioc` & `.uvprojx` Diffs**: Regenerating CubeMX reshuffles keys, silently shifts peripheral clocks, or drops hand-added Keil `.c` files with zero PR visibility.
`mcu-docs-mcp` fixes all three in one zero-bloat local package:
- **Left Hand**: Reads your project (`.ioc`, `.uvprojx`, CMSIS-SVD, `STM32_open_pin_data` XML) and computes exact silicon timing deterministically.
- **Right Hand**: Opens the **original PDF manual page** inside your AI client (`ui://mcu-docs/viewer.html`) with glowing yellow SVG bounding-box highlights down to **exact Chapter, Page, and Line** (`[RM0090 §17.4.18, P.3, L.10]`).
---
## 30-Second Quick Start
### Option A: Zero-Install Run via `uvx` (Recommended)
```bash
uvx --from git+https://github.com/rar-zip/mcu-docs-mcp mcu-docs-mcp
```
### Option B: Local Install (`pip`)
```bash
pip install git+https://github.com/rar-zip/mcu-docs-mcp.git
```
Or clone and run against the included **STM32F407 Motor Drive** showcase immediately:
```bash
git clone https://github.com/rar-zip/mcu-docs-mcp.git
cd mcu-docs-mcp
pip install -e ".[dev]"
# 1. Semantic diff between v1 & v2 CubeMX + Keil configs
mcu-docs diff \
--ioc-before examples/stm32f407_motor_drive/motor_ctrl_v1.ioc \
--ioc-after examples/stm32f407_motor_drive/motor_ctrl_v2.ioc \
--uvprojx-before examples/stm32f407_motor_drive/motor_ctrl_v1.uvprojx \
--uvprojx-after examples/stm32f407_motor_drive/motor_ctrl_v2.uvprojx
# 2. Cross-audit hardware config against clock limits, SVD, pins & Errata PDFs
mcu-docs audit examples/stm32f407_motor_drive/motor_ctrl_v2.ioc \
--uvprojx examples/stm32f407_motor_drive/motor_ctrl_v2.uvprojx
# 3. Deterministic TIM1_BDTR.DTG[7:0] dead-time solver (200 ns @ 168 MHz)
mcu-docs calc tim_deadtime --clk-mhz 168 --target-ns 200
# 4. Line-level manual search
mcu-docs search "TIMx_BDTR DTG"
```
---
## Connect to Your AI Client
<details>
<summary><b>Claude Code (One-Line CLI)</b></summary>
```bash
claude mcp add mcu-docs --scope user -- uvx --from git+https://github.com/rar-zip/mcu-docs-mcp mcu-docs-mcp --workspace .
```
</details>
<details>
<summary><b>Antigravity / Claude Desktop / Cursor / VS Code (<code>mcp_config.json</code>)</b></summary>
```json
{
"mcpServers": {
"mcu_docs_mcp": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/rar-zip/mcu-docs-mcp",
"mcu-docs-mcp",
"--workspace",
"/path/to/your/firmware-repo"
]
}
}
}
```
</details>
---
## Architecture
```mermaid
flowchart LR
A["Firmware Repo<br/>.ioc / .uvprojx / .svd / PDFs"] --> B["mcu-docs-mcp Server<br/>(Python + PyMuPDF + SQLite FTS5)"]
B --> C["Deterministic Engines<br/>SVD Decoder · Pin AF · 4x Timing Calcs<br/>Multi-Family Profiles (F0..H7/U5)"]
B --> D["Line-BBox Manual Index<br/>(section, page, line_no, x0..y1)"]
D --> E["MCP App Viewer<br/>ui://mcu-docs/viewer.html<br/>Yellow Highlight + L# Ruler + Ask AI"]
A --> F["CI PR Bot & git textconv<br/>mcu-docs diff / git-install"]
```
---
## MCP Tools Reference
| Tool | Purpose | Interactive Viewer? |
| :--- | :--- | :--- |
| `open_manual_viewer` | Opens the MCP App PDF viewer (`aux_pane` / `global` / inline) at any page, line range, or search hit | Yes |
| `search_manual` | FTS5 hardware-token search returning `[DocID §Sec, P.x, L.y]` citations + page highlight | Yes |
| `index_pdf_manual` | Indexes any vendor PDF (STM32, GD32, CH32V, ESP32, TI, sensors) by SHA-256 into SQLite FTS5 | — |
| `lookup_register` | Queries CMSIS-SVD (supports `derivedFrom`) + decodes 32-bit hex snapshots + jumps viewer | Yes |
| `lookup_pin_af` | Queries `STM32_open_pin_data` XML for valid alternate functions (`PA9` ↔ `USART1_TX AF7`) | — |
| `calc_peripheral_timing` | Solves `TIMx_BDTR.DTG[7:0]` (all 4 nonlinear ranges), PWM `PSC/ARR/CCR`, `USART_BRR`, `CAN_BTR` | — |
| `diff_project_configs` | Semantic `.ioc` & `.uvprojx` diff with derived CAN/UART drift and dropped-file alerts | — |
| `audit_project` | Full hardware audit against silicon family bus limits (`F0..H7/U5`), shoot-through & Errata PDFs | Yes |
| `fetch_stm32_data` | Downloads & loads official `STM32_open_pin_data` XML and `cmsis-svd-data` `.svd` for any part | — |
---
## GitHub PR Diff Bot & Local `git diff`
Tired of unreadable 800-line `.ioc` key-shuffling diffs on Pull Requests?
<p align="center">
<img src="./docs/assets/pr-diff-preview.svg" alt="GitHub PR semantic diff comment preview" width="840" />
</p>
1. **Pull Request Bot**: Copy [`.github/workflows/mcu-config-diff.yml`](./.github/workflows/mcu-config-diff.yml) into your repo to automatically post/update sticky semantic diff reports on every `.ioc` or `.uvprojx` PR.
2. **Local `git diff` Driver**: Run once inside any firmware repo to make plain `git diff` human-readable:
```bash
mcu-docs git-install
```
---
## Supported Silicon Families & Vendor Manuals
- **Built-in Family Profiles** (`silicon_profiles.py`): `STM32F0`, `STM32F1`, `STM32F3`, `STM32F401/411/405/407/429/446`, `STM32F7`, `STM32G0`, `STM32G4`, `STM32L4`, `STM32H7`, `STM32U5`.
- **PDF Locator & Viewer**: Works out-of-the-box with **any** vector PDF manual — **STM32, GD32, WCH CH32V, ESP32, NXP, TI, Nordic**, plus external ICs/sensors (**MPU6050, ADS1256, W25Q128, TMC2209**).
## Bundled Agent Skills (`skills/`)
- [`cubemx-pr-audit`](./skills/cubemx-pr-audit/SKILL.md) — Semantic PR review for `.ioc` & `.uvprojx`
- [`register-timing-calc`](./skills/register-timing-calc/SKILL.md) — Grounded `DTG[7:0]`, PWM, `BRR` & `CAN_BTR` math
- [`hardfault-silicon-triage`](./skills/hardfault-silicon-triage/SKILL.md) — Hex register dump decoding & Errata triage
- [`manual-deep-locator`](./skills/manual-deep-locator/SKILL.md) — Line-level PDF citation & interactive viewer workflow
## License
[MIT License](./LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues