# PlatformIO [Health: Active]

**Category:** 📟 Embedded System  
**Repository:** https://github.com/powerdragonfire/platformio.mcp  
**GitHub Stars:** 10  
**Views:** 9  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/platformio

## Description
PlatformIO for AI agents: build, flash, serial monitor, tests, crash decoding, size reports.

## Tools
Capabilities this server exposes over MCP:

- **pio_system_info** — Check that PlatformIO is installed and report its version, core directory, the active safety policy (full | build_only | read_only), the log directory, any open serial monitor sessions, and the globally installed platforms and tool packages (name, version, path), which works without a project. Call this first in a session; if PlatformIO is missing the result tells you how to install it.
- **pio_list_boards** — Search PlatformIO's board catalogue (~1,700 boards). Query matches board id, name, MCU, or vendor, e.g. 'esp32-s3', 'uno', 'STM32F4', 'DOIT'. Returns board ids plus MCU, clock, RAM, flash, and frameworks. Use the returned `id` in platformio.ini or pio_project_init.
- **pio_board_info** — Full details for one board id: MCU, clock, RAM and flash sizes in bytes, supported frameworks, connectivity, and debug probes. Use it to learn memory limits before writing code.
- **pio_project_init** — Create a new PlatformIO project (or add an environment to an existing one) with `pio project init`. Give an absolute project_dir, a board id from pio_list_boards, and optionally a framework (arduino, espidf, stm32cube, zephyr, ...). project_options are extra platformio.ini keys like 'monitor_speed=115200' or 'lib_deps=bblanchon/ArduinoJson'. Never hand-write platformio.ini for a new project; use this.
- **pio_project_envs** — Read platformio.ini and list every environment with its board, platform, framework, monitor/upload settings, lib_deps, and build_flags, plus which envs are default. Cheap; call before building or flashing.
- **pio_project_metadata** — Computed build metadata per environment: defines, include paths, compiler paths and flags, library dirs. Useful for understanding what the compiler actually sees. Triggers platform/toolchain install on first use.
- **pio_build** — Compile the project (`pio run`). Returns a status, parsed compiler errors and warnings with file/line/column, RAM and Flash usage percentages, the last 40 lines of output, and a path to the full log. Fix the listed errors, then build again. First builds may take minutes while toolchains download. Pass envs=[...] to build several environments in one call, one after another; the result lists ok, status, errors and memory per env and keeps going when one env fails.
- **pio_upload** — Build and flash firmware to the connected board (`pio run -t upload`). Refuses while a serial monitor session holds the port unless stop_open_sessions=true, which closes our own session(s) first. Pass upload_port when several boards are attached. Port failures come back classified (port_busy, port_permission, port_missing, no_response) with a port_diagnosis naming the holder and the fix. Blocked when PLATFORMIO_MCP_POLICY is build_only or read_only.
- **pio_clean** — Delete build artifacts for an env (`pio run -t clean`); full=true also removes downloaded dependencies (fullclean).
- **pio_list_targets** — List extra build targets the platform offers for this project, such as buildfs, uploadfs, erase, size, or menuconfig.
- **pio_run_target** — Run one named target from pio_list_targets (e.g. 'buildfs', 'uploadfs', 'erase', 'size'). Flash-related targets follow the same policy, stop_open_sessions, and port-diagnosis rules as pio_upload.
- **pio_list_devices** — List serial ports (`pio device list`) and flag which ones look like USB dev boards (CP210x, CH340, FTDI, ESP, Arduino, ST-Link...). Use the port with pio_upload, pio_monitor_start, or pio_monitor_capture.
- **pio_port_diagnose** — Explain why a serial port is unusable before or after a failed upload: whether it exists, whether one of our monitor sessions holds it, which other process has it open (lsof/fuser on macOS and Linux), and read/write permission, plus the concrete fix. Port defaults from platformio.ini or the single detected board. Reports only; it never closes anything.
- **pio_monitor_start** — Open a background serial monitor session and return a session_id. Port and baud default from platformio.ini (monitor_port/monitor_speed) when project_dir is given, else the single detected dev board and 115200. Output is buffered (ring buffer, max_lines); read it with pio_monitor_read. The session holds the port, so stop it before pio_upload.
- **pio_monitor_read** — Read new serial lines from a session since `cursor` (start at 0) and get the next cursor back. Set wait_for to a regex to block up to timeout_s until a matching line arrives (e.g. wait_for='setup done|Guru Meditation'). Without wait_for and with timeout_s>0 it waits for at least one new line. When wait_for never matches the result is ok=false with error=pattern_timeout (or session_closed), plus the lines seen so far and a cursor to continue from.
- **pio_monitor_write** — Send text to the device over the open session's serial port (newline appended by default). Blocked under build_only/read_only policy.
- **pio_monitor_stop** — Close a serial monitor session and release the port.
- **pio_monitor_list** — List open serial monitor sessions with port, baud, buffered line count, and next cursor.
- **pio_monitor_capture** — One-shot serial capture with no session to manage: open the port, collect output for up to `seconds` (or until regex `until` matches), close the port, and return the lines. Ideal right after pio_upload to grab the boot log.
- **pio_test** — Run PlatformIO unit tests (`pio test`, Unity framework) and return per-case pass/fail with file, line, and message. Tests live in test/test_<name>/. Native envs run on the host; embedded envs build, flash, and read results over serial (set without_uploading=true to only build them). filter/ignore take glob patterns like 'test_math*'.
- **pio_check** — Static analysis (`pio check`, cppcheck by default; clangtidy/pvs-studio if configured). Returns defects grouped and sorted by severity with file, line, CWE, and message. severity is the minimum level to report (low|medium|high).
- **pio_pkg_search** — Search the PlatformIO registry for libraries (default), platforms, or tools. Returns owner/name specs with the latest version and description. Example query: 'ArduinoJson', 'ssd1306 display', 'mqtt'.
- **pio_pkg_install** — Install a library/platform/tool into the project and add it to platformio.ini (`pio pkg install -l spec`). spec examples: 'bblanchon/ArduinoJson@^7', 'adafruit/Adafruit NeoPixel', 'https://github.com/user/repo.git'. Restrict to one env with env=.
- **pio_pkg_uninstall** — Remove a library/platform/tool from the project and platformio.ini.
- **pio_pkg_list** — List resolved platform, toolchain, and library packages for the project with versions.
- **pio_pkg_outdated** — Show which project dependencies have newer versions available.
- **pio_pkg_update** — Update dependencies within the version ranges declared in platformio.ini.
- **pio_decode_backtrace** — Turn a crash dump into source locations. Give `text` containing an ESP32/ESP-IDF 'Guru Meditation' register dump and 'Backtrace: 0x...:0x...' line, a RISC-V ESP32 (C2/C3/C5/C6/C61/H2/H4/P4/S31) MEPC/RA register dump with its 'Stack memory:' block, or a Cortex-M HardFault pc/lr dump, or give `session_id` of an open monitor session to scan its buffer. Xtensa and Cortex-M addresses are resolved with the toolchain's addr2line; RISC-V stacks are unwound with the toolchain's GDB into a full call chain (method=gdb_unwind), or, without GDB, stack words pointing into code are resolved (method=stack_scan, may include stale frames). Returns function, file, line per frame, plus the crash cause and reset reason. The ELF must be from the same build that was flashed.
- **pio_size_report** — Explain where flash and RAM go in the built firmware.elf: text/data/bss totals with percent of the board's flash and RAM, loaded sections classified as flash/ram, the biggest symbols (demangled, with file:line), and per-source-file totals. Use it to shrink firmware on purpose: drop the largest fonts/tables, remove unused features, tune build flags. Run pio_build first; `filter` is a regex applied to symbol names and file paths.
- **pio_flash_and_verify** — Hardware-in-the-loop check with no human: build + flash (`pio run -t upload`), then open the serial port and watch the boot log until `expect` (regex) matches -> verdict pass, or `fail_on` matches -> verdict fail with the crash automatically decoded to file:line, or timeout_s elapses -> verdict timeout. Port and baud come from platformio.ini (monitor_port/monitor_speed) or the single detected board. Set expect to a line your firmware prints once it is healthy, e.g. 'WiFi connected'. Blocked under build_only/read_only policy.
- **pio_test_plan_validate** — Validate a declarative hardware test plan JSON file before execution. Checks required fields for a serial assertion workflow (project, success/failure patterns, timeout, observation window, iteration count) and returns the normalized plan.
- **pio_test_plan_start** — Start a repeatable hardware test-plan run in the background. Each iteration can upload firmware, monitor serial output for pass/fail assertions, keep observing after success for the configured window, classify outcomes, and write a machine-readable report with evidence paths.
- **pio_test_plan_status** — Read test-plan run progress and results: run status, pass/fail/timeout/infrastructure-error counts, firmware/source/device identity, and recent or full per-iteration outcomes with evidence references.
- **pio_test_plan_cancel** — Request explicit cancellation of an in-progress test-plan run by run_id. The active iteration stops at its next safe check and the run is finalized as cancelled with completed iteration evidence retained.
- **pio_upload_ota** — Flash firmware over Wi-Fi to an ESP32/ESP8266 running ArduinoOTA (espota). Give `host` (IP or name.local); port defaults to 3232 (ESP32) / 8266 (ESP8266) and `auth` is the ArduinoOTA password. By default it resolves and pings the host first, then runs `pio run -t upload --upload-port <host>` so the image matches the current build; build=false sends the existing .pio/build/<env>/firmware.bin with espota.py directly. filesystem=true sends the SPIFFS/LittleFS image instead. Failures are mapped to what to fix: no_response (ArduinoOTA.handle not running), auth_failed, no_callback (firewall), device_rejected (partition table has no OTA slot). Blocked under build_only/read_only policy.
- **pio_partition_table** — Validate the ESP32 flash layout before it bites. Reads the partition CSV the env uses (board_build.partitions, project partitions.csv, or the Arduino framework default), checks alignment, overlaps, fit against the chip's flash size, OTA slot/otadata consistency, nvs/coredump presence, whether the built firmware.bin fits the smallest app slot, and whether the build dir's partitions.bin is stale. With read_device=true it also reads the live table at 0x8000 over serial (esptool) and diffs it against the CSV, catching the silent-corruption case where an app-only flash left an old table on the chip. Returns partitions plus issues with fixes.
- **pio_coredump** — Pull the ESP32 core dump out of the coredump flash partition after a crash (esptool read_flash) and save it. When the optional esp-coredump analyzer is installed (`platformio.mcp[coredump]`), it runs `esp-coredump info_corefile` against the env's firmware.elf with the toolchain's gdb and returns the crashed task, reason, registers, and backtrace. Reports clearly when the partition is erased (no crash recorded) or the analyzer is missing. Stop monitor sessions on the port first.
- **pio_power_profile** — Measure the device's current draw for `seconds` and report average/min/max/p95 mA, energy (mWh and µAh when voltage is known), a bucketed timeline, the share of time in sleep vs active (threshold auto-detected from the two dominant current levels, or `sleep_threshold_ma`), and a battery-life estimate. source='serial' reads a meter streaming readings on `port` (INA219/INA226 sketch, USB power meter log; `pattern` regex with (?P<value>) and optional (?P<unit>)/(?P<voltage>) groups, default: first number with uA/mA/A). source='ppk2' drives a Nordic Power Profiler Kit II (needs the `power` extra). Set `trigger` + `trigger_session_id` to start measuring when the firmware prints a line.
- **pio_deps_check** — Audit the project's library dependencies before they bite: compares lib_deps against what is installed in .pio/libdeps/<env>, lib/, and lib_extra_dirs, and reports name collisions (two libraries with the same name, where lib_deps order silently decides which one wins), unpinned specs, declared-but-missing and leftover libraries, and circular dependencies between manifests. build=true also runs `pio run` and returns the LDF dependency graph as a tree, flagging a RecursionError as a cycle. Each issue carries a severity, message, and a concrete fix.
- **pio_memory_watch** — Watch serial output for heap and stack telemetry and diagnose leaks, fragmentation, and stack headroom. Give session_id of an open monitor session (its buffer plus `seconds` more) or a port for a one-shot capture. Understands Arduino-ESP32 'Free heap: N min: N largest: N', ESP.getFreeHeap() prints, ESP-IDF heap_caps_print_heap_info blocks, FreeRTOS vTaskList tables, and uxTaskGetStackHighWaterMark lines; `pattern` (regex with a (?P<value>) group) adds a custom metric. Returns per-metric min/max/trend with a stable/shrinking/growing verdict, a per-task stack table flagged below stack_warn_bytes, and a fragmentation hint. When the firmware prints nothing usable, instrumentation_hint has copy-paste snippets.
- **pio_debug_start** — Open a live gdb session on the board through its debug probe (`pio debug --interface=gdb`, GDB/MI over pipes): starts the debug server (OpenOCD, J-Link, ST-Link, esp-prog, ...) from `debug_tool` in platformio.ini, builds a debug firmware, loads it (load=true) and halts at `debug_init_break` (default: main). Returns session_id, the .pioinit script PlatformIO generated, and the initial stop frame. The session holds the probe: stop it (pio_debug_stop) before pio_upload or pio_flash_and_verify. Blocked under build_only/read_only policy.
- **pio_debug_cmd** — Send one gdb command to an open debug session and get its output back, parsed from GDB/MI: `bt`, `p var`, `p/x reg`, `info locals`, `info registers`, `x/16xw addr`, `break src/main.cpp:42`, `watch counter`, `next`, `step`, `finish`, `continue`, `monitor reset halt`, or raw MI such as `-stack-list-frames`. Execution commands (continue/next/step/finish) block until the target stops again or timeout_s passes; on timeout the target keeps running and `interrupt` halts it. Returns result_class, console lines, error, and stopped {reason, frame{function,file,line}}.
- **pio_debug_stop** — Quit gdb and the debug server, resume the target, and free the probe so pio_upload works again.
- **pio_debug_list** — List open debug sessions with env, debug tool, running/halted state, and the last stop frame.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "platformio": {
    "command": "uvx",
    "args": ["platformio.mcp"]
  }
}
```

## Documentation

## What PlatformIO MCP server does

PlatformIO MCP server exposes PlatformIO workflows as MCP tools for embedded development. It covers project creation, board discovery, environment inspection, builds, uploads, cleaning, target execution, dependency management, unit tests, static analysis, serial communication, crash decoding, and firmware size analysis.

Board discovery searches PlatformIO's catalogue by identifiers such as MCU, vendor, or board name and returns hardware details including memory, clock speed, supported frameworks, connectivity, and debug probes. Project tools can create a new environment with `pio project init`, read `platformio.ini`, and calculate the compiler definitions, include paths, flags, and library directories used by a build.

## How it works

The server runs PlatformIO commands and returns concise summaries alongside structured results. Build responses include parsed errors and warnings with source locations, RAM and flash usage, recent output, and a path to the complete log. Long output is kept in log files under `~/.platformio-mcp/logs`, with the newest 200 files retained.

Serial monitoring supports both managed background sessions and one-shot captures. A session has a session ID, buffered output, cursor-based reads, optional regular-expression waits, and explicit stop operations. Upload and monitoring tools coordinate access to serial ports, and diagnosis can identify missing ports, permission problems, monitor sessions, or other processes holding a port.

`pio_flash_and_verify` combines firmware upload with boot-log observation. It returns a pass result when an expected expression appears, a failure when a configured crash pattern appears, or a timeout when neither condition occurs. Backtrace decoding resolves supported ESP32 and Cortex-M crash information against the matching firmware ELF.

## Setup and configuration

The package requires Python 3.12 or newer and `uv`. Install it with the package's `uvx platformio.mcp install` command, selecting a supported client such as Claude Code, Claude Desktop, Cursor, Codex, Windsurf, or another MCP client. The installation can also bundle PlatformIO Core with `--with-platformio`; otherwise, the server finds `platformio` or `pio` on `PATH` or in `~/.platformio/penv`.

For clients without a dedicated installer, generate an MCP configuration with `uvx platformio.mcp install --print`. The standard stdio entry uses `uvx` to launch `platformio.mcp`. `PLATFORMIO_MCP_PIO` can point to a specific PlatformIO executable. `PLATFORMIO_MCP_POLICY` controls hardware-changing operations with `full`, `build_only`, or `read_only` modes.

## Tools and capabilities

- Discover PlatformIO installation details, boards, devices, project environments, and build metadata.
- Initialize projects, install or remove packages, inspect dependencies, and update packages within declared version ranges.
- Build, clean, upload, run extra PlatformIO targets, and report compiler diagnostics and resource usage.
- Start, read, write to, capture, diagnose, list, and stop serial monitor sessions.
- Run Unity tests and static analysis with per-case results or severity-sorted defects.
- Decode crash backtraces and produce flash/RAM size reports with symbols and source locations.

## Limitations and notes

PlatformIO must be installed locally unless it is bundled during installation. Initial builds may take several minutes while platforms and toolchains download. The ELF used for crash decoding must come from the same build as the firmware on the device. Uploading, serial writes, and other flash-related operations are blocked by `build_only` and `read_only` policies. A serial monitor session holds its port and must be stopped before uploading, unless the upload operation is allowed to close the server's own sessions.

_Full upstream README: https://allmcps.com/mcp/platformio/readme_

