Skip to main content
Glama
pymcuprog-mcp

pymcuprog-mcp

by lucasgerads

pymcuprog-mcp

MCP server wrapping pymcuprog so AI tools (Claude Code, Claude Desktop, etc.) can program Microchip AVR microcontrollers via natural language.

Supports USB HID debuggers (nEDBG, PICkit 4, Atmel-ICE, MPLAB Snap, …) and serial UART UPDI adapters.

Installation

No installation needed if you use uvx — it runs the server directly from PyPI on demand (see .mcp.json examples below).

To install as a persistent tool:

uv tool install pymcuprog-mcp

Or with pip:

pip install pymcuprog-mcp

From source:

git clone https://github.com/lucasgerads/pymcuprog-mcp
cd pymcuprog-mcp
pip install -e .

Related MCP server: J-Link RTT Viewer MCP

Configuration

The server is configured via environment variables. The two most important ones are PYMCUPROG_DEVICE (target MCU name, e.g. atmega4808) and PYMCUPROG_TOOL (debugger type, e.g. nedbg).

Variable

Description

Default

PYMCUPROG_DEVICE

Target device name (e.g. atmega4808, attiny416)

—

PYMCUPROG_TOOL

Debugger type (nedbg, pickit4, atmelice, snap, …)

any connected

PYMCUPROG_SERIALNUMBER

USB serial number substring (to pick a specific tool)

—

PYMCUPROG_SERIALPORT

Serial port for UART UPDI mode (e.g. /dev/ttyUSB0, COM3)

—

PYMCUPROG_BAUDRATE

Baud rate for serial UPDI mode

115200

PYMCUPROG_PROJECT_DIR

Default project directory for the build_and_flash tool

—

Setting PYMCUPROG_SERIALPORT switches the server into serial UPDI mode (uses a plain USB-serial adapter instead of a Microchip debugger).

.mcp.json examples

All examples use uvx, which downloads and runs the server directly from PyPI with no prior installation step.

USB HID debugger (nEDBG / Curiosity Nano)

{
  "mcpServers": {
    "pymcuprog": {
      "command": "uvx",
      "args": ["pymcuprog-mcp"],
      "env": {
        "PYMCUPROG_DEVICE": "atmega4808",
        "PYMCUPROG_TOOL": "nedbg"
      }
    }
  }
}

PICkit 4 or MPLAB Snap

{
  "mcpServers": {
    "pymcuprog": {
      "command": "uvx",
      "args": ["pymcuprog-mcp"],
      "env": {
        "PYMCUPROG_DEVICE": "attiny416",
        "PYMCUPROG_TOOL": "pickit4"
      }
    }
  }
}

Serial UART UPDI (cheap USB-serial adapter)

{
  "mcpServers": {
    "pymcuprog": {
      "command": "uvx",
      "args": ["pymcuprog-mcp"],
      "env": {
        "PYMCUPROG_DEVICE": "avr128da48",
        "PYMCUPROG_SERIALPORT": "/dev/ttyUSB0",
        "PYMCUPROG_BAUDRATE": "115200"
      }
    }
  }
}

Multiple tools on the same machine (select by serial number)

{
  "mcpServers": {
    "pymcuprog-board-a": {
      "command": "uvx",
      "args": ["pymcuprog-mcp"],
      "env": {
        "PYMCUPROG_DEVICE": "atmega4808",
        "PYMCUPROG_TOOL": "nedbg",
        "PYMCUPROG_SERIALNUMBER": "MCHP0001"
      }
    },
    "pymcuprog-board-b": {
      "command": "uvx",
      "args": ["pymcuprog-mcp"],
      "env": {
        "PYMCUPROG_DEVICE": "atmega4808",
        "PYMCUPROG_TOOL": "nedbg",
        "PYMCUPROG_SERIALNUMBER": "MCHP0002"
      }
    }
  }
}

Claude Code (via CLI)

claude mcp add pymcuprog -e PYMCUPROG_DEVICE=atmega4808 -e PYMCUPROG_TOOL=nedbg -- uvx pymcuprog-mcp

