db1d565b64
Integration Tests / melodic (push) Has been cancelled
Integration Tests / noetic (push) Has been cancelled
Integration Tests / humble (push) Has been cancelled
Integration Tests / jazzy (push) Has been cancelled
Ruff Lint & Format / ruff (push) Has been cancelled
Sync main to develop / Check if sync is needed (push) Has been cancelled
Sync main to develop / Sync main to develop (push) Has been cancelled
1.6 KiB
1.6 KiB
Step 1: Custom / Programmatic Client
You can use the ROS-MCP server directly in your Python code using the MCP SDK.
Example
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def main():
server_params = StdioServerParameters(
command="uvx",
args=["ros-mcp", "--transport=stdio"]
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# Initialize the session
await session.initialize()
# List available tools
tools = await session.list_tools()
print(tools)
# Call a tool
result = await session.call_tool("get_topics", {})
print(result)
Prerequisites
- uv installed — see uv installation docs
- MCP Python SDK —
pip install mcp
Next Step
Set up rosbridge on the machine where ROS is running: Step 2: Rosbridge Setup
Advanced
- HTTP transport — run the MCP server as a standalone HTTP service instead of stdio
- Alternate installation methods:
- Install via pip — traditional
pip installor install from source with pip - Install from source — for developers who need to modify the server code
- Install via pip — traditional