Welcome to ROSMASTER M3 PRO repository
1. OpenClaw connects to the MCP interface of the robot
OpenClaw Integration with Robot MCP Interface
OpenClaw Integration with Robot MCP Interface1. Course ContentCourse OverviewLearning Objectives2. Preparation3. Introduction to the MCP Protocol4. OpenClaw Robot Control Communication Architecture5. Launching the MCP Service6. Controlling the Robot with OpenClaw7. Source Code Analysis7.1 🖥️ MCP Service7.2 🛠️ MCP Tools7.3 💬 MCP Message Interface8. Summary of Robot MCP Functional Interfaces
1. Course Content
Course Overview
This lesson explains how to implement intelligent robot control using the OpenClaw framework and the MCP (Model Context Protocol) interface.
Learning Objectives
- Understand the basic principles of the MCP protocol.
- Control the robot using OpenClaw.
2. Preparation
- Start the MicroROS chassis agent (if already started, no need to repeat the process)
sh start_agent.sh3. Introduction to the MCP Protocol
- MCP (Model Context Protocol) is an open protocol used to connect large language models with external tools and services. In this system, OpenClaw uses the MCP protocol to translate user natural language commands into specific robot operation commands.
- After the AI model parses the user's commands, it selects the corresponding MCP Tool for execution. The MCP service then translates the tool call into ROS2 Action commands, driving the robot chassis, robotic arm, and other hardware to perform actions.

- Through the ROSMASTER-M3Pro's MCP service interface, the robot can be connected to any AI model, agent, or AI tool that supports MCP, enabling robot control.
4. OpenClaw Robot Control Communication Architecture
The communication architecture for the OpenClaw-controlled robot is divided into four layers:
- User Interaction Layer: Sends natural language commands via interaction channels such as Web Chat, WeChat, Feishu, etc.
- AI Decision Layer: The LLM within OpenClaw parses user intent and selects the corresponding MCP Tool.
- MCP Service Layer: Operates based on the FastMCP framework; it registers over 20 tool functions—covering chassis movement, robotic arm control, visual recognition, etc.—and communicates with the robot hardware via ROS2 Actions, Topics, and Services.
- Robot Execution Layer: The MicroROS chassis agent receives commands and drives the robot hardware—such as the chassis and robotic arm—to execute the specified actions.
xxxxxxxxxx┌─────────────┐│ OpenClaw │└──────┬──────┘│▼┌─────────────┐│robot-control|│ Plugin |└──────┬──────┘│ MCP Protocol▼┌─────────────┐│ MCP Server │└──────┬──────┘│▼┌───────────────────────────┐│ ROS2 Communication Stack ││ Topics/Services/Actions │└──────┬────────────────────┘│▼┌──────────────────────────┐│ Hardware Driver Layer │└──────┬───────────────────┘│▼┌───────────────────┐│ Robot Hardware │└───────────────────┘
5. Launching the MCP Service
- Launch via Terminal
xxxxxxxxxxros2 launch m3pro_bringup mcp_service.launch.py
6. Controlling the Robot with OpenClaw
- On your PC, open the Web Chat UI and log in while connected to the same local area network (LAN) as the robot's onboard computer.
[!NOTE]
- For the interaction method with OpenClaw, you may select any of the options listed in the "02-openclaw Interaction Methods" section. For this demonstration, we will use the Web Chat interface as an example.
- Here, we will demonstrate and test OpenClaw's control capabilities using the robotic arm as an example:
- Return the robotic arm to its initial position.
- Adjust the first joint of the robotic arm to 0 degrees.

- If you require the robot to provide spoken responses, you must also launch the
openclaw_bridgenode and ensure that the OpenClaw voice tags feature is enabled.
xxxxxxxxxxros2 run multi_brains_pre openclaw_bridge- Once launched, the logs will indicate which speech synthesis model engine has been loaded.

7. Source Code Analysis
7.1 🖥️ MCP Service
Source Code Path:
xxxxxxxxxx$HOME/M3Pro_ws/src/multi_brains_pre/multi_brains_pre/mcp_service.py
mcp_service.py serves as the entry point for the MCP service and primarily performs the following tasks:
- Creates a FastMCP service instance, named
"ROS-MCP-Service". - Creates a ROS2 node via
ROSContextand initiates background spinning. - Calls
register_actions()to register all robot control tools. - Starts the MCP service, listening on the specified host and port.
xfrom fastmcp import FastMCPfrom .action_controller import ROSContextfrom .mcp_tools.mcp_action import register_actionsmcp_service = FastMCP(name="ROS-MCP-Service")action_controller = ROSContext().create_node()ROSContext.start_spin()register_actions(mcp=mcp_service, action_controller=action_controller)mcp_service.run(host=action_controller.MCP_HOST, port=action_controller.MCP_PORT, transport=action_controller.MCP_TRANSPORT)7.2 🛠️ MCP Tools
Source Code Path:
xxxxxxxxxx$HOME/M3Pro_ws/src/multi_brains_pre/multi_brains_pre/mcp_tools/mcp_action.py
mcp_action.py registers MCP Tools via the register_actions() function.
All tools adhere to a unified registration pattern: they use the @mcp.tool() decorator to define their descriptions and timeout durations, employ Pydantic Fields to constrain parameter ranges, and return a common_response dataclass. Let's take the chassis movement tool as an example:
xxxxxxxxxx.tool(description='''Control the robot's omnidirectional chassis movement''', timeout=30.0)def MoveWithSpeed( linear_x: float=Field(default=1.5, ge=-2.5, le=2.5), linear_y: float=Field(default=1.5, ge=-2.5, le=2.5), angular_z: float=Field(default=1.5, ge=-2.5, le=2.5), duration: float=Field(default=1.0)) -> common_response: action_controller.set_cmdvel(linear_x, linear_y, angular_z, duration) return common_response(execution_result="success", reason="")
7.3 💬 MCP Message Interface
Source Code Path
xxxxxxxxxx$HOME/M3Pro_ws/src/multi_brains_pre/multi_brains_pre/message/mcp_message.py
mcp_message.py uses Python dataclasses to define the request and response message formats for MCP Tools.
All MCP Tools consistently return a common_response; AI models determine whether an operation was successful based on the execution_result field:
xxxxxxxxxxclass common_response:execution_result: strreason: strOther message types include:
ArmJointAngles: The angles of the robot arm's 6 joints (arm_joint_1~5 + gripper)EndEffectorPose: The pose of the end effector (x, y, z, roll, pitch, yaw)BoxLocalization: Results of target detection bounding boxesPlacePoint: Coordinates and information regarding placement pointswaste_recognition_result: Results of waste recognition detection
8. Summary of Robot MCP Functional Interfaces
- For details, please refer to the appendix located in this chapter's folder: MCP Function Summary.md