Available tools

Tool

Description

list_supported_devices

All device names pymcuprog knows (no hardware needed)

list_connected_tools

USB HID debuggers currently attached

ping

Read device ID bytes to verify connectivity

erase

Chip erase or erase a specific memory area

flash

Erase + write + verify + release in one call (recommended)

build_and_flash

Run make in a project directory, then flash the resulting .hex

write_hex

Program a .hex file with manual control over erase/verify steps

verify_hex

Compare target memory to a .hex file

read_memory

Read raw bytes from flash, EEPROM, fuses, etc.

write_memory

Write raw hex bytes to fuses, EEPROM, user_row, etc.

hold_in_reset

Hold target in reset

release_from_reset

Release target from reset

disconnect

Close the persistent debugger session

read_target_voltage

Measure target VCC

read_supply_voltage

Read debugger supply setpoint

set_supply_voltage

Set debugger supply voltage output

read_tool_info

Read debugger firmware/hardware info

Typical workflow: ping → flash or ping → build_and_flash

All programming tools accept optional device, tool, serialport, etc. parameters to override the environment variables on a per-call basis.

Available Tools

18 tools
build_and_flashB

Build a project with make and flash the result to the target device.

project_dir: path to the directory containing the Makefile. Falls back to the PYMCUPROG_PROJECT_DIR environment variable if not provided. Runs 'make -C project_dir', finds the generated .hex file, then erases, writes, verifies, and releases the target. Returns 'OK' on success; raises with build output on compile failure.

Inputs: project_dir, device, tool, serialnumber, +2 more. Returns: result

disconnectA

Close the persistent programming session.

Call this to cleanly release the debugger connection, for example before unplugging the programmer or switching to a different target. Returns 'OK' on success.

Inputs: no named parameters. Returns: result

eraseB

Erase target device memory.

memory='all' performs a chip erase (default). For AVR, chip erase does not erase EEPROM if the EESAVE fuse is set. Other valid memory values: 'flash', 'eeprom', 'user_row'. Returns 'OK' on success. Use erase before write_hex when the target is not blank.

Inputs: memory, device, tool, serialnumber, +2 more. Returns: result

flashC

Erase, write, and verify a hex file in one operation.

This is the recommended way to program a device. It erases the target, writes the hex file, and verifies the result. hexfile: absolute path to the .hex file on disk. Returns 'OK' on success.

Inputs: hexfile (required), device, tool, serialnumber, +2 more. Returns: result

get_configA

Return the current server configuration read from environment variables.

Call this first to confirm what device and tool are configured before running any programming operations. No hardware connection is required.

Inputs: no named parameters. Returns: result

hold_in_resetA

Hold the target device in reset.

The device remains in reset until release_from_reset is called or the debugger is disconnected. Returns 'OK' on success.

Inputs: device, tool, serialnumber, serialport, +1 more. Returns: result

list_connected_toolsA

Return a list of Microchip USB HID debuggers currently attached to the host.

Optionally filter by tool_name (e.g. 'nedbg', 'pickit4'). No device or session configuration is required.

Inputs: tool_name. Returns: result

list_supported_devicesA

Return a sorted list of all device names supported by pymcuprog.

No hardware connection is required. Use this to find the correct device name before calling any programming tool.

Inputs: no named parameters. Returns: result

pingB

Read the device signature bytes to confirm communication with the target.

Returns the device ID as a space-separated hex string (e.g. '0x1e 0x96 0x51'). Use this to verify the target is connected and responding before programming.

Inputs: device, tool, serialnumber, serialport, +1 more. Returns: result

read_memoryA

Read raw bytes from a target device memory area.

memory: one of 'flash', 'eeprom', 'fuses', 'user_row', 'signatures', 'lockbits', 'boot_row'. offset: byte offset within the memory to start reading (default: 0). length: number of bytes to read; 0 means read to end of memory (default: 0). Returns a JSON object with keys 'memory', 'offset', 'length', and 'hex' where 'hex' is a space-separated hex byte string.

