PlatformIO MCP Server
A board-agnostic Model Context Protocol (MCP) server for PlatformIO embedded development. This server enables AI agents like Cline to interact with PlatformIO's comprehensive ecosystem of 1,000+ development boards across 30+ platforms.
Features
- ๐ Universal Board Support: Works with any board supported by PlatformIO (ESP32, Arduino, STM32, nRF52, RP2040, and many more)
- ๐ ๏ธ Complete Development Workflow: Initialize projects, build firmware, upload to devices, and monitor serial output
- ๐ Library Management: Search, install, and manage libraries from the PlatformIO registry
- ๐ฏ Device Discovery: Automatically detect connected development boards
- โก Board-Agnostic Architecture: No hardcoded board configurations - supports all PlatformIO platforms out of the box
Supported Platforms
PlatformIO supports 30+ embedded platforms including:
- Espressif: ESP32, ESP8266
- Arduino: Uno, Mega, Nano, Due
- STMicroelectronics: STM32, STM8
- Nordic: nRF51, nRF52
- Raspberry Pi: RP2040 (Pico)
- Teensy: All Teensy boards
- Atmel: AVR, SAM, megaAVR
- NXP: i.MX RT, LPC
- Microchip: PIC32
- TI: MSP430, TIVA
- RISC-V: SiFive, GAP
- And many more!
Prerequisites
- Node.js >= 18.0.0
- PlatformIO Core CLI: Install from https://platformio.org/install/cli
Installing PlatformIO CLI
# Using pip (recommended)
pip install platformio
# Or using Homebrew (macOS)
brew install platformio
# Verify installation
pio --version
Installation
# Clone or download this repository
git clone https://github.com/yourusername/platformio-mcp-server.git
cd platformio-mcp-server
# Install dependencies
npm install
# Build the server
npm run build
MCP Tools
The server exposes 11 MCP tools for comprehensive embedded development:
Board Discovery
list_boards
Lists all available PlatformIO boards with optional filtering.
Parameters:
filter(optional): Filter by platform, framework, or MCU (e.g., "esp32", "arduino", "stm32")
Example:
{
"filter": "esp32"
}
get_board_info
Gets detailed information about a specific board.
Parameters:
boardId(required): Board ID (e.g., "esp32dev", "uno", "nucleo_f401re")
Example:
{
"boardId": "esp32dev"
}
Device Management
list_devices
Lists all connected serial devices for firmware upload and monitoring.
Parameters: None
Project Operations
init_project
Initializes a new PlatformIO project with specified board and framework.
Parameters:
board(required): Board IDframework(optional): Framework (e.g., "arduino", "espidf", "mbed")projectDir(required): Project directory pathplatformOptions(optional): Additional platform options
Example:
{
"board": "esp32dev",
"framework": "arduino",
"projectDir": "/path/to/my-project"
}
build_project
Compiles the project and generates firmware binary.
Parameters:
projectDir(required): Path to project directoryenvironment(optional): Specific environment from platformio.ini
Example:
{
"projectDir": "/path/to/my-project"
}
clean_project
Removes build artifacts from the project.
Parameters:
projectDir(required): Path to project directory
upload_firmware
Uploads compiled firmware to a connected device.
Parameters:
projectDir(required): Path to project directoryport(optional): Upload port (auto-detected if not specified)environment(optional): Specific environment from platformio.ini
Example:
{
"projectDir": "/path/to/my-project",
"port": "/dev/ttyUSB0"
}
start_monitor
Provides instructions and command for starting serial monitor.
Parameters:
port(optional): Serial portbaud(optional): Baud rate (e.g., 115200)projectDir(optional): Project directory
Library Management
search_libraries
Searches the PlatformIO library registry.
Parameters:
query(required): Search querylimit(optional): Maximum results (default: 20)
Example:
{
"query": "wifi",
"limit": 10
}
install_library
Installs a library from the PlatformIO registry.
Parameters:
library(required): Library name or IDprojectDir(optional): Project directory (installs globally if not specified)version(optional): Specific version (e.g., "1.0.0")
Example:
{
"library": "ArduinoJson",
"projectDir": "/path/to/my-project",
"version": "^6.21.0"
}
list_installed_libraries
Lists installed libraries (globally or for a project).
Parameters:
projectDir(optional): Project directory (lists global libraries if not specified)
Usage with Cline
Install the server following the installation instructions above
Configure Cline to use this MCP server (add to your Cline configuration)
Start developing! Use natural language to interact with PlatformIO:
- "List all ESP32 boards"
- "Create a new project for Arduino Uno"
- "Build my project at /path/to/project"
- "Upload firmware to my ESP32"
- "Search for WiFi libraries"
Development
# Development mode with auto-reload
npm run dev
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Lint code
npm run lint
# Format code
npm run format
Project Structure
platformio-mcp/
โโโ src/
โ โโโ index.ts # Main MCP server
โ โโโ types.ts # TypeScript type definitions
โ โโโ platformio.ts # PlatformIO CLI wrapper
โ โโโ tools/ # MCP tool implementations
โ โ โโโ boards.ts # Board discovery tools
โ โ โโโ devices.ts # Device listing tools
โ โ โโโ projects.ts # Project initialization
โ โ โโโ build.ts # Build operations
โ โ โโโ upload.ts # Firmware upload
โ โ โโโ monitor.ts # Serial monitor
โ โ โโโ libraries.ts # Library management
โ โโโ utils/ # Utility functions
โ โโโ validation.ts # Input validation
โ โโโ errors.ts # Error handling
โโโ tests/ # Test files
โโโ package.json
โโโ tsconfig.json
โโโ README.md
Example Workflows
Create and Upload ESP32 Project
// 1. List ESP32 boards
await listBoards("esp32");
// 2. Initialize project
await initProject({
board: "esp32dev",
framework: "arduino",
projectDir: "/path/to/esp32-blink"
});
// 3. Build project
await buildProject("/path/to/esp32-blink");
// 4. Upload firmware
await uploadFirmware("/path/to/esp32-blink");
// 5. Start serial monitor
await startMonitor();
Search and Install Libraries
// Search for libraries
const libraries = await searchLibraries("ArduinoJson", 10);
// Install library to project
await installLibrary("ArduinoJson", {
projectDir: "/path/to/my-project",
version: "^6.21.0"
});
Troubleshooting
PlatformIO Not Found
If you get "PlatformIO CLI not found" errors:
- Install PlatformIO:
pip install platformio - Verify installation:
pio --version - Ensure
pioorplatformiois in your system PATH
Board Not Found
- Check board ID spelling (case-sensitive)
- List available boards:
pio boards - Search at https://docs.platformio.org/en/latest/boards/
Upload Failures
- Ensure device is connected and powered
- Check USB cable and drivers
- Verify correct port (use
list_devicestool) - Try resetting the device
- Close other programs using the serial port
Build Errors
- Check source code for syntax errors
- Ensure required libraries are installed
- Verify platformio.ini configuration
- Try cleaning:
pio run -t clean
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
MIT License - see LICENSE file for details.
Links
- PlatformIO: https://platformio.org
- PlatformIO Boards: https://docs.platformio.org/en/latest/boards/
- PlatformIO Libraries: https://registry.platformio.org
- Model Context Protocol: https://modelcontextprotocol.io
- Cline: https://github.com/cline/cline
Support
For issues and questions:
- Open an issue on GitHub
- Check PlatformIO documentation: https://docs.platformio.org
- Join PlatformIO community: https://community.platformio.org