Skip to main content
Glama
bitpirate-mcp
by Indigaz

An MCP server for the ESP32-Bit-Pirate - an open-source, ESP32-S3-based clone of the Bus Pirate multibus tool. It exposes the bench's UART, SPI (incl. the on-device flash shell), I2C (master and slave), 1-Wire, GPIO, PWM and scope/measure capabilities as MCP tools over stdio, so an AI agent can probe, dump and analyze firmware on a target board end-to-end: attach a device to the ESP32, let the agent drive the tools, and get extracted binaries and analysis out the other end.

A port of buspirate-mcp (Marc Plogas, MIT) from the BusPirate 6's BPIO2 binary protocol to the Bit-Pirate's text-console protocol. The tool/dispatch/session/safety layers are largely kept verbatim; the device layer was replaced and re-grounded in the Bit-Pirate v1.8 firmware source.

What makes this different from the upstream

buspirate-mcp (BP6)

bitpirate-mcp (ESP32-Bit-Pirate)

Transport

BPIO2 flatbuffers over a 2nd CDC port

Plain text console at 115200 baud (single CDC port)

Device layer

hardware.py (BPIO2 SDK, submodule)

bitpirate_hardware.py (prompt/marker-aware console driver, no vendor deps)

Flash work

Manual JEDEC sequences + host-side page program/erase

Native firmware flash shell: probe, on-device analysis, search, strings, read, raw dump, patch write, full erase

On-device analysis

None

BinaryAnalyzer in firmware: file signatures, secret patterns (keys/hashes/URLs), entropy summary

Raw transactions

spi_transfer byte arrays

BP6-style instruction syntax [0x9F r:3] dispatched by the firmware

Logic analyzer

FALA (5 tools, 75 MHz, 8 ch)

Removed - no FALA; verify_connection uses the DIO measure edge/frequency detector; measure_pin/measure_frequency/capture cover DIO timing

Power supply

Hardware PSU (3 tools)

None on the bare devkit - tools report psu: unavailable gracefully

Signal timing

Fast binary protocol

~2 s per menu round-trip (firmware main-loop latency); raw dump is serial-bottlenecked (~11.5 KB/s)

Gains: the Bit-Pirate is stronger for RE than the BP6 in one key respect - the firmware does binary analysis on the device (39 secret patterns, file signature table, entropy), so spi_flash_analyze returns findings without pulling the whole image first. It is also cheaper (~$15 board + devkit vs $100+).

Related MCP server: agentic-hil

Architecture

MCP client (Claude Code, Hermes, any MCP host)
  |  stdio
  v
server.py            tool definitions + dispatch + safety tiers + session mgmt
  |
  v
tools.py             53 tool implementations (protocol-agnostic where possible)
  |
  v
bitpirate_hardware.py  THE device layer (the only firmware-specific module)
  |  pyserial, /dev/ttyACM0 @115200
  v
ESP32-S3 running ESP32-Bit-Pirate v1.8 text console

The console driver has two read modes, both grounded in the firmware's actual output:

  • Prompt-aware reads - command, then read until the trailing mode prompt (DIO> , SPI> , …) matches at the end of the transcript. Used for mode switches, DIO, and instruction-syntax transactions.

  • Marker-aware reads - shell flows (flash shell, config wizard) don't end at a mode prompt; the driver reads until a known completion marker (=== SPI Flash Shell ===, SPI Flash Dump: Done., SPI configured., …) and answers intermediate prompts in the exact order the firmware asks them.

A quadratic-echo line-length guard (250 chars) protects the firmware's getLine input path.

Every command string in the driver was taken from the v1.8 firmware source - SpiFlashShell.cpp, SpiController.cpp, DioController.cpp, UserInputManager.cpp, ActionDispatcher.cpp - not assumed.

Tools (53)

