esp32 server
A lightweight Model Context Protocol (MCP) server framework for ESP32. Seamlessly connect embedded devices to LLMs.
claude mcp add --transport stdio solnera-esp32-mcpserver uvx solnera-esp32-mcpserver \ --env PORT="3000" \ --env WIFI_SSID="Your WiFi SSID" \ --env WIFI_PASSWORD="Your WiFi password"
How to use
This ESP32 MCP server implements the MCP JSON-RPC 2.0 protocol over HTTP, allowing LLMs and agents to discover and execute tools exposed by the device. The server focuses on lightweight, on-device interaction with hardware capabilities via a defined tool API. Tools are registered with metadata and input schemas, enabling robust validation and structured parameter passing. To operate, the ESP32 hosts an MCP server that presents an endpoint (typically /mcp) for MCP traffic. An LLM can initialize a session, request a list of available tools using tools/list, and invoke a tool using tools/call with the appropriate parameters. The echo example in the repository demonstrates how a tool is defined, registered, and called, returning structured results such as echoed text and metadata like length and timestamp. This enables you to integrate hardware-facing functionality (sensors, actuators, etc.) into LLM-driven workflows while keeping the processing on-device for privacy and responsiveness.
How to install
Prerequisites:
- ESP32 development board
- Computer with PlatformIO installed (recommended) or Arduino IDE
- Basic familiarity with ESP32 development workflow
Installation steps:
- Install PlatformIO Core (if not using the IDE):
- macOS/Linux: curl -fsSL https://platformio.org/install/cli | sh
- Windows: Install PlatformIO IDE from the official website
- Open PlatformIO and clone the repository (or create a new PlatformIO project and copy the files):
- git clone https://github.com/yourusername/esp32-mcpserver.git
- Open the project in PlatformIO
- Install dependencies and libraries via PlatformIO (PlatformIO handles ArduinoJson, ESPAsyncWebServer, AsyncTCP automatically via platformio.ini)
- Configure WiFi in src/main.cpp (see configuration section below)
- Build and upload to your ESP32:
- In PlatformIO, click Build, then Upload, or use the command line: platformio run --target upload
Configuration basics:
- Ensure your ESP32 is connected to your WiFi network by editing the credentials in src/main.cpp (ssid and password).
Additional notes
Tips and caveats:
- The server exposes MCP methods: initialize, notifications/initialized, tools/list, and tools/call. Ensure your LLM or agent is aware of the session handling as MCP may include session IDs.
- Tools are defined with JSON Schema validation to enforce proper input/output shapes. Extend your tool metadata and schemas as needed.
- If you encounter issues with network connectivity, double-check the ESP32’s IP address and ensure the device is reachable from the network where your orchestrator runs.
- While this ESP32 server uses ESPAsyncWebServer for non-blocking operation, ensure proper memory management on constrained devices, especially when handling large JSON payloads.
- For debugging, connect to the serial console to view logs during initialization and tool registration.
Related MCP Servers
mcp-for-beginners
This open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
Remote
A type-safe solution to remote MCP communication, enabling effortless integration for centralized management of Model Context.
PolyMCP
Polymcp provides a simple and efficient way to interact with MCP servers using custom agents
mcp-streamable-http
Example implementation of MCP Streamable HTTP client/server in Python and TypeScript.
mcp
🤖 Taskade MCP · Official MCP server and OpenAPI to MCP codegen. Build AI agent tools from any OpenAPI API and connect to Claude, Cursor, and more.
mcp-typescript-sdk
A TypeScript SDK for implementing Model Context Protocol (MCP) over MQTT, supporting both browser and Node.js environments.