mbotmcp

mbotmcp

3.5

This project demonstrates how to control an mBot2 robot using Spring AI and Model Context Protocol (MCP).

MBotMcp is a project that enables the control of an mBot2 robot using natural language commands through the integration of Spring AI and Model Context Protocol (MCP). The system comprises a Spring Boot application that implements MCP, an MQTT broker for message passing, Python code running on the mBot2 robot, and AI client integration capabilities. The Spring application exposes robot control commands as AI-callable functions, allowing AI models to control the physical robot through natural language. The setup requires Java 21, Maven, an mBot2 robot, mBlock IDE, and an MQTT broker, which can be run in Docker. The project provides a comprehensive setup guide, including configuring the Spring Boot application, setting up the MQTT broker, and uploading the Python script to the mBot2 robot.

Features

  • Natural language control of mBot2 robot
  • Integration with Spring AI and MCP
  • MQTT broker for message passing
  • Python code for mBot2 robot
  • AI client integration capabilities

MCP Tools

  • {'mbotExplore': "Execute the 'explore' routine"}
  • {'mbotStop': 'Stop the robot'}
  • {'mbotBeep': 'Make the robot beep'}
  • {'mbotLeft': 'Turn the robot left'}
  • {'mbotRight': 'Turn the robot right'}
  • {'mbotForward': 'Move the robot forward'}
  • {'mbotBackward': 'Move the robot backward'}

Usage with Different Platforms

mcp

python
# Example Python script for mBot2
ssid = "<your wifi ssid>"
ssid_password = "<your wifi password>"
mqtt_ip = "<ip of the mqtt broker>"
mqtt_port = 1883
mqtt_user = "<your mqtt username>"
mqtt_password = "<your mqtt password>"

spring_boot

bash
# Build the Spring Boot App
mvn clean package

mqtt_broker

bash
# Run the MQTT Broker using Docker Compose
cd mbotmcp/assets
docker-compose up -d