Sandbox
@ajtudela/nav2_mcp_server

MCP server for Nav2 robot control

Nav2 MCP Server turns Nav2 navigation actions into MCP tools and resources. It supports moving to poses, following waypoints, docking, clearing costmaps, reading robot pose, canceling navigation, and managing Nav2 lifecycle state. The server can run over stdio or HTTP and is set up for ROS 2 environments.

84 stars24 forksPythonUpdated 3mo ago
Who it's for

Builders who want to connect Claude Desktop, Cursor, or other MCP clients to Nav2 robots.

What it delivers

You can control and monitor a Nav2 robot from an MCP client instead of wiring each ROS 2 action by hand.

What it does

Navigation tools

Provides tools for `navigate_to_pose`, `follow_waypoints`, `spin_robot`, `backup_robot`, `dock_robot`, and `undock_robot`.

Robot status and path tools

Exposes `get_robot_pose`, `get_path`, and `get_path_from_robot` for checking state and planning routes.

Costmap and lifecycle control

Lets you clear costmaps and start or shut down Nav2 with `clear_costmaps` and `nav2_lifecycle`.

Async task handling

Supports non-blocking navigation, progress updates, and cancellation with `cancel_navigation`.

ROS 2 and transport setup

Runs in ROS 2 Jazzy environments and supports `stdio` or `http` transport through environment settings.

How to get it

  1. 1Copy the environment configuration template
    cp .env.example .env
  2. 2Clone the repository and install with uv
    git clone https://github.com/ajtudela/nav2_mcp_server.git
    cd nav2_mcp_server
    # Set up ROS 2 environment variables if needed
    export ROS_DOMAIN_ID=0
    uv sync
  3. 3Or install directly from the repository
    uv add git+https://github.com/ajtudela/nav2_mcp_server.git
  4. 4Build the image
    docker build -t nav2-mcp-server:latest .
  5. 5Pull the latest image from the Docker registry
    docker pull ghcr.io/ajtudela/nav2_mcp_server:latest
  6. 6Run
    uv run nav2_mcp_server

README

Nav2 MCP Server

ROS2 License Build Docker image Python Dynamic TOML Badge codecov

An MCP (Model Context Protocol) server that provides tools and resources to control and monitor Nav2 navigation operations, allowing seamless integration with Nav2-enabled robots through the MCP protocol.

Demo of Nav2 MCP Server

Features

  • Navigation control: Navigate to specific poses, follow waypoint sequences, and execute precise robot movements
  • Real-time status: Monitor navigation progress, robot pose, and system status with comprehensive feedback
  • Costmap management: Clear stale obstacle data and manage navigation costmaps for optimal path planning
  • Lifecycle management: Control Nav2 system startup and shutdown for complete system control
  • ROS 2 integration: Full compatibility with Nav2 navigation stack and ROS 2 ecosystem
  • Async operations: Non-blocking navigation commands with progress monitoring and cancellation support

Tools

ToolDescriptionParameters
navigate_to_poseNavigate the robot to a specific pose (position and orientation) in the map framex: float, y: float, yaw: float
follow_waypointsNavigate the robot through a sequence of waypoints in orderwaypoints: str (JSON array)
spin_robotRotate the robot in place by a specified angleangle: float
backup_robotMove the robot backward by a specified distancedistance: float, speed: float
dock_robotDock the robot to a charging station or dockx: float, y: float, yaw: float, dock_id: str, dock_type: str, nav_to_dock: bool
undock_robotUndock the robot from a charging station or dockdock_type: str
clear_costmapsClear robot navigation costmaps to remove stale obstacle datacostmap_type: str
get_robot_poseGet the current position and orientation of the robot
cancel_navigationCancel the currently active navigation task
nav2_lifecycleControl Nav2 lifecycle (startup or shutdown)action: str
get_pathCompute a navigation path between two posesstart_x: float, start_y: float, start_yaw: float, goal_x: float, goal_y: float, goal_yaw: float, planner_id: str
get_path_from_robotCompute a navigation path from the robot's current pose to a goal posegoal_x: float, goal_y: float, goal_yaw: float, planner_id: str

