Google Home MCP Server

by jmagar
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Implements Smart Home API intents for Google Assistant, handling device discovery, state queries, and command execution for smart home devices.

  • Integrates with Google Cloud Project for enabling the Smart Home API, necessary for the authentication and operation of the Google Home device control.

  • Allows control of Google Home smart plugs, enabling listing of available devices, turning them on/off, and monitoring their real-time status through the Smart Home API.

Google Home MCP 服务器

用于通过智能家居 API 控制 Google Home 智能插头的 MCP 服务器实现。

特征

  • 列出所有可用的智能插头及其状态
  • 控制智能插头(打开/关闭)
  • 获取特定智能插头的实时状态
  • 自动设备状态刷新
  • 使用智能家居 API 进行 OAuth2 身份验证

先决条件

  1. 已启用智能家居 API 的 Google Cloud 项目
  2. Google 智能家居行动项目
  3. 智能家居操作的 OAuth 2.0 客户端凭据
  4. Node.js 18 或更高版本
  5. 访问 Google Home 智能插头

设置

  1. 创建智能家居动作:
    • 前往Google 控制台上的操作
    • 创建新项目
    • 选择“智能家居”作为项目类型
    • 配置帐户链接:
      • OAuth 客户端 ID
      • OAuth 客户端密钥
      • 授权网址
      • 令牌 URL
  2. 设置 OAuth 2.0:
    • 配置您的 OAuth 服务器端点
    • 设置用户身份验证流程
    • 实现令牌生成/验证
  3. 安装依赖项:
pnpm install
  1. 配置服务器:
    • config.json.example复制到config.json
    • 填写您的:
      • OAuth 客户端 ID
      • OAuth 客户端密钥
  2. 构建服务器:
pnpm build
  1. 启动服务器:
pnpm start

可用工具

1. 列出智能插头

{ name: "list_smart_plugs", description: "List all available smart plugs and their current states", response: Array<{ id: string; name: string; state: { on: boolean; online: boolean; } }> }

2. 控制智能插头

{ name: "control_smart_plug", description: "Turn a smart plug on or off", parameters: { deviceId: string; // Device ID from list_smart_plugs state: boolean; // true for on, false for off }, response: { success: boolean; device: { id: string; name: string; state: { on: boolean; online: boolean; } } } }

3. 获取智能插座状态

{ name: "get_smart_plug_state", description: "Get the current state of a specific smart plug", parameters: { deviceId: string; // Device ID from list_smart_plugs }, response: { id: string; name: string; state: { on: boolean; online: boolean; } } }

API 详细信息

服务器实现智能家居 API 意图:

  1. 同步意图
    • 当用户关联其帐户时调用
    • 报告可用的设备和功能
    • 处理设备发现
  2. 查询意图
    • 报告设备当前状态
    • 处理来自 Google Assistant 的状态查询
    • 返回在线/离线状态
  3. 执行意图
    • 处理设备控制命令
    • 执行开/关操作
    • 报告命令成功/失败

错误处理

服务器实现了全面的错误处理,并提供了特定的错误代码:

  • CONFIG_ERROR :配置加载或验证错误
  • API_ERROR :智能家居 API 错误
  • DEVICE_NOT_FOUND :在可用设备中未找到设备 ID
  • COMMAND_ERROR :执行设备命令时出错

每个错误包括:

  • 错误信息
  • 错误代码
  • 详细错误信息(如果有)

安全

  • OAuth 2.0 身份验证流程
  • 安全令牌处理
  • 请求验证
  • 命令授权
  • HTTPS 通信
  • 输入清理

发展

  1. 以开发模式启动:
pnpm dev
  1. 运行测试:
pnpm test
  1. 调试日志:
    • 所有 API 调用均已记录
    • 捕获错误详细信息
    • 跟踪设备状态变化

贡献

  1. 分叉存储库
  2. 创建功能分支
  3. 提交你的更改
  4. 推送到分支
  5. 创建拉取请求

执照

麻省理工学院

ghome-mcp-服务器

-
security - not tested
F
license - not found
-
quality - not tested

使用户能够使用具有 OAuth2 身份验证的智能家居 API 控制 Google Home 智能插头,提供实时设备状态管理和控制操作。

  1. Features
    1. Prerequisites
      1. Setup
        1. Available Tools
          1. 1. List Smart Plugs
          2. 2. Control Smart Plug
          3. 3. Get Smart Plug State
        2. API Details
          1. Error Handling
            1. Security
              1. Development
                1. Contributing
                  1. License
                    1. ghome-mcp-server
                      ID: 8gner2riks