Chotu Robo Server is an MCP (Model Context Protocol) server that enables communication between artificial intelligence and Arduino-based robots. The server allows you to control hardware components like LEDs, motors, servos, and sensors through AI commands, creating an interface between digital intelligence and physical robotics.
npm install johnny-five
npm install @modelcontextprotocol/sdk
// Basic ESP32 web server code for Chotu Robo
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
WebServer server(80);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.begin();
}
void loop() {
server.handleClient();
}
void handleRoot() {
server.send(200, "text/plain", "Chotu Robo Server Running");
}
// Basic Arduino Nano code for Chotu Robo
void setup() {
Serial.begin(115200);
// Setup pins for hardware components
pinMode(13, OUTPUT); // LED pin
}
void loop() {
if (Serial.available() > 0) {
String command = Serial.readStringUntil('\n');
processCommand(command);
}
}
void processCommand(String command) {
// Process serial commands
if (command == "LED_ON") {
digitalWrite(13, HIGH);
Serial.println("LED turned ON");
} else if (command == "LED_OFF") {
digitalWrite(13, LOW);
Serial.println("LED turned OFF");
}
}
choturobo.js
with the following content:const { McpServer } = require('@modelcontextprotocol/sdk');
const { StdioServerTransport } = require('@modelcontextprotocol/sdk');
const { Board, Led, Servo, Motor } = require('johnny-five');
// Initialize the MCP Server
const server = new McpServer();
const transport = new StdioServerTransport();
server.connect(transport);
// Connect to the Arduino board
const board = new Board();
board.on('ready', function() {
console.log('Board is ready!');
// Initialize components
const led = new Led(13);
const servo = new Servo(9);
const motor = new Motor([10, 11]);
// Define MCP tools
server.tool('blinkLED', async ({ time }) => {
led.blink(500);
await new Promise(resolve => setTimeout(resolve, time * 1000));
led.stop();
return { status: 'success', message: `LED blinked for ${time} seconds` };
});
server.tool('moveServo', async ({ angle }) => {
servo.to(angle);
return { status: 'success', message: `Servo moved to ${angle} degrees` };
});
server.tool('runMotor', async ({ speed, time }) => {
motor.speed(speed);
await new Promise(resolve => setTimeout(resolve, time * 1000));
motor.stop();
return { status: 'success', message: `Motor ran at speed ${speed} for ${time} seconds` };
});
// Add more tools as needed
});
// Start the server
server.start();
node choturobo.js
npx @modelcontextprotocol/inspector node build/choturobo.js
The Chotu Robo Server responds to the following commands:
Command | Description | Parameters |
---|---|---|
blinkLED |
Blink an LED | time : duration in seconds |
buzz |
Activate a buzzer | time : duration in seconds |
runMotor |
Run a motor | speed : 0-255, time : duration in seconds |
moveServo |
Move a servo | angle : 0-180 degrees |
controlFan |
Control a fan | state : true/false |
toggleRelay |
Toggle a relay | state : true/false |
readTemperature |
Read temperature | None |
readDistance |
Measure distance | None |
When integrated with AI systems like Claude, you can use natural language commands:
AI Command | Description | Example |
---|---|---|
move-chotu |
Move the robot | "Move Chotu forward by 5 steps" |
start-chotu |
Start the robot | "Start Chotu" |
stop-chotu |
Stop the robot | "Stop Chotu" |
turn-chotu |
Turn the robot | "Turn Chotu left" |
set-chotu-speed |
Set robot speed | "Set Chotu speed to 10" |
// Example command to blink LED for 5 seconds
{
"command": "blinkLED",
"params": {
"time": 5
}
}
// Example command to move servo to 90 degrees
{
"command": "moveServo",
"params": {
"angle": 90
}
}
// Example command to run motor at half speed for 3 seconds
{
"command": "runMotor",
"params": {
"speed": 128,
"time": 3
}
}
// Example command to read temperature
{
"command": "readTemperature"
}
// Example command to read distance
{
"command": "readDistance"
}
In wireless mode, the robot connects to your local WiFi network and can receive commands remotely. After uploading the code to the ESP32:
Example HTTP request:
POST http://192.168.1.100/command
Content-Type: application/json
{
"command": "blinkLED",
"params": {
"time": 3
}
}
In wired mode, the robot needs to be connected via USB to a computer running the MCP server. Commands are sent through the serial connection:
This mode is useful for development and testing before moving to wireless operation.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.