A comprehensive Model Context Protocol (MCP) server implementation for the ESP32 CYD (Cheap Yellow Display) board. This project provides extensive remote control capabilities for the ESP32-2432S028R board through a WebSocket-based MCP interface.
- WebSocket-based MCP protocol implementation
- JSON-RPC 2.0 compliant
- Real-time bidirectional communication
- Multiple client support
- Event notifications
display.clear- Clear screen with colordisplay.text- Draw text with positioning and stylingdisplay.line- Draw lines with thicknessdisplay.rectangle- Draw rectangle outlinesdisplay.fillRectangle- Draw filled rectanglesdisplay.circle- Draw circle outlinesdisplay.fillCircle- Draw filled circlesdisplay.pixel- Draw individual pixelsdisplay.backlight- Control backlight on/offdisplay.brightness- Set display brightness (0-255)display.rotation- Set display rotation (0-3)display.progressBar- Draw progress barsdisplay.info- Get display information
touch.getState- Get current touch statetouch.enable- Enable/disable touch inputtouch.calibrate- Calibrate touch screentouch.getHistory- Get recent touch eventstouch.simulate- Simulate touch eventstouch.getCalibration- Get calibration valuestouch.saveCalibration- Save calibration to file- Gesture detection (swipe support)
gpio.pinMode- Set pin mode (input/output/PWM)gpio.digitalWrite- Write digital valuegpio.digitalRead- Read digital valuegpio.analogWrite- PWM outputgpio.analogRead- Read analog valuegpio.attachInterrupt- Attach interruptsgpio.setPWM- Configure PWM with frequencygpio.tone- Generate tonesgpio.pulseIn- Measure pulse duration
sensor.readTemperature- Read temperature sensorsensor.readLight- Read light sensorsensor.readInternalTemp- ESP32 internal temperaturesensor.readHallSensor- Built-in hall sensorsensor.readBatteryVoltage- Power supply voltagesensor.readAll- Read all sensors at oncesensor.calibrate- Calibrate sensorssensor.getEnvironment- Environmental summary
network.status- Get network statusnetwork.connect- Connect to WiFinetwork.scan- Scan for networksnetwork.startAP- Start access pointnetwork.httpRequest- Make HTTP requestsnetwork.ping- Ping hostsnetwork.getTime- Get NTP timenetwork.setMDNS- Configure mDNS
system.info- Comprehensive system informationsystem.restart- Restart ESP32system.sleep- Deep/light sleep modessystem.memory- Memory statisticssystem.tasks- FreeRTOS task infosystem.setCPUFrequency- CPU speed controlsystem.performanceMode- Performance optimizationsystem.factoryReset- Factory reset
file.list- List files/directoriesfile.read- Read file contentsfile.write- Write to filefile.delete- Delete filesfile.mkdir- Create directoriesfile.copy- Copy filesfile.storage- Storage statistics- Support for SPIFFS and SD card
audio.tone- Play single toneaudio.playMelody- Play melodiesaudio.beep- Simple beep soundsaudio.playPattern- Custom tone patternsaudio.notification- Notification soundsaudio.alarm- Alarm patternsaudio.setVolume- Volume control- Predefined melodies (Mario, Star Wars, etc.)
- ESP32-2432S028R (CYD) board
- 2.8" ILI9341 TFT display (240x320)
- XPT2046 resistive touch controller
- Optional: SD card for file storage
- Optional: External sensors (temperature, light)
- Install PlatformIO or Arduino IDE
- Clone this repository
- Open the project in PlatformIO
- Build and upload to your ESP32 CYD board
git clone https://github.com/yourusername/esp32-cyd-mcp
cd esp32-cyd-mcp
pio run -t uploadEdit include/config.h to customize:
- WiFi credentials
- Pin assignments
- Server ports
- Display settings
- Sensor calibration
- Power on the ESP32 CYD board
- Connect to WiFi or use the AP mode
- Find the device IP address on the display
- Connect via WebSocket to
ws://[IP]:3001
{
"jsonrpc": "2.0",
"id": "1",
"method": "tools/invoke",
"params": {
"name": "display.text",
"arguments": {
"text": "Hello MCP!",
"x": 50,
"y": 100,
"color": "white",
"size": 2
}
}
}Add to your Claude Desktop configuration:
{
"mcpServers": {
"esp32-cyd": {
"command": "websocat",
"args": ["ws://192.168.1.100:3001"]
}
}
}All tools are invoked using the standard MCP tools/invoke method:
{
"method": "tools/invoke",
"params": {
"name": "tool.name",
"arguments": { ... }
}
}The server sends notifications for various events:
touch.event- Touch input eventssensor.update- Periodic sensor updatesnetwork.event- Network state changesgpio.interrupt- GPIO interrupt events
- Create header file in
include/tools/ - Implement in
src/tools/ - Register tools in the
registerTools()method - Add initialization in
main.cpp
esp32-cyd-mcp/
├── include/
│ ├── config.h # Configuration
│ ├── mcp_server.h # MCP server core
│ └── tools/ # Tool headers
├── src/
│ ├── main.cpp # Main application
│ ├── mcp_server.cpp # MCP implementation
│ └── tools/ # Tool implementations
├── platformio.ini # PlatformIO config
└── README.md
- WiFi Connection Issues: Check credentials in config.h
- Touch Not Working: Run touch calibration tool
- Display Issues: Verify display rotation setting
- Memory Issues: Monitor free heap, reduce tool usage
This project is open source and available under the MIT License.
Contributions are welcome! Please submit pull requests or open issues for bugs and feature requests.
- ESP32 community for hardware support
- TFT_eSPI library for display drivers
- MCP specification for protocol design