Skip to main content
Glama

mcu-docs-mcp

CI License: MIT Python 3.10+ MCP Apps SEP-1865

Line-Level MCU PDF Manual Locator + Interactive MCP App Viewer + CMSIS-SVD / Pin AF / Silicon Calculators + CubeMX .ioc & Keil .uvprojx Semantic Diff & Hardware Auditor

简体中文文档 · Changelog · Contributing


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]).


Related MCP server: stm32-rag-mcp

30-Second Quick Start

Option A: Zero-Install Run via uvx (Recommended)

uvx --from git+https://github.com/rar-zip/mcu-docs-mcp mcu-docs-mcp

Option B: Local Install (pip)

pip install git+https://github.com/rar-zip/mcu-docs-mcp.git

Or clone and run against the included STM32F407 Motor Drive showcase immediately:

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

claude mcp add mcu-docs --scope user -- uvx --from git+https://github.com/rar-zip/mcu-docs-mcp mcu-docs-mcp --workspace .
{
  "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"
      ]
    }
  }
}

Architecture

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 &amp; 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?

  1. Pull Request Bot: Copy .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:

    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/)

License

MIT License

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Serves verified register data extracted from chip datasheets to AI coding agents, enabling register lookup, bit-field decode/encode, errata checks, document search, and init sequence retrieval.
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      Provides read-only retrieval of STM32 datasheet and reference manual content with exact citations, page numbers, register details, and source hashes so Claude can answer questions or generate code from verified evidence.
      3
      1
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding assistants to perform complete headless STM32 embedded firmware development, including project creation, pin configuration, code generation, building, and flashing, by driving the official STM32 command-line toolchain.
      4
      9
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to directly inspect and debug embedded hardware: reading/writing serial ports and bus devices, auto-detecting baud rates, parsing Modbus/NMEA/custom binary frames, plus diagnosing failures through a 45-rule fault-pattern library, error-code tables, and compile/flash error translation. Also provides pin-conflict checking, register and Cortex-M fault decoding, pre-validated driver and component selection libraries, board knowledge, and guarded flashing with post-flash byte-level verification.
      59
      MIT