RViz Map Image MCP
Converts a live ROS 2 occupancy map into shareable images (PNG/JPEG/base64) and provides tools for map metadata, coordinate conversion, corner goal finding, and Nav2 navigation commands.
README
RViz Map Image MCP
FastMCP tools for converting a live ROS 2 occupancy map into a shareable image.
The server subscribes to the same nav_msgs/msg/OccupancyGrid data that RViz
uses for a 2D map display, usually /map, then returns PNG/JPEG images,
base64 payloads, metadata, corner goals, and optional Nav2 navigation commands.
This is useful when an AI agent needs to inspect the robot's current map, send the map image to a user, convert between map coordinates and pixels, or navigate to coarse locations such as the map corners.
Features
- Render a live ROS 2 occupancy grid as an RViz-style map image.
- Return images as base64, data URIs, or saved PNG/JPEG files.
- Include map metadata: resolution, origin, image size, occupancy statistics, and pixel-to-world conventions.
- Mark the robot pose and safe corner goals on the rendered image.
- Convert map-frame world coordinates to rendered-image pixels and back.
- Find safe free-space goals near
top_left,top_right,bottom_left, andbottom_right. - Validate candidate navigation goals against the map and optional costmap.
- Send Nav2
NavigateToPosegoals to coordinates or named corners.
Files
occupancy_map_to_image.py One-shot CLI map capture script
map_image_mcp_server.py FastMCP server with map image and navigation tools
mcp_config_example.json Example MCP client configuration
requirements.txt Python dependencies outside the ROS install
Requirements
- ROS 2 with Python support, tested with Humble-era APIs.
- A live
nav_msgs/msg/OccupancyGridtopic such as/map. - For navigation tools: Nav2
nav2_msgs/action/NavigateToPose. - Python packages:
python3 -m pip install --user -r requirements.txt
ROS message packages such as rclpy, nav_msgs, geometry_msgs,
nav2_msgs, and tf2_ros should come from your ROS 2 installation, not pip.
One-Shot Map Capture
cd /home/bharat/Desktop/rviz_map_image_mcp
python3 occupancy_map_to_image.py \
--map-topic /map \
--output /home/bharat/Desktop/rviz_map_captures/latest_map.png \
--draw-corners \
--draw-legend
Useful options:
--return-base64 include base64 image data in the JSON output
--scale 2 render at 2 pixels per map cell before max-side limiting
--max-image-side 1600 cap the longest rendered side
--no-flip-y keep raw occupancy-grid row order
--use-sim-time use ROS simulated time
The command prints JSON with the saved image path, map metadata, and optionally base64 image data.
MCP Server
Run over stdio:
cd /home/bharat/Desktop/rviz_map_image_mcp
python3 map_image_mcp_server.py --transport stdio
Run over streamable HTTP:
cd /home/bharat/Desktop/rviz_map_image_mcp
python3 map_image_mcp_server.py \
--transport streamable-http \
--host 127.0.0.1 \
--port 8767
Default ROS topics and frames:
/map
/global_costmap/costmap
/odom
/navigate_to_pose
map
base_footprint
Override them with CLI flags or the configure_topics MCP tool.
MCP Client Config
Stdio example:
{
"mcpServers": {
"rviz-map-image-stdio": {
"name": "RViz Map Image MCP",
"transport": "stdio",
"command": "python3",
"args": [
"/home/bharat/Desktop/rviz_map_image_mcp/map_image_mcp_server.py",
"--transport",
"stdio"
]
}
}
}
HTTP example:
{
"mcpServers": {
"rviz-map-image-http": {
"name": "RViz Map Image MCP HTTP",
"transport": "http",
"url": "http://127.0.0.1:8767/mcp"
}
}
}
MCP Tools
server_status
list_map_topics
configure_topics
summarize_map
get_map_image
save_map_image
get_map_corners
world_to_pixel
pixel_to_world
get_robot_pose
validate_goal
navigate_to_coordinate
navigate_to_corner
Image Tools
get_map_image returns an image and metadata. Important options:
return_base64=true return image_base64 and mime_type
save=true save a copy to disk
save_path=... choose a specific output path
draw_robot=true overlay the current robot pose when TF/odom is available
draw_corners=true overlay safe corner goals
draw_legend=true overlay occupancy legend
scale=1.0
max_image_side=1600
save_map_image is a convenience wrapper that saves by default under:
/home/bharat/Desktop/rviz_map_captures
Coordinate Tools
With the default flip_y=true, image right is +map_x and image up is
+map_y, matching the normal top-down RViz view. The server returns the exact
image dimensions and transform metadata with each rendered image.
Use:
world_to_pixel
pixel_to_world
to connect visual annotations back to map-frame coordinates.
Navigation Tools
get_map_corners returns safe free-space goals near:
top_left
top_right
bottom_left
bottom_right
navigate_to_corner accepts those IDs, plus:
nearest
farthest
navigate_to_coordinate sends a Nav2 NavigateToPose action after optional
goal validation.
Notes
This server reads the ROS occupancy grid, not RViz internals. RViz and this
tool should show the same map when they subscribe to the same /map topic.
The companion UGV workspace package src/ugv_main/ugv_navigation_mcp provides
more geometry-focused navigation tools, including Hough-style room-corner
detection. This project is focused on visual map access and lightweight
map-corner interaction for AI agents.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。