Inputs: memory, offset, length, device, +4 more. Returns: result

read_supply_voltageA

Read the debugger's onboard supply voltage setpoint.

Returns the current setpoint as a float string. Requires a USB HID debugger with onboard supply capability (e.g. Curiosity Nano).

Inputs: tool, serialnumber. Returns: result

read_target_voltageA

Read the voltage on the target VCC pin as measured by the debugger.

Returns the measured voltage as a float string (e.g. '3.298'). Requires a USB HID debugger with voltage measurement capability. Does not require a target device or programming session.

Inputs: tool, serialnumber. Returns: result

read_tool_infoB

Read hardware and firmware information from the connected debugger.

Returns a JSON object with fields such as fw_major, fw_minor, hw_rev, serial_number, and device_name. Requires a USB HID debugger; does not require a target device.

Inputs: tool, serialnumber. Returns: result

release_from_resetC

Release the target device from reset, allowing it to start executing.

Returns 'OK' on success.

Inputs: device, tool, serialnumber, serialport, +1 more. Returns: result

set_supply_voltageA

Set the debugger's onboard supply voltage output (e.g. 3.3 or 5.0).

Returns 'OK' on success. Requires a USB HID debugger with onboard supply capability. WARNING: Ensure the target device supports the requested voltage before calling.

Inputs: voltage (required), tool, serialnumber. Returns: result

verify_hexA

Verify that target device memory matches an Intel HEX file.

hexfile: absolute path to the .hex file on disk. Returns 'PASS' if memory matches, raises an error if it does not. Use after write_hex or to audit an already-programmed device.

Inputs: hexfile (required), device, tool, serialnumber, +2 more. Returns: result

write_hexA

Write an Intel HEX file to the target device.

hexfile: absolute path to the .hex file on disk. erase_first: if True, performs a chip erase before writing. Default: False. verify_after: if True, reads back and verifies all written memory. Default: True. Returns 'OK' on success, raises an error if programming or verification fails. For the common case of a full firmware update, prefer the flash tool instead.

Inputs: hexfile (required), erase_first, verify_after, device, +4 more. Returns: result

write_memoryA

Write raw bytes to a target device memory area.

memory: memory area name (e.g. 'fuses', 'eeprom', 'user_row'). data_hex: bytes to write as a space-separated or 0x-prefixed hex string (e.g. '0xff 0x00 0xc8' or 'ff 00 c8'). offset: byte offset within the memory to start writing (default: 0). Returns 'OK' on success. Use for writing fuse bytes, EEPROM, or small memory regions. For full firmware images, prefer flash which handles address mapping.

Inputs: memory (required), data_hex (required), offset, device, +4 more. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 18 tools

    Disambiguation4/5

    Most tools have distinct purposes with clear descriptions, but there is some overlap between flash, write_hex, write_memory, and build_and_flash. The descriptions clarify differences, so agents can generally choose correctly.

    Naming Consistency4/5

    Tool names predominantly use snake_case with a verb_noun pattern, but some are single verbs (erase, flash, ping) and a few combine verb_verb (build_and_flash) or verb_prep_noun (hold_in_reset), creating minor inconsistencies.

    Tool Count5/5

    18 tools cover the full programming workflow—connection, programming, memory ops, voltage control, info—without being excessive. Each tool serves a distinct need for the domain.

    Completeness5/5

    The tool set covers build, erase, write, verify, read, reset, voltage control, and tool info. Missing specialized fuse/lockbit tools are mitigated by write_memory/read_memory, making the surface complete for typical use.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants like Claude to directly debug microcontrollers via JLink, supporting breakpoints, single-step, memory/register access, variable inspection, RTT logging, and firmware flashing.
      25
      7
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to interact with STM32 development boards via J-Link debugger using RTT communication, supporting connection, logging, memory operations, and firmware flashing through natural language.
      12
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to debug ARM Cortex-M targets via GDB and OpenOCD, supporting attach, breakpoints, stepping, register/memory inspection, and SVD peripheral decoding.
      MIT