Skip to main content

MCP server for controlling ROS2 robots with natural language

Project description

ROS MCP

Trust Score ROS2-humble Industrial CI

ROS MCP is a MCP server designed for controlling robots in ROS environments using natural language. It supports communication via ROS topics, services, and actions, and works with any ROS message type.

Demo

Test to see if ros topics, services, and actions can be used.

https://github.com/user-attachments/assets/61143c37-fb73-4998-9cbc-844d92ae61d9

Prompt used (Topic)

Open gazebo with TurtleBot3 and publish topic to move it.

Prompt used (Service)

Show me service list and call service to reset the world in Gazebo.

Prompt used (Action)

Show me action list and call action to move the TurtleBot3 forward for 1m.

Components

  • Socket Server (socket_server.py): A lightweight server that runs on localhost:8765 to handle GUI-related operations. It receives instructions from the MCP server to launch tools such as Gazebo or rqt_graph on the local display.

  • MCP Server (ros-general.py): A Python-based server that implements the MCP. It processes natural language input, maps it to ROS commands, and communicates with the socket server. To enable node communication between the MCP server and the local machine, both must be configured with the same ROS_DOMAIN_ID on the same local network.

Overview of MCP Tools

  • Topic Management: List, monitor, and publish to ROS2 topics
  • Node Control: List and inspect running ROS2 nodes
  • Service Interaction: Call ROS2 services with custom
  • Action Support: Send goals to ROS2 actions
  • GUI Integration: Launch ROS2 GUI tools via WebSocket server
  • Environment Debugging: Check ROS2 setup and configuration
  • Process Management: Clean up running ROS2 processes

Please refer here for more details.

Getting Started

Requirements

  • ROS2 Humble Hawksbill (This project has only been tested with ROS2 Humble. Compatibility with other ROS2 distributions is not guaranteed.)
  • claude desktop (Linux, macOS and Windows)
  • Python 3.10+
  • websockets >= 15.0.1
  • uv package manager (Installing uv)
  • Other dependencies as listed in pyproject.toml

Installation

Git clone and install websockets package

git clone git@github.com:Yutarop/ros-mcp.git
cd ros-mcp
pip install "websockets>=15.0.1"

Activate .venv and install dependencies

uv venv
source .venv/bin/activate
uv pip install -e .

Claude Settings (claude_desktop_config.json)

To use the MCP server correctly with Claude Desktop, you need to modify the claude_desktop_config.json file with appropriate values.

{
  "mcpServers": {
    "ros-general": {
      "command": "uv",
      "args": [
        "--directory",
        "/ABSOLUTE/PATH/TO/PARENT/FOLDER/ros-mcp",
        "run",
        "bash",
        "-c",
        "export ROS_LOG_DIR=/tmp && export ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-YOUR_ROS_DOMAIN_ID} && source /opt/ros/humble/setup.bash && python3 /ABSOLUTE/PATH/TO/PARENT/FOLDER/ros-general.py"
      ]
    }
  }
}
💡 Replace the following placeholders:
  • /ABSOLUTE/PATH/TO/PARENT/FOLDER/ros-mcp Replace with the absolute path the ros-mcp directory. For example: /home/ubuntu/ros-mcp

  • YOUR_ROS_DOMAIN_ID Replace with the ROS domain ID used in your environment to enable ROS communication between the MCP server and your local machine. If you're not sure what your current domain ID is, you can check it by running the following command in your terminal:

    echo $ROS_DOMAIN_ID
    

    If nothing is printed, the domain ID is not set, and the default value 0 will be used. Alternatively, you can set it manually using the following command:

    export ROS_DOMAIN_ID=10  # Replace 10 with your desired domain ID
    
  • /ABSOLUTE/PATH/TO/PARENT/FOLDER/ros-general.py Replace with the absolute path to your ros-general.py script. For example: /home/ubuntu/ros-mcp/ros-general.py

Running the Servers

Start MCP server

Make sure your virtual environment is activated before running the MCP server:

(ros-mcp) $ uv run ros-general.py

Start socket server

python3 socket_server.py

💡not in the virtual environment!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iflow_mcp_yutarop_ros_mcp-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iflow_mcp_yutarop_ros_mcp-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file iflow_mcp_yutarop_ros_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: iflow_mcp_yutarop_ros_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_yutarop_ros_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 80c431fce010e01712803d905e1e46427c5fdee5458e85976c4033b8ad6569f5
MD5 3d321d42efb8f4ff909166bab97684f9
BLAKE2b-256 0219aa8ef2be47c62bcca98af1ff7752a594cd4723f8a088612a84ffa503a6fd

See more details on using hashes here.

File details

Details for the file iflow_mcp_yutarop_ros_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_yutarop_ros_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_yutarop_ros_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d65ba0988e1f49f56f3b7a4eec9e5811560dff8d31bf37d15986a2044a089b4
MD5 35ecea47f914edf34b2ceddbb969bda1
BLAKE2b-256 930a3952a7d70c0fdf3449983f69512b27e92cfd63f084cb266ca54b6bee30ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page