A MCP server that provides ROS topic publishing functionality via rosbridge
Project description
Rosbridge MCP Server
A Model Context Protocol (MCP) server that provides tools to publish messages to ROS topics via rosbridge. This is a Python implementation demonstrating ROS integration with MCP servers.
Features
- Publish messages to any ROS topic via rosbridge WebSocket
- Configurable rosbridge connection via environment variables
- Support for any ROS message type
- Simple tool:
publish_topic
Usage
Choose one of these examples based on your needs:
Basic usage (localhost):
{
"mcpServers": {
"rosbridge": {
"command": "uvx",
"args": ["takanarishimbo-rosbridge-mcp-server"]
}
}
}
Custom rosbridge host:
{
"mcpServers": {
"rosbridge": {
"command": "uvx",
"args": ["takanarishimbo-rosbridge-mcp-server"],
"env": {
"ROSBRIDGE_HOST": "192.168.1.100",
"ROSBRIDGE_PORT": "9090"
}
}
}
}
Remote ROS system:
{
"mcpServers": {
"rosbridge": {
"command": "uvx",
"args": ["rosbridge-mcp-server"],
"env": {
"ROSBRIDGE_HOST": "ros-robot.local",
"ROSBRIDGE_PORT": "9091"
}
}
}
}
Configuration
The server can be configured using environment variables:
ROSBRIDGE_HOST
The rosbridge server host (default: "localhost")
Examples:
localhost: Local rosbridge192.168.1.100: Remote IP addressros-robot.local: Hostname
ROSBRIDGE_PORT
The rosbridge server port (default: "9090")
Standard rosbridge WebSocket port is 9090.
Available Tools
publish_topic
Publish a message to a ROS topic
Parameters:
topic(required): The ROS topic name (e.g., "/cmd_vel")message_type(required): The ROS message type (e.g., "geometry_msgs/Twist")message(required): The message data as a JSON object
Example usage:
{
"name": "publish_topic",
"arguments": {
"topic": "/cmd_vel",
"message_type": "geometry_msgs/Twist",
"message": {
"linear": { "x": 0.5, "y": 0.0, "z": 0.0 },
"angular": { "x": 0.0, "y": 0.0, "z": 0.1 }
}
}
}
Development
-
Clone this repository
git clone https://github.com/TakanariShimbo/rosbridge-mcp-server.git cd rosbridge-mcp-server
-
Install dependencies using uv
uv sync -
Start rosbridge on your ROS system
roslaunch rosbridge_server rosbridge_websocket.launch
-
Run the server
uv run takanarishimbo-rosbridge-mcp-server
-
Test with MCP Inspector (optional)
npx @modelcontextprotocol/inspector uv run takanarishimbo-rosbridge-mcp-server
Publishing to PyPI
This project uses PyPI's Trusted Publishers feature for secure, token-less publishing via GitHub Actions.
1. Configure PyPI Trusted Publisher
-
Log in to PyPI (create account if needed)
- Go to https://pypi.org/
-
Navigate to Publishing Settings
- Go to your account settings
- Click on "Publishing" or go to https://pypi.org/manage/account/publishing/
-
Add GitHub Publisher
- Click "Add a new publisher"
- Select "GitHub" as the publisher
- Fill in:
- Owner:
TakanariShimbo(your GitHub username/org) - Repository:
rosbridge-mcp-server - Workflow name:
pypi-publish.yml - Environment:
pypi(optional but recommended)
- Owner:
- Click "Add"
2. Configure GitHub Environment (Recommended)
-
Navigate to Repository Settings
- Go to your GitHub repository
- Click "Settings" → "Environments"
-
Create PyPI Environment
- Click "New environment"
- Name:
pypi - Configure protection rules (optional):
- Add required reviewers
- Restrict to specific branches/tags
3. Setup GitHub Personal Access Token (for release script)
The release script needs to push to GitHub, so you'll need a GitHub token:
-
Create GitHub Personal Access Token
- Go to https://github.com/settings/tokens
- Click "Generate new token" → "Generate new token (classic)"
- Set expiration (recommended: 90 days or custom)
- Select scopes:
- ✅
repo(Full control of private repositories)
- ✅
- Click "Generate token"
- Copy the generated token (starts with
ghp_)
-
Configure Git with Token
# Option 1: Use GitHub CLI (recommended) gh auth login # Option 2: Configure git to use token git config --global credential.helper store # Then when prompted for password, use your token instead
4. Release New Version
Use the release script to automatically version, tag, and trigger publishing:
# First time setup
chmod +x scripts/release.sh
# Increment patch version (0.1.0 → 0.1.1)
./scripts/release.sh patch
# Increment minor version (0.1.0 → 0.2.0)
./scripts/release.sh minor
# Increment major version (0.1.0 → 1.0.0)
./scripts/release.sh major
# Set specific version
./scripts/release.sh 1.2.3
5. Verify Publication
-
Check GitHub Actions
- Go to "Actions" tab in your repository
- Verify the "Publish to PyPI" workflow completed successfully
-
Verify PyPI Package
- Visit: https://pypi.org/project/rosbridge-mcp-server/
- Or run:
pip show rosbridge-mcp-server
Release Process Flow
release.shscript updates version in all files- Creates git commit and tag
- Pushes to GitHub
- GitHub Actions workflow triggers on new tag
- Workflow uses OIDC to authenticate with PyPI (no tokens needed!)
- Workflow builds project and publishes to PyPI
- Package becomes available globally via
pip installoruvx
Code Quality
This project uses ruff for linting and formatting:
# Run linter
uv run ruff check
# Fix linting issues
uv run ruff check --fix
# Format code
uv run ruff format
Project Structure
rosbridge-mcp-server/
├── src/
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Main entry point
│ └── server.py # Server implementation
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock file
├── .github/
│ └── workflows/
│ └── pypi-publish.yml # PyPI publish workflow with Trusted Publishers
├── scripts/
│ └── release.sh # Release automation script
├── README.md # This file
└── .gitignore # Git ignore file
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file takanarishimbo_rosbridge_mcp_server-0.2.0.tar.gz.
File metadata
- Download URL: takanarishimbo_rosbridge_mcp_server-0.2.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ff16d320bd44e2fd650f9485eca876a5c8cf64004040d21436cdabb1ef5752e
|
|
| MD5 |
821acf9c70ff06de84940d348023e4fe
|
|
| BLAKE2b-256 |
f712c243e5516172301fda39cf55d249bd5854690d251ab8a5d445b9cd1fc48b
|
File details
Details for the file takanarishimbo_rosbridge_mcp_server-0.2.0-py3-none-any.whl.
File metadata
- Download URL: takanarishimbo_rosbridge_mcp_server-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7682b41ba3c69500686ac73090a1960676f9d8c60c1a134613cb98fa529c7a5a
|
|
| MD5 |
08c2e19162754aa25136de81fc64f1d0
|
|
| BLAKE2b-256 |
c4c3ba285725df2db92acb9f8821bd4a2cdb5152b1ea6194ae471ee4605879f0
|