Ouster激光雷达MCP服务器
一种模型上下文协议(MCP)服务器,通过标准化的API提供对Ouster Lidar传感器的访问。该服务器允许AI模型和其他客户端通过一组定义良好的工具功能与Ouster Lidar传感器进行交互。
特性
- 连接和断开Ouster Lidar传感器
- 获取详细的传感器信息
- 捕获激光雷达扫描
- 配置传感器参数
- 支持多个传感器同时连接
- 直接从GitHub运行
uvx不进行本地克隆
需求
- Python 3.11或更高版本
- Ouster SDK 0.14.0或更高版本(使用时自动安装
uvx) - MCP库1.7.1或更高版本(使用时自动安装
uvx) - uv包管理器(包括
uvx)
安装
- 克隆此存储库
- 创建并激活虚拟环境:
# Create virtual environment
uv venv
# Activate it
source .venv/bin/activate # On Unix/macOS
.venv\Scripts\activate # On Windows- 安装依赖项:
# Basic installation
uv pip install -e .
# With development dependencies (for running tests)
uv pip install -e ".[dev]"用法
启动服务器
服务器可以通过多种方式运行:
选项1:直接运行 uvx (推荐,不需要本地克隆)
直接从GitHub运行 uvx:
# Start with default settings (stdio transport)
uvx --from git+https://github.com/jmdaly/ouster-lidar-mcp-server.git ouster-mcp-server
# Enable debug logging
uvx --from git+https://github.com/jmdaly/ouster-lidar-mcp-server.git ouster-mcp-server --debug
# Run with SSE transport (localhost:8080)
uvx --from git+https://github.com/jmdaly/ouster-lidar-mcp-server.git ouster-mcp-server --sse
# Specify host and port for SSE
uvx --from git+https://github.com/jmdaly/ouster-lidar-mcp-server.git ouster-mcp-server --sse --host 0.0.0.0 --port 9000选项2:从本地克隆
如果已克隆存储库:
1.标准I/O(stdio)传输:
# Start with default settings
python main.py
# Enable debug logging
python main.py --debug2.通过HTTP传输服务器发送事件(SSE):
# Start with default settings (localhost:8080)
python main.py --sse
# Specify host and port
python main.py --sse --host 0.0.0.0 --port 9000
# Enable debug logging
python main.py --sse --debug选项3:作为安装包
如果您已安装该软件包:
# Start with default settings
ouster-mcp-server
# Enable debug logging
ouster-mcp-server --debug
# Run with SSE transport
ouster-mcp-server --sse测试服务器
提供测试客户端以验证服务器功能:
对于stdio传输:
python test_client.py --server-script main.py --sensor your-sensor-hostname对于SSE运输:
# Start the server in one terminal
python main.py --sse
# Run the test client in another terminal
python test_client.py --server-url http://localhost:8080 --sensor your-sensor-hostname与Claude等MCP客户端一起使用
- 使用上述方法之一启动服务器(直接
uvx、stdio或SSE传输) - 使用Claude Desktop或任何其他MCP兼容客户端连接到服务器
- 使用提供的工具与Ouster激光雷达传感器进行交互
使用Claude Desktop进行最快的设置:
# This runs the server directly from GitHub - no local clone needed
uvx --from git+https://github.com/jmdaly/ouster-lidar-mcp-server.git ouster-mcp-server --sse然后将Claude Desktop连接到 http://localhost:8080
可用工具
服务器提供以下工具功能:
connect_sensor-连接到Ouster激光雷达传感器disconnect_sensor-断开与Ouster激光雷达传感器的连接get_sensor_info-获取有关连接传感器的详细信息get_connected_sensors-列出所有连接的传感器capture_single_scan-从连接的传感器捕获单次扫描set_sensor_config-配置传感器参数
Claude中的示例用法
以下是如何使用Claude中的工具的示例:
> tool ouster_lidar.connect_sensor
{
"hostname": "os-122200123456.local"
}
Response:
{
"status": "connected",
"sensor_info": {
"hostname": "os-122200123456.local",
"serial": "122200123456",
"model": "OS-1-64",
"firmware_version": "v2.4.0"
}
}
> tool ouster_lidar.capture_single_scan
{
"hostname": "os-122200123456.local"
}
Response:
{
"status": "success",
"scan_summary": {
"frame_id": 42,
"scan_shape": {
"h": 64,
"w": 1024
},
"range_stats": {
"min": 0.0,
"max": 85.23,
"mean": 12.45
},
"signal_stats": {
"min": 0.0,
"max": 255.0,
"mean": 45.78
},
"reflectivity_stats": {
"min": 0.0,
"max": 255.0,
"mean": 35.62
},
"num_valid_returns": 45678
}
}发展
项目结构
main.py-核心服务器实现test_client.py-用于测试服务器功能的客户端tests/-服务器和客户端的单元测试README.md-文件
添加新工具
要添加新的工具功能,请执行以下操作:
- 使用以下命令实现async函数
@mcp.tool()装饰器 - 确保为参数和返回类型提供类型提示
- 添加全面的文档字符串来描述功能
例子:
@mcp.tool()
async def my_new_tool(param1: str, param2: int) -> Dict[str, Any]:
"""
Description of what the tool does.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Dictionary with results
"""
# Implementation
return {"result": "success"}运行测试
该项目包括对服务器和客户端功能的全面单元测试:
# Run all tests
pytest
# Run specific test file
pytest tests/test_server.py
# Run with verbose output
pytest -v
# Run with code coverage report
pytest --cov=.进一步增强
未来发展的一些潜在增强功能:
- 添加对记录/回放激光雷达数据的支持
- 实现点云可视化功能
- 添加对多传感器校准和注册的支持
- 实施先进的点云处理算法