Environment Variables

VariableDefaultDescription
ROS_DOMAIN_IDROS 2 domain ID for network isolation (recommended to set)
ROS_LOCALHOST_ONLYSet to '1' to restrict ROS 2 communication to localhost only

Configuration

Environment Variables

VariableDefaultDescription
TRANSPORT_MODEstdioTransport mode: stdio (local integration) or http (network)
HTTP_HOST0.0.0.0HTTP host binding (only used when TRANSPORT_MODE=http)
HTTP_PORT3001HTTP port (only used when TRANSPORT_MODE=http)
LOG_LEVELINFOLogging level: DEBUG, INFO, WARNING, ERROR, CRITICAL
ROS_DOMAIN_IDROS 2 domain ID for network isolation (recommended)
ROS_LOCALHOST_ONLYSet to '1' to restrict ROS 2 communication to localhost only

Setup

  1. Copy the environment configuration template:
cp .env.example .env
  1. Edit .env to customize settings:
# Transport mode: 'stdio' for local, 'http' for containerized/network
TRANSPORT_MODE=stdio

# HTTP settings (only needed if using http transport)
HTTP_HOST=0.0.0.0
HTTP_PORT=3001

# Logging
LOG_LEVEL=INFO

Installation

Dependencies

Install with uv

Clone the repository and install with uv:

git clone https://github.com/ajtudela/nav2_mcp_server.git
cd nav2_mcp_server
# Set up ROS 2 environment variables if needed
export ROS_DOMAIN_ID=0
uv sync

Or install directly from the repository:

uv add git+https://github.com/ajtudela/nav2_mcp_server.git

Docker

Build the image

Build the image:

docker build -t nav2-mcp-server:latest .

Pull the image

Pull the latest image from the Docker registry:

docker pull ghcr.io/ajtudela/nav2_mcp_server:latest

Usage

Running with uv

uv run nav2_mcp_server

Configuration example for Claude Desktop/Cursor/VSCode

Add this configuration to your application's settings (mcp.json):

Using uv (stdio transport)

{
  "nav2 mcp server": {
    "type": "stdio",
    "command": "uv",
    "args": [
      "run",
      "--directory",
      "/path/to/nav2_mcp_server",
      "nav2-mcp-server"
    ],
    "env": {
      "ROS_DOMAIN_ID": "0",
      "ROS_LOCALHOST_ONLY": "1"
    }
  }
}

Using Docker (stdio transport)

"nav2 mcp server": {
    "type": "stdio",
    "command": "docker",
    "args": [
        "run",
        "-i",
        "--rm",
        "ghcr.io/ajtudela/nav2_mcp_server"
    ],
    "env": {
      "ROS_DOMAIN_ID": "0",
      "ROS_LOCALHOST_ONLY": "1"
    }
}

Using HTTP transport

"nav2 mcp server": {
  "type": "http",
  "url": "http://localhost:3001/mcp",
  "env": {
    "TRANSPORT_MODE": "http",
    "LOG_LEVEL": "INFO"
  }
}

Files in the repo

Repository payload16 top-level entries
  • .github
  • docs
  • src
  • tests
  • .dockerignore
  • .env.example
  • .flake8
  • .gitignore
  • .pep8
  • Dockerfile
  • LICENSE
  • mcp.json
  • package.xml
  • pyproject.toml
  • README.md
  • uv.lock

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface

86k

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k

Open-source auth gateway connecting 1400+ SaaS providers to AI agents through SDK, CLI, MCP, HTTP, and OpenAPI.

5.7k

Open-source 3D architectural editor with a local CLI, MCP tools, and practical workflows for humans and AI agents.

23k
cinderline/
northcinder

Open-source MCP server for comparing products and asking the buyer before purchase.

1.2k
czlonkowski/
n8n-mcp

A MCP for Claude Desktop / Claude Code / Windsurf / Cursor to build n8n workflows for you

23k