
kakimochi/ros2-mcp-server 是从 https://github.com/kakimochi/ros2-mcp-server. 导入的 MCP 服务器候选
概览
kakimochi/ros2-mcp-server 是从 https://github.com/kakimochi/ros2-mcp-server. 导入的 MCP 服务器候选
概述(AI 翻译)
ros2-mcp-server 是一款基于 Python 的服务器,将模型上下文协议(MCP)与 ROS 2 集成,使 AI 助手能够通过 ROS 2 主题控制机器人。它通过 FastMCP 处理命令,并作为 ROS 2 节点运行,向 /cmd_vel 主题发布 geometry_msgs/Twist 消息以控制机器人运动。
该实现支持诸如“以0.2 m/s前进5秒后停止”等命令,发布者名为/cmd_vel。
特色
- MCP 集成:使用 FastMCP 处理来自 MCP 客户端(例如 Claude)的命令。
- ROS 2 原生:作为 ROS 2 节点运行,直接发布到
/cmd_vel。 - 基于时间的控制:支持基于持续时间的移动命令(例如,指定时间移动后停止)。
- 异步处理:结合FastMCP的
asyncio与ROS 2的事件循环以实现高效运行。
先修条件
- ROS 2:安装并采购的Humble发行版。
- Python:版本3.10(兼容ROS 2 Humble所需)。
- uv:用于依赖管理的 Python 包管理器。
- 依赖关系:
rclpy:ROS 2 Python 客户端库(随 ROS 2 安装)。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
ros2-mcp-server
ros2-mcp-server is a Python-based server that integrates the Model Context Protocol (MCP) with ROS 2, enabling AI assistants to control robots via ROS 2 topics. It processes commands through FastMCP and runs as a ROS 2 node, publishing geometry_msgs/Twist messages to the /cmd_vel topic to control robot movement.
This implementation supports commands like “move forward at 0.2 m/s for 5 seconds and stop,” with the /cmd_vel publisher named pub_cmd_vel.
Features
- MCP Integration: Uses FastMCP to handle commands from MCP clients (e.g., Claude).
- ROS 2 Native: Operates as a ROS 2 node, directly publishing to
/cmd_vel. - Time-Based Control: Supports duration-based movement commands (e.g., move for a specified time and stop).
- Asynchronous Processing: Combines FastMCP’s
asynciowith ROS 2’s event loop for efficient operation.
Prerequisites
- ROS 2: Humble distribution installed and sourced.
- Python: Version 3.10 (required for compatibility with ROS 2 Humble).
- uv: Python package manager for dependency management.
- Dependencies:
rclpy: ROS 2 Python client library (installed with ROS 2).fastmcp: FastMCP framework for MCP server implementation.numpy: Required by ROS 2 message types.
Installation
-
Clone the Repository:
git clone https://github.com/kakimochi/ros2-mcp-server.git cd ros2-mcp-server -
Python Version Configuration: This project uses Python 3.10 as required by ROS 2 Humble. The
.python-versionfile is already configured:# .python-version content 3.10 -
Project Dependencies: The
pyproject.tomlfile is configured with the necessary dependencies:# pyproject.toml content [project] name = "ros2-mcp-server" version = "0.1.0" description = "ROS 2 MCP Server" readme = "README.md" requires-python = ">=3.10" dependencies = [ "fastmcp", "numpy", ] -
Create uv Environment:
uv venv --python /usr/bin/python3.10 -
Activate the Virtual Environment:
source .venv/bin/activateYou’ll see
(.venv)appear at the beginning of your command prompt, indicating that the virtual environment is active. -
Install Dependencies:
uv pip install -e .
MCP Server Configuration
To use this server with Claude or other MCP clients, you need to configure it as an MCP server. Here’s how to set it up:
For Claude Desktop
- Open Claude Desktop settings and navigate to the MCP servers section.
- Add a new MCP server with the following configuration:
"ros2-mcp-server": { "autoApprove": [], "disabled": false, "timeout": 60, "command": "uv", "args": [ "--directory", "/path/to/ros2-mcp-server", "run", "bash", "-c",
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →