embedcalc-mcp

v0.6.7
io.github.ethan-hub26/embedcalc-mcp Checked 4 days ago Published 2 months ago

Embedded calculators, codegen & schematic review: CRC, timing, struct, IEEE-754, KiCad.

LLMs are confidently wrong about exactly the math that bricks boards. Ask any model for a CRC-16/MODBUS check value, an STM32 CAN_BTR register for 500 kbit/s @ 36 MHz, or the padded size of a struct — you'll get a plausible-looking wrong answer often enough that you can't trust any of them. The failure mode is the worst kind: the answer *looks* right. This server gives the model tools instead. Every tool is a pure, deterministic implementation pinned with test vectors (standard CRC check values, oracle fixtures, IPC/ASTM published numbers — 193 tests). No API key, no account.

Summary extracted from the README.

embedcalc-mcp

Exact embedded-engineering math for AI agents. An MCP server with 40 deterministic calculators, code generators, and schematic checks — so Claude, Cursor, or any MCP-enabled agent computes CRC check values, CAN timing registers, and struct padding, and checks KiCad netlists and PADS PCB files for common MCU board wiring mistakes, instead of hallucinating them.

npm MCP Registry license

Why

LLMs are confidently wrong about exactly the math that bricks boards. Ask any model for a CRC-16/MODBUS check value, an STM32 CAN_BTR register for 500 kbit/s @ 36 MHz, or the padded size of a struct — you'll get a plausible-looking wrong answer often enough that you can't trust any of them. The failure mode is the worst kind: the answer looks right.

This server gives the model tools instead. Every tool is a pure, deterministic implementation pinned with test vectors (standard CRC check values, oracle fixtures, IPC/ASTM published numbers — 193 tests).

Install

Claude Code:

claude mcp add embedcalc -- npx -y embedcalc-mcp

Claude Desktop / Cursor / any MCP client (JSON config):

{
  "mcpServers": {
    "embedcalc": { "command": "npx", "args": ["-y", "embedcalc-mcp"] }
  }
}

No API key, no account. Runs locally over stdio. (The optional find_component tool queries embedcalc.com over the network; everything else is offline.) Requires Node.js (npx).

