Sponsored by Deepsite.site

MCP server ROS 2

Created By
wise-vision9 months ago
Python server implementing Model Context Protocol (MCP) for ROS2.
Overview

Features

  • List available topics
  • List available services
  • Call service
  • Get messages from WiseVision Data Black Box (influxDB alternative to Rosbag2)
  • Subscribe topic to get messages
  • Publish message on topic
  • Echo message on topic
  • Get fields from message type

Note: To call service with custom service source it before start server.

API

Tools

  • ros2_topic_list

    • Retrun list of available topics
    • Output:
      • topic_name (string): Topic name
      • topic_type (string): Message topic type
  • ros2_service_list

    • Retruns list available services
    • Output:
      • service_name (string): Service name
      • service_type (string): Service type
      • request_fields (string array): Fields in service
  • ros2_service_call

    • Call ros2 service
    • Inputs:
      • service_name (string): Service name
      • service_type (string): Service type
      • fields (string array): Fields in service request filled with user data
      • force_call (bool): Force service call without every field in service field up, Default set to false
    • Output:
      • result (string): Return result of the service call
      • error (string): Return error in case of error
    • Features:
      • Check if service exists
      • Check if every field in service is provide
  • ros2_topic_subscribe

    • Subscribes to a ROS 2 topic and collects messages either for a duration or a message limit.
    • Inputs:
      • topic_name (string): Topic name
      • msg_type (string): Message type
      • duration (float): How long subscribe topic
      • message_limit (int): How many messages collect
      • Default to collect first message, waiting 5 seconds
    • Output:
      • messages: Serialized messages from topic
      • count: Number of collected messages
      • duration: How long messages has been collected
  • ros2_get_messages

    • Inputs:
      • topic_name (string): Topic name
      • message_type (string): Message type
      • number_of_msg(int): How many messages get from data black box
      • time_start (str): Start time for data retrieval. Only messages with timestamps after this will be returned
      • time_end (str): End time for data retrieval. Only messages with timestamps before this will be returned
    • Output:
      • timestamps: Time values used to indicate when each message was created, recorded, or received. Typically represented as ISO 8601 strings or UNIX epoch times. Used for filtering, ordering, and synchronizing data.
      • messages: Individual units of published data in ROS 2 topics. Each message contains a structured payload defined by its message type (e.g., std_msgs/msg/String).
  • ros2_get_message_fields

    • Inputs:
      • message_type (string): Message type
    • Output:
      • Returns the field names and types for a given ROS 2 message request type
  • ros2_topic_publish

    • Inputs:
      • topic_name (string): Topic name
      • message_type (string): Message type
      • data (dict): Dictionary with message fields
    • Output:
      • status: Status of publication
  • ros2_topic_echo_wait

    • Inputs:
      • topic_name (string): Topic name
      • message_type (string): Message type
      • timeout (float): Duration to wait for a message before giving up.
    • Output:
      • message: The deserialized ROS 2 message, converted to a Python dictionary (via message_to_ordereddict)
      • received: true, indicating the message was successfully received

Usage

MCP Server Configuration

NOTE

The server is running inside a Docker container as the root user. To communicate with other ROS components, they must also be run as root.

NOTE

Due to this issue, this MCP server doesn't work with Copilot in Visual Studio Code.

Docker run

Set MCP setting to mcp.json.

"mcp_server_ros_2": {
    "command": "docker",
    "args": [
        "run",
        "-i",
        "--rm",
        "wisevision/mcp_server_ros_2"
    ],
    }

Build docker image locally

git clone https://github.com/wise-vision/mcp_server_ros_2.git
cd mcp_server_ros_2
docker build -t wisevision/mcp_server_ros_2 .

Add this to AI Agent prompt:

You are an AI assistant that uses external tools via an MCP server.
Before calling any tool, always check your memory to see if the list of available tools is known.
	•	If you don’t have the current tool list in memory, your first action should be to call the list-tools tool.
	•	Never guess tool names or parameters.
	•	If a user requests something that may require a tool and you don’t have the right tool info, ask them or call list-tools first.
Once the tool list is loaded, you may call tools directly using their documented names and schemas.
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Serper MCP ServerA Serper MCP Server
DeepChatYour AI Partner on Desktop
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
CursorThe AI Code Editor
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Tavily Mcp
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
ChatWiseThe second fastest AI chatbot™
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Amap Maps高德地图官方 MCP Server
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
WindsurfThe new purpose-built IDE to harness magic