sphero-rvr-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sphero-rvr-mcp Drive forward 1 meter"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Sphero RVR MCP Server
An MCP (Model Context Protocol) server that enables AI assistants to control a Sphero RVR robot. Run this on a Raspberry Pi connected to your RVR, and use any MCP-compatible client to drive, control LEDs, read sensors, and more.
Features
Core Capabilities
Full RVR Control: Movement, LEDs, sensors, battery monitoring, IR communication
Distance-Based Movement: Drive forward/backward by meters, pivot by degrees
Safety System: Configurable speed limits, auto-stop timeout, emergency stop
Sensor Streaming: Background streaming with cached data access
Natural Language Control: Let AI drive your robot with conversational commands
Client Agnostic: Works with any MCP-compatible client
Low-Latency Architecture (v0.2.1+)
Direct Serial Protocol: Bypasses SDK for sub-millisecond command latency
No Sphero SDK Required: Works on Python 3.10 - 3.13+ (SDK was limited to 3.10)
Minimal Dependencies: Just 4 packages (fastmcp, pydantic, structlog, pyserial)
Distance Control:
drive_forward(0.5)moves exactly 0.5 metersAngle Control:
pivot(90)rotates exactly 90 degreesCommand Queue: Priority-based async queue eliminates race conditions
Atomic State Management: Thread-safe state with validated transitions
Structured Logging: JSON or console format for easy debugging
Related MCP server: toio-mcp
Compatible MCP Clients
Claude Code (CLI)
Any custom client using the MCP SDK
Requirements
Raspberry Pi 3 or newer (connected to Sphero RVR via serial)
Python 3.10+ (tested on 3.10, 3.12, 3.13 - no SDK limitations)
Sphero RVR with serial connection to Pi
Installation
Install from PyPI (recommended)
pip install sphero-rvr-mcpInstall from source
git clone https://github.com/jsperson/sphero_rvr_mcp.git
cd sphero_rvr_mcp
pip install -e .Verify Installation
Run the pre-flight check to verify everything is set up correctly:
sphero-rvr-mcp --checkThis will verify:
Python version (requires 3.10+)
FastMCP is installed
Serial port exists and is accessible
Current configuration settings
Configure Your MCP Client
The server runs via stdio. Configure your MCP client with:
Command:
python -m sphero_rvr_mcp
Claude Code
claude mcp add sphero-rvr -c "python -m sphero_rvr_mcp"Or edit ~/.claude.json:
{
"mcpServers": {
"sphero-rvr": {
"type": "stdio",
"command": "python",
"args": ["-m", "sphero_rvr_mcp"]
}
}
}Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"sphero-rvr": {
"command": "python",
"args": ["-m", "sphero_rvr_mcp"]
}
}
}Other Clients
Refer to your client's MCP configuration documentation. The server uses stdio transport.
Configuration
Environment variables (optional):
Variable | Default | Description |
Connection | ||
|
| Serial port for RVR |
|
| Serial baud rate |
Safety | ||
|
| Default speed limit (0-100) |
|
| Auto-stop timeout (seconds, 0=disabled) |
Performance | ||
|
| Max queued commands |
Observability | ||
|
| Log level (DEBUG, INFO, WARNING, ERROR) |
|
| Log format (json, console) |
Usage
Example Commands
Once your MCP client is connected to the server:
You: Connect to the RVR
You: Drive forward 6 inches
You: Pivot 90 degrees to the right
You: Drive forward 1 meter
You: Set all LEDs to blue
You: What's the battery level?
You: Which direction is the rover facing?
# Returns heading in degrees and cardinal direction (N, NE, E, SE, S, SW, W, NW)
You: Turn left 45 degrees and drive backward 0.5 meters
You: Emergency stop!Available Tools
Connection (3 tools)
Tool | Description |
| Connect to RVR and wake it up |
| Safely disconnect |
| Get connection state, uptime, firmware |
Movement (11 tools)
Tool | Description |
| Drive forward by distance in meters |
| Drive backward by distance in meters |
| Turn in place by degrees (positive=right, negative=left) |
| Drive at speed toward heading (0-359) |
| Tank drive with left/right velocities (m/s) |
| RC-style with linear + yaw velocity |
| Normal stop |
| Immediate stop, blocks movement |
| Allow movement after e-stop |
| Set current heading as 0 |
| Set current position as origin |
LEDs (3 tools)
Tool | Description |
| Set all LEDs to RGB color |
| Set specific LED group to RGB |
| Turn off all LEDs |
LED groups: headlight_left, headlight_right, brakelight_left, brakelight_right, status_indication_left, status_indication_right, battery_door_front, battery_door_rear, power_button_front, power_button_rear, undercarriage_white, all
Sensors (12 tools)
Tool | Description |
| Start background sensor streaming |
| Stop all streaming |
| Get cached sensor readings |
| Query light sensor directly |
| Enable/disable color sensor LED |
| Query color sensor (auto LED) |
| Get compass heading and cardinal direction |
| Calibrate compass (rotate 360°) |
| Get motor temperatures (°C) |
| Get wheel encoder tick counts |
| Motor thermal state (ok/warning/critical) |
| Get IR sensor readings (bot-to-bot, 255=no signal) |
Streamable sensors: accelerometer, gyroscope, imu, locator, velocity, speed, quaternion, color_detection, ambient_light, core_time
Battery & System (11 tools)
Tool | Description |
| Battery percentage |
| Battery voltage in volts |
| Battery state (ok/low/critical) |
| Voltage thresholds (critical/low/hysteresis) |
| Current safety settings |
| Firmware versions (Nordic + MCU) |
| Processor identifiers (Nordic/ST) |
| Bluetooth MAC address |
| PCB board revisions |
| Product SKU |
| Uptime in milliseconds |
Safety & Motor Protection (5 tools)
Tool | Description |
| Set max speed (0-100%) |
| Set auto-stop timeout |
| Check for motor faults |
| Enable/disable stall detection |
| Enable/disable fault detection |
IR Communication (7 tools)
Tool | Description |
| Send IR code (0-7) |
| Start robot-to-robot IR broadcasting |
| Stop IR broadcasting |
| Follow an IR-broadcasting robot |
| Stop following |
| Evade an IR-broadcasting robot |
| Stop evading |
Architecture
Component Overview
MCP Tool Handlers (FastMCP)
|
v
Direct Serial Protocol (low-latency)
|
+-- Packet Builder (commands.py)
+-- Serial Connection (direct_serial.py)
|
v
Sphero RVR (via /dev/ttyAMA0)Key Design Patterns
Direct Serial Protocol
Bypasses the Sphero SDK for minimal latency
Constructs raw SOP/EOP packets directly
Sub-millisecond command transmission
Supports all core RVR commands
Distance-Based Movement
drive_forward(distance)- Uses RVR's internal position controllerdrive_backward(distance)- Accurate reverse movementpivot(degrees)- Precise rotation using heading control
Command Queue
All hardware commands go through async priority queue
Priority levels: EMERGENCY (0) -> HIGH (1) -> NORMAL (2) -> LOW (3)
Per-command timeout enforcement
Eliminates race conditions in concurrent access
Atomic State Management
Thread-safe with explicit locks
Validated state transitions
All changes logged
Observability
Structured Logging
{
"event": "command_submitted",
"command_type": "drive_forward",
"distance": 0.5,
"timestamp": "2026-01-15T01:23:45.678Z"
}Safety Features
Speed Limiting
All movement commands are limited to a configurable percentage of max speed (default 50%). This prevents accidental high-speed collisions.
You: Set the speed limit to 25%
You: Now drive forward at full speed
# RVR will only go at 25% of max speedCommand Timeout
If no movement command is received within the timeout period (default 5 seconds), the RVR automatically stops. This prevents runaway situations if connection is lost.
Emergency Stop
Immediately stops all movement and blocks further motion until explicitly cleared. Has highest priority in the command queue.
You: Emergency stop!
# RVR stops immediately
# All movement commands will fail until:
You: Clear the emergency stopTroubleshooting
Connection Issues
"Failed to connect to RVR"
Check serial connection:
ls -l /dev/ttyAMA0Ensure RVR is powered on and charged
Verify baud rate (default 115200)
Connection times out
RVR might be off or in deep sleep
Try power cycling the RVR
Check serial cable connection
Performance Issues
Slow response
Raspberry Pi 3 may be slower than Pi 4/5
Reduce sensor streaming frequency
Close unnecessary applications
Sensor Issues
Color detection returns all zeros
Ensure RVR is on a non-dark surface
Try increasing stabilization time
Check that belly LED is working
RVR Behavior Issues
RVR not responding to commands
Check if emergency stop is active:
get_safety_statusCheck speed limit isn't set to 0%
Try disconnecting and reconnecting
RVR stops on its own
Check command timeout setting (default 5 seconds)
Disable auto-stop:
set_command_timeout(0)Verify battery level isn't critical
Project Structure
sphero_rvr_mcp/
├── pyproject.toml # Package configuration
├── README.md # This file
├── LICENSE # MIT License
└── src/sphero_rvr_mcp/
├── __init__.py
├── __main__.py # Entry point
├── config.py # Configuration
├── api.py # Direct API (non-MCP)
├── server.py # MCP server & tool handlers
│
├── protocol/ # Direct serial protocol
│ ├── __init__.py
│ ├── commands.py # Packet builders
│ ├── direct_serial.py # Serial connection
│ └── packet.py # SOP/EOP framing
│
├── core/ # Core infrastructure
│ ├── command_queue.py # Priority command queue
│ ├── state_manager.py # Atomic state management
│ └── exceptions.py # Exception hierarchy
│
├── hardware/ # Hardware abstraction
│ ├── connection_manager.py # Connection lifecycle
│ ├── sensor_stream_manager.py # Sensor streaming
│ └── safety_monitor.py # Safety system
│
├── services/ # Application services
│ ├── movement_service.py
│ ├── led_service.py
│ └── ir_service.py
│
└── observability/ # Logging
└── logging.py # Structured loggingDevelopment
Running Tests
# Unit tests
pytest tests/unit/
# Integration tests (requires RVR)
pytest tests/integration/
# All tests
pytestViewing Logs
# Console format (human-readable)
RVR_LOG_FORMAT=console python -m sphero_rvr_mcp
# JSON format (machine-readable)
RVR_LOG_FORMAT=json python -m sphero_rvr_mcpContributing
Contributions welcome! Please:
Fork the repository
Create a feature branch
Add tests for new functionality
Ensure all tests pass
Submit a pull request
Changelog
v0.2.3 (2026-01-29)
22 new MCP tools for full SDK sensor coverage:
Temperature & thermal protection monitoring
System info (firmware, MAC, SKU, uptime, board revision)
Extended battery info (voltage, state, thresholds)
Motion sensors (encoders, magnetometer with compass heading)
Motor protection (fault state, stall/fault notifications)
IR follow/evade behaviors
Fixed 4 sensor commands with incorrect protocol parameters
Magnetometer heading - returns
heading(degrees) andcardinaldirection
v0.2.1 (2026-01-15)
Direct serial protocol for low-latency control (bypasses SDK)
Added
drive_forwardanddrive_backwardwith distance in metersAdded
pivotcommand for precise angle rotationRemoved unused dependencies (prometheus-client, tenacity, nest-asyncio)
Added pyserial dependency
Simplified architecture (removed circuit breaker, event bus, metrics)
No longer requires Sphero SDK installation
v0.2.0 (2026-01-14)
Complete architectural rewrite for production reliability
Added command queue with priority levels
Added circuit breaker for connection resilience
Added event bus for sensor distribution
Added atomic state management
Added comprehensive observability (logging + metrics)
Fixed SDK response key parsing (color sensor now works!)
v0.1.1 (2024-12-XX)
Added connection timeouts
Updated documentation
v0.1.0 (2024-12-XX)
Initial release
License
MIT
Credits
Available Tools
55 toolscalibrate_magnetometerA
Start magnetometer calibration (calibrate to north).
This is an async operation - the RVR will notify when complete. Rotate the RVR 360 degrees during calibration.
Inputs: no named parameters. Returns: object
clear_emergency_stopB
Clear emergency stop.
Inputs: no named parameters. Returns: object
connectC
Connect to the Sphero RVR robot and wake it up.
Inputs: baud, port. Returns: object
connect_simpleB
Simple connect test without parameters.
Inputs: no named parameters. Returns: object
disconnectB
Disconnect from RVR.
Inputs: no named parameters. Returns: object
drive_backwardA
Drive backward a specified distance in meters.
Uses RVR's internal position controller for accurate movement.
Inputs: distance (required), speed. Returns: object
drive_forwardA
Drive forward a specified distance in meters.
Uses RVR's internal position controller for accurate movement.
Inputs: distance (required), speed. Returns: object
drive_rcD
Drive with RC controls.
Inputs: yaw_velocity (required), linear_velocity (required). Returns: object
drive_tankC
Drive with tank controls.
Inputs: left_velocity (required), right_velocity (required). Returns: object
drive_with_headingC
Drive at speed toward heading.
Inputs: speed (required), heading (required), reverse. Returns: object
emergency_stopC
Emergency stop.
Inputs: no named parameters. Returns: object
enable_color_detectionD
Enable color detection.
Inputs: enabled. Returns: object
enable_motor_fault_notifyC
Enable or disable motor fault detection notifications.
Inputs: enabled. Returns: object
enable_motor_stall_notifyB
Enable or disable motor stall detection notifications.
Inputs: enabled. Returns: object
get_ambient_lightB
Get ambient light.
Inputs: no named parameters. Returns: object
get_battery_statusC
Get battery status.
Inputs: no named parameters. Returns: object
get_battery_thresholdsA
Get battery voltage thresholds (critical, low, hysteresis).
Inputs: no named parameters. Returns: object
get_battery_voltageB
Get battery voltage in volts (calibrated).
Inputs: no named parameters. Returns: object
get_battery_voltage_stateA
Get battery voltage state (ok/low/critical).
Inputs: no named parameters. Returns: object
get_board_revisionA
Get PCB board revision for both processors.
Inputs: no named parameters. Returns: object
get_color_detectionD
Get color detection.
Inputs: stabilization_ms. Returns: object
get_connection_statusB
Get connection status.
Inputs: no named parameters. Returns: object
get_core_uptimeA
Get core uptime in milliseconds since power-on for both processors.
Inputs: no named parameters. Returns: object
get_encoder_countsA
Get wheel encoder tick counts (left and right).
Inputs: no named parameters. Returns: object
get_firmware_versionA
Get firmware version (major.minor.revision) for both processors.
Inputs: no named parameters. Returns: object
get_ir_readingsA
Get all 4 IR sensor readings (front_left, front_right, back_right, back_left).
Inputs: no named parameters. Returns: object
get_mac_addressA
Get Bluetooth MAC address.
Inputs: no named parameters. Returns: object
get_magnetometerA
Get magnetometer X, Y, Z readings with heading and cardinal direction.
Inputs: no named parameters. Returns: object
get_motor_fault_stateA
Check if motor fault is currently active.
Inputs: no named parameters. Returns: object
get_motor_thermal_protection_statusA
Get motor thermal protection status.
Returns temperature and status for each motor. Status: 0=ok, 1=warning, 2=critical
Inputs: no named parameters. Returns: object
get_processor_nameA
Get processor identifier strings for both processors.
Inputs: no named parameters. Returns: object
get_safety_statusC
Get safety status.
Inputs: no named parameters. Returns: object
get_sensor_dataB
Get sensor data.
Note: Sensor queries use blocking serial I/O. Each query typically completes in <100ms but may block the event loop briefly.
Inputs: sensors. Returns: object
get_skuA
Get product SKU string.
Inputs: no named parameters. Returns: object
get_temperatureA
Get temperature sensor readings (motor and Nordic die temps).
Returns temperatures in Celsius for left_motor, right_motor, and nordic_die.
Inputs: no named parameters. Returns: object
pivotA
Pivot (turn in place) by a specified number of degrees.
Rotates the RVR without forward motion. Uses internal heading control for accurate turning.
Inputs: degrees (required), speed. Returns: object
reset_locatorC
Reset locator.
Inputs: no named parameters. Returns: object
reset_yawC
Reset yaw.
Inputs: no named parameters. Returns: object
send_ir_messageD
Send IR message.
Inputs: code (required), strength. Returns: object
set_all_ledsC
Set all LEDs.
Inputs: red (required), blue (required), green (required). Returns: object
set_command_timeoutD
Set command timeout.
Inputs: timeout_seconds (required). Returns: object
set_ledC
Set specific LED group.
Inputs: red (required), blue (required), green (required), led_group (required). Returns: object
set_speed_limitC
Set speed limit.
Inputs: max_speed_percent (required). Returns: object
start_ir_broadcastingC
Start IR broadcasting.
Inputs: far_code (required), near_code (required). Returns: object
start_ir_evadingC
Start evading an IR-broadcasting robot.
Inputs: far_code (required), near_code (required). Returns: object
start_ir_followingB
Start following an IR-broadcasting robot.
Inputs: far_code (required), near_code (required). Returns: object
start_sensor_streamingD
Start sensor streaming.
Inputs: sensors (required), interval_ms. Returns: object
stopB
Stop RVR.
Inputs: no named parameters. Returns: object
stop_ir_broadcastingA
Stop IR broadcasting.
Inputs: no named parameters. Returns: object
stop_ir_evadingC
Stop IR evading behavior.
Inputs: no named parameters. Returns: object
stop_ir_followingA
Stop IR following behavior.
Inputs: no named parameters. Returns: object
stop_sensor_streamingA
Stop sensor streaming.
Inputs: no named parameters. Returns: object
test_immediate_returnB
Test tool that returns immediately.
Inputs: no named parameters. Returns: object
test_slow_returnB
Test tool that takes 3 seconds.
Inputs: no named parameters. Returns: object
turn_leds_offA
Turn off all LEDs.
Inputs: no named parameters. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 55 tools
Most tools target distinct actions or sensors, but there is some overlap: multiple battery getters (status, voltage, voltage_state, thresholds) and get_sensor_data could be seen as a catch-all that duplicates specific getters. The test tools and connect_simple/connect add minor confusion, but descriptions generally clarify boundaries.
The majority of tools use a consistent verb_noun pattern (get_*, set_*, start_*, stop_*, drive_*). However, there are deviations like test_immediate_return, test_slow_return, connect_simple, emergency_stop, clear_emergency_stop, and turn_leds_off which break the pattern slightly.
With 55 tools, the server is well beyond the typical 3-15 range and even exceeds the 25+ threshold. The surface is bloated with redundant test utilities and multiple specialized getters that could be consolidated, making it overwhelming for agents.
The toolset covers core robot operations: connection, driving, LEDs, sensors, IR, battery, safety, and system info. Notable gaps include a direct position getter (only reset_locator and encoder counts) and no gyroscope/accelerometer readings, but the domain is largely covered.
Maintenance
Related MCP Connectors
Connect any AI agent to 1,000+ apps and 27,000+ actions through one remote MCP server (OAuth).
Automate 1,000+ services from any MCP-compatible AI agent: build Applets, run actions and queries.
Hosted MCP server connecting AI assistants to 9,000+ apps and 40,000+ actions via Zapier.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to control Unreal E…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI models to monitor and control Kachaka robots via MCP, including navigation, shelf operations, and sensor data access.1Apache 2.0
- FlicenseNot gradedqualityDmaintenanceControls toio robot cubes via natural language through BLE, enabling movement, LED control, and sound playback from MCP-compatible clients like Claude Desktop.1-
- FlicenseNot gradedqualityDmaintenanceEnables natural language control of an esieabot robot (motors, servo, camera) through Claude Desktop or MCP Inspector.-
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to control a littleBits R2-D2 robot over Bluetooth Low Energy by calling tools to drive and play sounds.-