BLEMCPServer is a lightweight Model Context Protocol (MCP) server implementation for ESP32 that communicates over Bluetooth Low Energy (BLE). It exposes MCP tools via JSON-RPC, supports message fragmentation/reassembly for BLE MTU constraints, and provides a practical WiFi provisioning demo. The library focuses exclusively on BLE transport, making it suitable for embedded devices where WiFi or HTTP transports are unnecessary or too heavy.
- Project Title & Badges
- Description
- Prerequisites & Installation
- Usage
- Configuration
- Project Structure
- Testing
- Deployment
- Built With
- Contributing
- License
- Acknowledgments
- ESP32 (tested with ESP32-S3)
- PlatformIO (recommended) or Arduino IDE
- Python (for PlatformIO)
- Git
git clone git@github.com:solnera/BLEMCPServer.git
cd BLEMCPServerDependencies are managed via platformio.ini in the example projects and include:
- h2zero/NimBLE-Arduino
- bblanchon/ArduinoJson
Install and build:
cd examples/config_wifi
pio runcd examples/config_wifi
pio run -t upload
pio device monitor- Connect to the BLE device (default name:
MCP_Server_BLE). - Use the MCP JSON-RPC API to discover tools and call them.
{"jsonrpc":"2.0","id":1,"method":"tools/list"}{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"config_wifi","arguments":{"ssid":"YOUR_SSID","password":"YOUR_PASSWORD"}}}{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_status","arguments":{}}}The BLE transport uses the following service/characteristics:
- Service UUID:
00001999-0000-1000-8000-00805F9B34FB - RX UUID:
4963505F-5258-4000-8000-00805F9B34FB(client writes) - TX UUID:
4963505F-5458-4000-8000-00805F9B34FB(server notifies)
The server name, version, and instructions are configured when creating BLEMCPServer in the example:
BLEMCPServer mcpServer("ESP32-MCP-BLE", "1.0.0", "MCP WiFi configuration tool");WiFi credentials are sent over MCP via config_wifi and validated on-device. The example logs connection status to the serial monitor.
The default BLE device name is MCP_Server_BLE. To customize it, initialize BLE before starting the MCP server:
McpBle::getInstance().init("Your_Device_Name");
mcpServer.begin();.
├── examples/
│ └── config_wifi/ # WiFi provisioning demo using MCP tools
├── include/ # Public headers (BLEMCPServer, McpBle, transport API)
├── src/ # Core implementation (BLEMCPServer, BLE, transport)
├── library.json # PlatformIO library manifest
No automated test suite is included yet. Validation is currently performed by flashing the example to an ESP32 device and exercising the MCP tools over BLE.
Deployment consists of flashing the firmware to an ESP32 device. No cloud or server deployment is required.
- ESP32 Arduino Framework
- NimBLE-Arduino
- ArduinoJson
- FreeRTOS (ESP32 SDK)
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes with clear messages
- Push to your fork and open a Pull Request
Please open issues for bug reports or feature requests with clear reproduction steps.
MIT License. See library.json for license metadata.
- NimBLE-Arduino for BLE stack support
- ArduinoJson for efficient JSON handling
- The MCP community and reference implementations for protocol alignment