Claude Desktop, step by step:

  1. Claude menu (the app's menu bar, not the settings inside the chat window) → Settings… → Developer → Edit Config. The file is
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Add the embedcalc entry above under mcpServers (keep any servers already there) and save. To pin a version, use "embedcalc-mcp@0.6.7" instead of "embedcalc-mcp".
  3. Quit Claude Desktop completely and start it again — the config is only read at start-up.
  4. Check: click Add files, connectors, and more (bottom-left of the message box) → Connectors → Manage connectors → embedcalc should list the tools. If it does not, the server's log is mcp-server-embedcalc.log in ~/Library/Logs/Claude (macOS) or %APPDATA%\Claude\logs (Windows).

Tools (40)

Domain Tools
Code generation crc_to_c (7 presets + custom Rocksoft params → compilable table-driven C with check value) · regmap_to_c (LSB-first fields → shift/mask defines + bit-field struct) · bitfield_macro
Timing can_bit_timing (bxCAN BTR / FDCAN NBTP / MCP2515 CNF1-3) · uart_baud (STM32 BRR + error %) · i2c_timing (pull-up range + STM32 TIMINGR) · spi_timing · i2s_clocks · lin_timing · rs485_bus · modbus_rtu_timing (t1.5/t3.5) · ring_buffer_size
Data representation qformat_convert (Qm.n fixed point) · ieee754_convert (float/double, hex↔decimal↔bin) · number_base_convert (32-bit two's complement) · endian_swap (incl. Modbus BADC/CDAB) · struct_layout (C parser → offsets/padding/size, 32-bit MCU model)
Electronics eseries_nearest (E6/E12/E24/E96) · resistor_code (color bands + SMD/EIA-96) · crystal_load_caps · lm317 · attenuator_pad (T/π) · junction_temp · microstrip_impedance (IPC-2141) · pcb_trace_width (IPC-2221) · awg_wire · ne555 · dcdc_converter (buck/boost/inverting) · op_amp (gain + bandwidth) · rc_filter (1st-order LP/HP cutoff) · bjt_bias (voltage-divider operating point) · mosfet_switch (low-side conduction + gate drive) · zener_reg (shunt regulator)
Components find_component — real, in-stock MPNs + buy links from a computed value (parametric search)
Schematic review (see limits) review_schematic (deterministic MCU board-rule check on a netlist: decoupling, bulk cap, floating pins, I2C pull-up, reset, output conflict, power short + interface packs auto-detected from net names — USB ESD/VBUS, CAN termination/transceiver, RS-485 termination/bias, SWD connector/reset, crystal load caps — + polarity & voltage/power derating rules (schema-optional ratings) + STM32F4/STM32F1/ESP32/NuMicro family rules; unevaluable rules reported as skipped) · parse_kicad (KiCad netlist export → standard schema, auto-parses voltage ratings) · parse_pads (PADS PowerPCB ASCII .asc or PADS netlist + BOM .xlsx/.xls/.csv → standard schema; real board connectivity, values and fitted/not-fitted from the BOM) · get_extraction_guide (experimental — schematic image/PDF → schema, transcribed by the AI client) · check_transcription (experimental — flags contradictions and unwired parts in such a transcription) · list_schematic_rules

All tool names are prefixed embedcalc_ (e.g. embedcalc_crc_to_c).

Example prompts

"Give me MODBUS CRC-16 as a C function" → table-driven C, check("123456789") = 0x4B37 embedded for on-target verification

"CAN 500 kbit/s on STM32F103, APB1 36 MHz, sample point 87.5%" → CAN_BTR = 0x00050008 (BRP=9, TS1=6, TS2=1)

"How big is struct { uint8_t flags; uint32_t ts; uint16_t id; } on a Cortex-M?" → 12 bytes, 5 of them padding, with the layout table

"Encode −0.25 in Q1.14" / "What float is 0x7FC00000?" / "Nearest E96 to 12.3 kΩ?"

Schematic review — give the absolute paths of the design files and the MCU family; the model calls parse_pads / parse_kicad, then review_schematic:

"Review this board with embedcalc: PCB file C:\boards\NuTiny-N76E885\NUTINY-SDK-N76E885_V21.asc, BOM C:\boards\NuTiny-N76E885\NUTINY-SDK-N76E885_V21_BOM.xls, MCU family numicro" → findings such as no capacitor on the 5V regulator input and no ESD part on USB D+/D-, plus notFitted (parts on the PCB but not in the BOM) to check

"Review my KiCad netlist D:\proj\board.net, MCU family stm32f4" → same review on a KiCad netlist export

  • Use the PADS .asc (PCB or netlist ASCII) and the BOM that vendor reference designs ship next to the PDF. Without a BOM the review still runs, but values and fitted/not-fitted status are unknown.
  • Read skipped in the result: those rules could not run on the given data. A finding means the netlist matches a rule, not that the board is wrong — see the limits below.

Accuracy

  • CRC: all 7 presets verified against standard check values for "123456789"
  • CAN: solver output byte-identical to the interactive calculators at embedcalc.com
  • IEEE-754 / AWG / IPC: pinned to reference constants and published standard values
  • struct_layout uses a 32-bit MCU model (ARM EABI: pointers 4 B; double/int64 size 8, align 8) — stated in the tool description so the model can caveat it

Every release passes 193 tests, including a stdio end-to-end pass that spawns the built server and calls the tools.

Schematic review — what it can and cannot do

  • Reliable input: a design file. A KiCad netlist (parse_kicad) or a PADS PCB ASCII file plus its BOM (parse_pads) gives the real connectivity; review_schematic then runs the rules on it. Many vendor reference designs ship the PADS .asc and BOM next to the PDF. Net names come from the PCB and can differ from the schematic labels; parts missing from the BOM are treated as not fitted and listed in notFitted.
  • Image / PDF input is experimental. The server does not read images. The AI client transcribes the drawing into a parts/nets list and the rules run on that list, so the result is only as good as the transcription. On an 8-page real-board schematic, three independent transcriptions by AI agents were wrong — invented pin numbers, capacitors and resistors left unconnected, MCU pin names misread — and the reviews built on them were wrong as well. check_transcription and the netlist_consistency rule flag lists that contradict themselves or are half-finished, but they cannot catch a pin that was misread consistently. Treat an image-based result as a list of things to check on the drawing, not as a review.
  • Scope. The rules catch common board mistakes (decoupling and bulk caps, pull-ups, reset, USB/CAN/RS-485/SWD/crystal wiring, MCU-family requirements). They are not a full ERC/DRC and do not read part datasheets; "skipped" in the result lists what was not checked.
  • Known limitations (found on a 30-board test run of vendor PADS designs):
    • A rail with no capacitor at all is reported twice: a missing-decoupling error and a missing-bulk warning.
    • A ferrite bead whose BOM value is only a part number (e.g. GZ1608D601TF) is not recognised as a bead, so the nets on either side are judged — and reported — as separate rails.
    • Without a BOM, resistor and inductor values are unknown, so 0Ω links and beads are not followed; a crystal or capacitor behind one can be missed.
    • Decoupling and bulk checks only run on rails that feed an IC/MCU pin. A rail that only feeds a part the parser could not classify (a module typed other) is not checked.
    • On-board debugger detection relies on the Nuvoton convention of ICE-prefixed references for the Nu-Link section; other vendors' on-board debuggers are recognised only when the debug nets link two ICs directly or through a series resistor.
    • A finding means the netlist matches the rule, not that the board is wrong: evaluation boards often leave ESD parts or I2C pull-ups to the attached board on purpose.
  • embedcalc.com — the same 60+ calculators as free interactive tools, no AI required

License

Free to install and use; copying, modifying, reverse-engineering or redistributing the code is not permitted — see LICENSE. Versions 0.6.5 and earlier were published under MIT.