Skip to main content

MCP server wrapping pymcuprog for AVR/Microchip programming

Project description

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

pip install pymcuprog-mcp

Or from source:

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

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

USB HID debugger (nEDBG / Curiosity Nano)

{
  "mcpServers": {
    "pymcuprog": {
      "command": "pymcuprog-mcp",
      "env": {
        "PYMCUPROG_DEVICE": "atmega4808",
        "PYMCUPROG_TOOL": "nedbg"
      }
    }
  }
}

PICkit 4 or MPLAB Snap

{
  "mcpServers": {
    "pymcuprog": {
      "command": "pymcuprog-mcp",
      "env": {
        "PYMCUPROG_DEVICE": "attiny416",
        "PYMCUPROG_TOOL": "pickit4"
      }
    }
  }
}

Serial UART UPDI (cheap USB-serial adapter)

{
  "mcpServers": {
    "pymcuprog": {
      "command": "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": "pymcuprog-mcp",
      "env": {
        "PYMCUPROG_DEVICE": "atmega4808",
        "PYMCUPROG_TOOL": "nedbg",
        "PYMCUPROG_SERIALNUMBER": "MCHP0001"
      }
    },
    "pymcuprog-board-b": {
      "command": "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 -- 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: pingflash or pingbuild_and_flash

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymcuprog_mcp-0.1.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymcuprog_mcp-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pymcuprog_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: pymcuprog_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymcuprog_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9482d8859305f0d789fd157ca452a7f9836b4ca8e508cd6447eead22a396c48e
MD5 ac23a2054cef60cee4375c901105eef6
BLAKE2b-256 b5426493a805af194dd49e67f0222a9e25f84f55145c6864938ebb57eadd5889

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymcuprog_mcp-0.1.1.tar.gz:

Publisher: release.yml on lucasgerads/pymcuprog-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymcuprog_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pymcuprog_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymcuprog_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ad111eee997080f03d77b0a92bdebebb6bca557c47d9bf205d81b28063fe9d2
MD5 82fb37c160845e40eb68524759ba4c86
BLAKE2b-256 1f45e956aaa713c7fcac6be094f85241e6f64f6a0c7b5689b9765116bf576991

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymcuprog_mcp-0.1.1-py3-none-any.whl:

Publisher: release.yml on lucasgerads/pymcuprog-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page