Safety tiers: read-only (full autonomy), allowed-write (autonomous, logged), approval-write (blocks until a human confirms with _confirmed: true and the firmware's own confirmation prompts are driven - double-gated for destructive operations).

Session & UART

Tool

Tier

Notes

list_devices

read-only

USB CDC console ports

verify_connection

read-only

DIO measure edge/frequency detector on TX/RX

scan_baud

read-only

baud probing over a UART session

open_uart / send_command / close_uart

allowed-write

console interaction with targets

uart_ping

allowed-write

probe burst (message x repeats) + bounded response capture with echo count

read_output

read-only

non-blocking capture of target output

enter_download_mode

allowed-write

boot/EN pin toggling (0-48 GPIO)

read_flash

allowed-write

esptool through the firmware UART bridge

SPI (incl. on-device flash shell)

Tool

Tier

Notes

open_spi / close_spi

allowed-write

mode switch + engagement session; close exits the flash shell

spi_probe

read-only

firmware flash probe: JEDEC ID, manufacturer, model, capacity

spi_read

read-only

region read as hexdump

spi_dump

read-only

raw full-chip dump to a file - the workhorse for RE

spi_write

approval-write

patch write from file/hex/ASCII, auto-erase option

spi_transfer

read-only

BP6-style instruction [0x9F r:3] (JEDEC, status, custom sequences)

spi_config

allowed-write

MOSI/MISO/SCLK/CS pins + 1-80 MHz + WP/HOLD (NVS-persisted)

spi_flash_analyze

read-only

on-device BinaryAnalyzer: file signatures, secrets, entropy

spi_flash_search

read-only

string search (1-32 bytes) with context

spi_flash_strings

read-only

printable-string extraction

spi_flash_erase

approval-write

full-chip erase - destructive

I2C (master + slave)

Tool

Tier

Notes

open_i2c / close_i2c

allowed-write

engagement session

i2c_ping

read-only

single-byte ping (ack/no-ack)

i2c_scan

read-only

bus scan

i2c_read / i2c_dump

read-only

register read / range dump

i2c_write

approval-write

register write

open_i2c_slave / close_i2c_slave

allowed-write

bench as I2C slave: a target master can write to / read from the bench

i2c_slave_log

read-only

mid-session capture of what a target master sent

1-Wire (incl. DS18B20 lifecycle)

Tool

Tier

Notes

open_1wire / close_1wire

allowed-write

engagement session

onewire_search

read-only

ROM search (multi-device aware)

onewire_ping

read-only

presence detect

onewire_temp

read-only

DS18B20 convert + read (CRC-checked by firmware)

onewire_read

read-only

scratchpad read-back

onewire_write_spad

allowed-write

scratchpad program (e.g. temperature-set for test emulators)

DIO, PWM & measurement

Tool

Tier

Notes

set_pin / read_pin

allowed / read

GPIO drive and sample

dio_toggle

allowed-write

read a pin and drive the opposite level

pulse

allowed-write

timed pulse on a pin

pull_up / pull_down

allowed-write

weak-pull configuration

pwm_set / pwm_stop

allowed-write

hardware PWM (50 Hz-~100 kHz)

servo_set

allowed-write

50 Hz pulse-width servo control

measure_pin

read-only

edge/level timing on a pin

measure_frequency

read-only

frequency measurement

capture

read-only

bounded logic capture (hex)

PSU (hardware-dependent)

Tool

Tier

Notes

set_voltage / set_power

approval-write

report psu: unavailable (no PSU on the bare devkit)

Install

# any Python 3.10+ (tested on 3.11)
git clone https://github.com/Indigaz/bitpirate-mcp
cd bitpirate-mcp
python3 -m venv .venv          # or: uv venv --python 3.11 .venv
.venv/bin/pip install -e .

Register with an MCP host (.mcp.json):

{
  "mcpServers": {
    "bitpirate": {
      "command": "/absolute/path/to/bitpirate-mcp/.venv/bin/python",
      "args": ["-m", "buspirate_mcp"]
    }
  }
}

Board requirements: an ESP32-S3 devkit running ESP32-Bit-Pirate v1.x, exposing a USB CDC console (/dev/ttyACM0 on Linux). No pin configuration needed for first use - the firmware keeps its SPI pin map in NVS (defaults on a typical Bit-Pirate build: MOSI 40, MISO 39, SCLK 41, CS 4, 20 MHz, WP 7); spi_config re-points any free GPIO.

Typical RE workflow

  1. Attach a target to the bench (SPI flash via clip, or I2C bus).

  2. spi_probe - identify the chip (ID, manufacturer, capacity).

  3. spi_dump → ~/re-lab/<target>/flash.bin - raw image off the bus.

  4. spi_flash_analyze / spi_flash_strings / spi_flash_search - on-device findings (what firmware, embedded keys, embedded binaries).

  5. Hand the image to your static-analysis tooling (Ghidra, REA, etc.).

Testing & verification

  • 301 unit tests, all passing. The device layer is tested with a transcript-driven protocol mock (FakeSerial): scripted firmware transcripts are released only after the triggering command is written, simulating real round-trip latency so command/response pairing cannot bleed across commands. The mock is a FIFO of (line → response) so repeated prompts (e.g. y/y) resolve in firmware order, and it accepts raw bytes for the dump path.

  • Live-verified on hardware (ESP32-S3 devkit + Bit-Pirate v1.8, no target attached - no-chip paths): DIO read, edge counter, drive-HIGH/LOW self-test; instruction syntax [0x9F r:3] (floating bus, correct); flash shell probe (no-chip detection), analyze short-circuit, clean shell exit. Reproduce: scripts/smoke_live.py, scripts/smoke_live_spi.py (read-only by design).

  • Protocol battery: 92/92 steps green on a two-board rig. A second ESP32-S3 running a custom rig-responder firmware acts as the target side (SPI slave, I2C slave + master, 1-Wire DS18B20 emulator with scratchpad/RAM, GPIO mirror witness, scope). Every checked value is derived from a known write - no flake-tolerant assertions. scripts/protocol_battery.py (console 31 steps + mcp 61 steps).

Roadmap

Shipped

Phase / Tier

What landed

Phase 1–2

Console driver (prompt/marker-aware), safety tiers, UART session tools

Phase 3

I2C host tools + 1-Wire search/read

Phase 4

read_flash via the firmware UART bridge (esptool)

Phase 5

Scope/measure: measure_pin, measure_frequency, capture

Tier 3

DIO digital + PWM: set_pin, read_pin, pulse, pull_up, pull_down, pwm_set, pwm_stop

Tier 4

Bidirectional I2C (ping + bench-as-slave) + servo_set

Tier 5

1-Wire DS18B20 lifecycle: onewire_ping, onewire_temp, onewire_write_spad

Tier 6

Deterministic end-to-end verification: the 92-step protocol battery on a real two-board rig

Open upstream PRs (geo-tp/ESP32-Bit-Pirate)

PR

Fix

#201

onewire: add xfer command (raw 1-Wire transfer primitive)

#202

uart: add uread bounded read; stop redundant UART re-init

#203

scope/measure: bounded wizreport, freqms, logiccap commands for the MCP driver

#204

hiz: actually release DIO/OneWire/UART pins on mode exit

Next (MCP-side, small)

  • dio_toggle - invert a pin without re-driving a level.

  • uart_ping - timed (5 s) capture to characterize a DUT's baud/echo behavior.

  • i2c_transfer - bracket instruction syntax for raw I2C sequences (parity with spi_transfer).

Proposed features (by effort)

  • XMODEM send/receive tools - the firmware already implements xmodem; expose it as MCP tools for AT-style DUT firmware flashing.

  • uart_read_lines - line-buffered reads (AT command shells, OK-gated targets).

  • dio_shift - clock a byte out across N pins (shift-register DUTs).

  • 1-Wire depth - multi-device search results, DS2408 (8-channel I/O), DS2431/DS2433 EEPROM read/write.

  • spi_slave - bench as SPI slave so a target master can drive the bench (completes the bidirectional matrix: I2C slave exists, SPI slave does not).

  • SPI EEPROM shell - 24xx/25xx EEPROM read/write (matches common bench EEPROMs; carries over from the original Phase 3).

  • capture output modes - save-to-file + ASCII waveform rendering so an agent can actually see the signal.

  • analog_read - ESP32-S3 ADC path (upstream firmware PR; the S3 has ADCs the Bit Pirate firmware doesn't use yet).

  • spi_flash_diff - compare two dumps (find what a patch changed).

  • Bluetooth mode tools - the firmware's S3 BT mode is unexposed; upstream work, larger effort, listed for completeness.

Packaging (carried)

  • Rename the buspirate_mcp package to bitpirate_mcp, PyPI publish, CI.

Credits

  • Upstream: buspirate-mcp by Marc Plogas (MIT) - the tool/dispatch/session/ safety architecture it builds on.

  • Hardware & firmware: ESP32-Bit-Pirate by geo-tp (the console protocol, flash shell and analyzer this port drives).

  • Port to the ESP32-Bit-Pirate: designed and implemented by Hermes Agent (Nous Research)

    • the LLM agent driving this bench - under direction by Christian Brooks (Indigaz), who owns the hardware, set the goals, and reviews the work.

  • Method: every firmware-facing string is grounded in v1.8 source; the whole port is test-first (301 unit tests) and verified end-to-end on a real two-board rig (92/92 protocol battery) before each phase ships.

License

MIT - see LICENSE. Upstream copyright (c) Marc Plogas; port copyright (c) 2026 Hermes Agent (Nous Research) / Christian Brooks.

Available Tools

33 tools
close_1wireA

Close a 1-Wire session and reset the ESP32-Bit-Pirate to HiZ mode. [allowed-write] [Duration: instant.]

Inputs: session_id (required).

close_i2cB

Close an I2C session and reset the ESP32-Bit-Pirate to HiZ mode. [allowed-write] [Duration: instant.]

Inputs: session_id (required).

close_spiB

Exit the flash shell and reset the ESP32-Bit-Pirate to HiZ mode. [allowed-write] [Duration: instant.]

Inputs: session_id (required).

close_uartB

Close a UART session and finalize logs. [allowed-write] [Duration: instant.]

Inputs: session_id (required).

enter_download_modeA

Put target into UART download mode by toggling GPIO pins. Holds boot pin LOW, pulses reset pin, releases. Works for ESP32, ESP8266, and similar chips. [allowed-write] [Duration: fast (~1-2 s -- GPIO toggle sequence).]

Inputs: boot_pin (required), reset_pin (required).

i2c_dumpC

Dump memory from an I2C device by reading all registers sequentially. Saves to artifacts. [read-only] [Duration: slow for large sizes (~1-2 min for 64 KB EEPROM). Fast for small sizes (256 bytes ~2-5 s). Parameterized by size. Background-dispatch recommended for large dumps.]

Inputs: session_id (required), device_addr (required), size, register_bytes.

i2c_readB

Read bytes from an I2C device, optionally from a specific register. [read-only] [Duration: instant.]

Inputs: session_id (required), device_addr (required), length, register_addr.

i2c_scanB

Scan the I2C bus for devices. Returns 7-bit addresses with device hints. [read-only] [Duration: slow (~3-10 s -- sweeps all 128 7-bit addresses). Background-dispatch recommended.]

Inputs: session_id (required).

i2c_writeA
Destructive

Write bytes to an I2C device register. DANGEROUS: may alter device configuration or EEPROM contents. [approval-write] [Duration: instant.]

Inputs: data_hex (required), session_id (required), device_addr (required), register_addr (required), +1 more.

list_devicesA

Find ESP32-Bit-Pirate console ports on USB CDC serial. [read-only] [Duration: instant.]

Inputs: no named parameters.

onewire_readC

Send arbitrary bytes on the 1-Wire bus and read back a response. [read-only] [Duration: instant.]

Inputs: write_hex (required), read_bytes (required), session_id (required).

open_1wireB

Open a 1-Wire connection and start an engagement. Configures 1-Wire mode with pullup enabled. [allowed-write] [Duration: fast (~0.5-2 s -- mode switch + folder creation).]

Inputs: engagement_name (required), current_ma, voltage_mv, engagement_path.

open_i2cB

Open an I2C connection and start an engagement. Configures I2C mode with pullups enabled. [allowed-write] [Duration: fast (~0.5-2 s -- mode switch + folder creation).]

Inputs: engagement_name (required), speed, current_ma, voltage_mv, +2 more.

open_spiB

Enter SPI mode on the ESP32-Bit-Pirate and start an engagement. Pin map comes from NVS (change with spi_config). [allowed-write] [Duration: fast (~1-2 s -- mode switch).]

Inputs: engagement_name (required), engagement_path.

open_uartB

Open a persistent UART connection and start an engagement. Creates engagement folder and raw logging. [allowed-write] [Duration: fast (~0.5-2 s -- mode switch + folder creation).]

Inputs: baud (required), engagement_name (required), rx_pin, tx_pin, +1 more.

read_flashA

Read flash memory from target via esptool through the Bit-Pirate UART bridge. Optionally enters download mode first. Requires esptool installed. [allowed-write] [Duration: very-slow (~3-5 min for 1-2 MiB at 460800 baud; larger images proportionally longer). Background-dispatch required. Bridge mode persists after dump -- press the Bit-Pirate button or USB-replug to exit.]

Inputs: size (required), output_path (required), baud, offset, +2 more.

read_outputA

Read available data from an open UART session. Blocks up to timeout. [read-only] [Duration: fast (~timeout_ms; default 5 s). Returns earlier if data is available.]

Inputs: session_id (required), timeout_ms.

scan_baudA

Scan common baud rates and score by readable ASCII output. Returns candidates sorted by confidence. [read-only] [Duration: slow (~15-60 s -- cycles through common baud rates, samples each for a short window). Background-dispatch recommended.]

Inputs: no named parameters.

send_commandB

Send a command over UART and capture the response. [allowed-write] [Duration: fast (~timeout_ms; default 3 s). Returns earlier when response is received.]

Inputs: command (required), session_id (required), timeout_ms.

set_powerB
Destructive

Enable or disable the power supply. DANGEROUS: affects power to target device. [approval-write] [Duration: instant.]

Inputs: enable (required), _confirmed.

set_voltageB
Destructive

Set power supply voltage (0.8-5.0V) and current limit (0-500mA). DANGEROUS: wrong voltage can damage target hardware. [approval-write] [Duration: instant.]

Inputs: voltage_v (required), current_limit_ma (required), _confirmed.

spi_configB

Set the SPI pin map (MOSI/MISO/SCLK/CS GPIO, frequency 1-80 MHz, optional WP/HOLD pins). NVS-persisted by the firmware. [allowed-write] [Duration: fast (~2-4 s).]

Inputs: cs (required), miso (required), mosi (required), sclk (required), +3 more.

spi_dumpA

Dump the entire SPI flash to a file (firmware raw mode, menu 8). Serial-bottlenecked (~91 s per MiB at 115200 baud). [read-only] [Duration: slow - very-slow (4 MiB flash ~ 7 min). Background-dispatch required.] Returns {path, size}.

Inputs: output_path (required), timeout.

spi_flash_analyzeA

Run the on-device BinaryAnalyzer over the whole flash: file signatures, sensitive patterns (keys, hashes, URLs), entropy summary. [read-only] [Duration: slow - very-slow (full-chip read ~91 s/MiB + analysis). Background-dispatch recommended.]

Inputs: timeout.

spi_flash_eraseA
Destructive

Erase the ENTIRE flash chip (firmware menu 9). DANGEROUS: all contents destroyed. [approval-write] [Duration: slow - very-slow (seconds to minutes depending on chip).]

Inputs: _confirmed (required), timeout.

spi_flash_stringsA

Extract printable strings from the whole flash (min length parameter). [read-only] [Duration: slow - very-slow (full-chip read). Background-dispatch recommended.]

Inputs: timeout, min_length.

spi_probeA

Detect the SPI flash chip via the firmware flash shell. Returns JEDEC ID, manufacturer, model, capacity, and capability notes. [read-only] [Duration: fast (~2-5 s).]

Inputs: no named parameters.

spi_readA

Read a region of SPI flash memory as a hexdump (firmware menu 5). [read-only] [Duration: fast - slow (serial-bottlenecked ~11.5 KB/s -- ~8 s per 100 KiB).]

Inputs: length (required), address (required), timeout.

spi_transferB

Run a BP6-style SPI instruction, e.g. '[0x9F r:3]' (JEDEC read), '[0x05 r:1]' (status), '[0x06] [0xC7]' (enable + chip erase). Dispatched to the firmware's instruction parser in SPI mode. [read-only for read-only instructions] [Duration: instant - fast.]

Inputs: instruction (required), timeout.

spi_writeA
Destructive

Write data to SPI flash (firmware menu 6): from a file, hex string, or ASCII string. DANGEROUS: overwrites flash. [approval-write] [Duration: fast - slow (depends on size).]

Inputs: address (required), _confirmed (required), data_hex, auto_erase, +2 more.

verify_connectionA

Check for signal activity on specified pins. User must provide pin mapping. [read-only] [Duration: fast (~2 s -- samples for sample_duration_ms, default 2000).]

Inputs: rx_pin (required), tx_pin (required), sample_duration_ms.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 33 tools

    Disambiguation3/5

    The per-protocol grouping keeps most tools distinct, but flash reading is split across three overlapping entry points (read_flash via esptool/UART bridge, spi_dump via firmware shell, spi_read/spi_flash_search/spi_flash_strings for regions and analysis) and an agent could easily pick the wrong path or protocol family. Detailed descriptions and duration hints help, but the boundaries are only resolvable by careful reading of mechanism (bridge vs shell vs on-device analyzer).

    Naming Consistency3/5

    Most tools follow a readable prefix_verb pattern (open_spi, spi_read, i2c_write, close_uart), but the convention drifts: 'onewire_*' vs 'close_1wire', and an inconsistent 'spi_*' versus 'spi_flash_*' split that mixes raw-shell ops with whole-chip analysis ops. It remains interpretable but is not a single predictable pattern.

    Tool Count3/5

    33 tools is heavy, but the breadth is largely earned by four protocol families (SPI, I2C, UART, 1-Wire) plus power control, each needing open/close and a handful of operations. Still, the SPI family alone consumes 13 tools with visible redundancy (spi_dump vs read_flash vs spi_read), so trimming would improve the surface.

    Completeness4/5

    Each protocol has session open/close plus the expected read/write/scan operations, and there is power control, device discovery, and download-mode entry, so the hardware-engagement lifecycle is well covered. Minor gaps: no region-scoped erase (only full-chip spi_flash_erase with spi_write overwrite), no session listing/teardown-all, and no general GPIO manipulation beyond the hardcoded download-mode sequence.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for BusPirate 6 hardware security testing. Exposes UART, SPI, I2C, 1-Wire, power supply, GPIO, and logic analyzer operations as tools.
      2
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Agentic Hardware-in-the-Loop (Agentic HIL) lets coding agents develop firmware on real embedded boards: flash, reset, read UART and exchange CAN traffic, diagnose and fix. Local, policy-gated MCP tools support OpenOCD, pyOCD and STM32CubeProgrammer, with pytest for CI.
      44
      943 PyPI
      37
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to interact with physical embedded target boards over a dual-CDC USB bridge using MCP tools. It exposes console reading, pattern waiting, command sending, reboot/login state machines, and in-RAM MicroPython execution while a single-owner daemon safely arbitrates access to the serial devices.
      6
      4
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes 238 schema-typed tools over streamable-HTTP MCP that let a client drive a Flipper Zero, an AWOK Biscuit (ESP32-C5) and an ESP32 Marauder — scanning, screen mirroring, storage, and other device operations — from natural-language or direct tool calls. Transmit/attack tools stay behind an explicit human confirmation gate.
      MIT