Govee LED控制服务

一个通过Govee API控制Govee LED设备的MCP服务器,提供开关、颜色调节和亮度控制功能。

  • by mathd
  • Python
  • 本地部署
  • 6 星标
  • 更新于
在 GitHub 查看 mathd/govee_mcp_server

使用说明

Govee MCP服务器

MCP服务器,用于通过Govee API控制Govee LED设备。

设置

环境变量

创建一个 .env 根目录中的文件,包含以下变量:

GOVEE_API_KEY=your_api_key_here
GOVEE_DEVICE_ID=your_device_id_here
GOVEE_SKU=your_device_sku_here

要获取这些值:

  1. 从Govee开发者门户获取您的API密钥
  2. 使用Govee Home应用程序查找您的设备ID和SKU

安装

通过Smithery安装

通过以下方式自动安装克劳德桌面版Govee MCP服务器 史密瑟里:

npx -y @smithery/cli install @mathd/govee_mcp_server --client claude

手动安装

# Install with pip
pip install .

# For development (includes test dependencies)
pip install -e ".[test]"

用法

MCP服务器

MCP服务器提供通过模型上下文协议控制Govee设备的工具。它可以与Cline或其他MCP客户端一起使用。

可用工具:

  • turn_on_off:打开或关闭LED
  • set_color:使用RGB值设置LED颜色
  • set_brightness:设置LED亮度级别

命令行接口

提供CLI以直接控制Govee设备:

# Turn device on/off
govee-cli power on
govee-cli power off

# Set color using RGB values (0-255)
govee-cli color 255 0 0  # Red
govee-cli color 0 255 0  # Green
govee-cli color 0 0 255  # Blue

# Set brightness (0-100)
govee-cli brightness 50

跑 govee-cli --help 获取完整的命令文档。

发展

运行测试

要运行测试套件,请执行以下操作:

# Install test dependencies
pip install -e ".[test]"

# Run all tests
pytest tests/

# Run specific test files
pytest tests/test_server.py  # Server tests (mocked API calls)
pytest tests/test_cli.py    # CLI tests (real API calls)

# Run tests with verbose output
pytest tests/ -v

注:CLI测试对Govee设备进行真正的API调用,并将实际控制它。在运行这些测试之前,请确保设备已通电并已连接。

项目结构

.
├── src/govee_mcp_server/
│   ├── __init__.py
│   ├── server.py    # MCP server implementation
│   └── cli.py       # Command-line interface
├── tests/
│   ├── test_server.py  # Server tests (with mocked API)
│   └── test_cli.py     # CLI tests (real API calls)
└── pyproject.toml      # Project configuration

测试覆盖率

  • 服务器测试包括:

    • 环境初始化
    • Govee API客户端方法
    • 服务器工具和实用程序
    • 错误处理
  • CLI测试通过执行实际的API调用来控制Govee设备,从而执行真实世界的集成测试。