AR

Arduino ESP32 MCP Server for Claude AI Robotics

Deploy an MCP server to connect Claude AI with Arduino ESP32 for AI-powered robotics, real-world automation, and interactive robot control.

Overview

This project implements an MCP (Model Context Protocol) server that runs on an Arduino ESP32 and enables bidirectional integration between Claude AI (or any language model / orchestration layer that speaks MCP) and a physical robot or embedded system. The ESP32 hosts a lightweight MCP-compliant endpoint that accepts structured tool calls (JSON), maps them to local hardware actions (motors, servos, sensors), and returns telemetry and execution results back to the model. This creates a low-latency, secure bridge from language-level reasoning to real-world actuation.

For developers building AI-driven robotics, the ESP32 MCP server simplifies the “last hop” of model-driven automation: instead of hard-coding control logic on the microcontroller, the MCU exposes a small set of actuators/sensors as tools. Claude (or another MCP-capable controller) can then call those tools as part of an application workflow. The pattern is useful for interactive robots, teleoperation, real-world automation, and experimentation with embodied AI without re-implementing control glue on the model side.

Features

  • MCP-compatible server on Arduino ESP32 for tool-oriented control
  • JSON-based tool invocation and telemetry responses
  • Wi‑Fi networking (HTTP/WebSocket/TCP variants supported depending on build)
  • Example tool implementations: motor control, servo positioning, sensor reads, digital I/O
  • Simple configuration via header-config file or environment variables
  • OTA-friendly build for iterative development (PlatformIO / Arduino IDE)
  • Minimal dependencies so it runs on standard ESP32 boards

Installation / Configuration

Prerequisites:

  • ESP32 development board
  • Arduino IDE or PlatformIO
  • Git, USB cable
  • (Optional) A host machine running Claude or another MCP orchestrator

Clone the repository:

git clone https://github.com/vishalmysore/choturobo.git
cd choturobo

Open the project with PlatformIO or Arduino IDE. Example PlatformIO usage:

; platformio.ini (excerpt)
[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

Configure network and server settings in src/config.h (or edit the example secrets.h):

// src/config.h
#pragma once
#define WIFI_SSID "your-ssid"
#define WIFI_PASS "your-password"

// TCP/HTTP server config
#define MCP_PORT 8080
#define MCP_USE_WEBSOCKET true  // set false to use plain HTTP/TCP

Example build and upload (PlatformIO):

pio run -e esp32dev -t upload
pio device monitor -b 115200

By default the MCP server binds to the configured port and prints its IP on startup. The server accepts JSON tool calls and returns JSON responses. Adjust pins in src/hardware.h to match your wiring.

Available Tools / Resources

The repository contains example tool implementations you can extend:

  • motor: start/stop, set speed, set direction
  • servo: set angle (0–180)
  • digital: read/write GPIO pins
  • analog: read ADC channels
  • sensor: sample sensor modules (ultrasonic, IMU, etc.)
  • telemetry: query runtime status (uptime, Wi‑Fi RSSI, memory)

Example JSON request (tool call):

{
  "id": "call-001",
  "tool": "motor",
  "action": "drive",
  "params": { "speed": 120, "direction": "forward", "duration_ms": 2000 }
}

Example JSON response:

{
  "id": "call-001",
  "status": "ok",
  "result": { "completed": true, "elapsed_ms": 2003 }
}

If using HTTP, POST requests to http://:8080/mcp are accepted. For WebSocket builds, connect your orchestration service as a persistent channel for streaming requests and responses.

Use Cases

  • Interactive teleoperation: Claude generates high-level commands (“approach the red object, stop 20 cm away”). The orchestrator translates intent into MCP tool calls to motor and distance sensor tools on the ESP32, receiving sensor telemetry for closed-loop behavior.
  • Physical agent experiments: Rapidly prototype embodied behaviors by exposing only a few safe tools (e.g., move, stop, set_arm). The model can be trained or prompted to compose those tools into complex tasks without changing microcontroller firmware.
  • Real-world automation: Use Claude to implement conditional workflows (if temperature > X, trigger fan). The ESP32 reports sensor readings and executes actuator commands triggered by the model.
  • Remote monitoring and diagnostics: The telemetry tool returns memory, Wi‑Fi signal, and sensor status for remote troubleshooting and logging.
  • Education and demos: Teach model-to-robot integration using a small, reproducible codebase. Students can modify tools and observe model-driven control in real time.

Tips for Developers

  • Start by enabling only safe tools to prevent unintended behavior (limit durations, force speed caps).
  • Use short, idempotent tool calls for robust retries (avoid long blocking operations inside handlers).
  • Add authentication or use a secured network for deployments that expose the ESP32 to model orchestration services.
  • Extend tools to return structured telemetry so your orchestration layer can perform verification and error handling.

Repository and source code: https://github.com/vishalmysore/choturobo