{"id":"f05086ce-e13d-448c-ac84-cd0152c62b77","entityType":"agent","slug":"clawhub-toddpan-feyagate","name":"Feyagate","canonicalUrl":"https://www.xpersona.co/agent/clawhub-toddpan-feyagate","canonicalPath":"/agent/clawhub-toddpan-feyagate","generatedAt":"2026-10-12T12:05:45.577Z","source":"CLAWHUB","claimStatus":"UNCLAIMED","verificationTier":"NONE","summary":{"evidence":{"source":"editorial-content","verified":true,"confidence":"high","updatedAt":"2026-10-11T23:08:24.753Z","emptyReason":null},"description":"MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol. Skill: Feyagate Owner: toddpan Summary: MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol. Tags: latest:1.0.9 Version history: v1.0.9 | 2026-06-05T23:45:13.858Z | auto - Major refactor: skill was simplified with most Python code and scripts removed. - SKILL.md restructured and updated for clarity, with enhanced metadata and improved platform summ","descriptionLabel":"Technical summary","evidenceSummary":"Capability contract not published. No trust telemetry is available yet. 979 downloads reported by the source. Last updated 10/11/2026.","installCommand":"clawhub skill install s175wd5ntjvmg1jg3apxgq5csn8597qy:feyagate","sourceUrl":"https://clawhub.ai/toddpan/feyagate","homepage":"https://clawhub.ai/toddpan/skills/feyagate","primaryLinks":[{"label":"View on ClawHub","url":"https://clawhub.ai/toddpan/feyagate","kind":"source"},{"label":"Homepage","url":"https://clawhub.ai/toddpan/skills/feyagate","kind":"homepage"}],"safetyScore":84,"overallRank":62,"popularityScore":60,"trustScore":null,"claimedByName":null,"isOwner":false,"seoDescription":"MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol. Skill: Feyagate Owner: toddpan Summar"},"coverage":{"evidence":{"source":"public-profile","verified":false,"confidence":"medium","updatedAt":"2026-10-11T23:08:24.753Z","emptyReason":null},"protocols":[{"protocol":"OPENCLEW","label":"OpenClaw","status":"self-declared","notes":"Declared in the public agent profile."}],"capabilities":[],"verifiedCount":0,"selfDeclaredCount":1,"capabilityMatrix":{"rows":[{"key":"OPENCLEW","type":"protocol","support":"unknown","confidenceSource":"profile","notes":"Listed on profile"}],"flattenedTokens":"protocol:OPENCLEW|unknown|profile"}},"adoption":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T23:08:24.753Z","emptyReason":null},"stars":null,"forks":null,"downloads":979,"likes":null,"task":null,"library":null,"packageName":null,"latestVersion":"1.0.9","tractionLabel":"979 downloads"},"release":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"medium","updatedAt":"2026-10-11T23:08:24.739Z","emptyReason":null},"lastUpdatedAt":"2026-10-11T23:08:24.753Z","lastCrawledAt":"2026-10-11T23:08:24.739Z","lastIndexedAt":null,"nextCrawlAt":"2026-10-12T23:08:24.739Z","lastVerifiedAt":null,"highlights":[{"version":"1.0.9","createdAt":"2026-06-05T23:45:13.858Z","changelog":"- Major refactor: skill was simplified with most Python code and scripts removed. - SKILL.md restructured and updated for clarity, with enhanced metadata and improved platform summaries. - Documentation greatly condensed; details now reference QUICKSTART.md and companion guides. - Most implementation files, scripts, and secondary docs deleted; setup is now external or delegated. - Troubleshooting, license, and configuration sections streamlined. - Sub-skill loading, naming, and CLI instructions clarified.","fileCount":12,"zipByteSize":35075},{"version":"1.0.8","createdAt":"2026-05-25T23:15:30.684Z","changelog":"- Added user guides for Hermes and OpenClaw platforms (docs/hermes-guide.md, docs/openclaw-guide.md) - Updated skill code and documentation to support new guides - Minor improvements and maintenance in core files (README.md, auth.py, installer.py, pyproject.toml) - No changes to the public API or skill interface","fileCount":62,"zipByteSize":134654},{"version":"1.0.7","createdAt":"2026-05-24T10:14:47.116Z","changelog":"- Initial public Python release with CLI, modular architecture, and core gateway skill system. - Added main feyagate CLI tool and service lifecycle management (setup/start/stop/status/log/upgrade/auth). - Introduced cross-platform device control and status tools for Xiaomi, Tuya, Midea, eWeLink, serial, GPIO. - Integrated sub-skill system (automation, extension, platform-specific skills) with trigger-based loading. - Included advanced manual install scripts, full documentation, and API references. - Implemented license management: free (Xiaomi-only) and licensed (all platforms) editions.","fileCount":59,"zipByteSize":126034},{"version":"1.0.6","createdAt":"2026-05-24T00:42:40.745Z","changelog":"Feyagate-skill 1.0.6 Changelog - Added detailed SKILL.md documentation describing cross-platform smart home gateway usage, endpoints, commands, and modular sub-skills. - Sub-skills for Xiaomi, Tuya, Midea, eWeLink, Automation, and Extension now documented with triggers and usage guidance. - Included CLI usage for installation, status, authentication, and manual scripts for Linux/macOS/Windows. - Provided license requirement details distinguishing free vs. licensed features. - Added configuration sample and troubleshooting guide for common setup and runtime issues. - Outlined the recommended workflow for integrating with compatible AI agents and platforms.","fileCount":39,"zipByteSize":76931}]},"execution":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No published capability contract is available yet."},"installCommand":"clawhub skill install s175wd5ntjvmg1jg3apxgq5csn8597qy:feyagate","setupComplexity":"low","setupSteps":["Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.","Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data."],"contract":{"contractStatus":"missing","authModes":[],"requires":[],"forbidden":[],"supportsMcp":false,"supportsA2a":false,"supportsStreaming":false,"inputSchemaRef":null,"outputSchemaRef":null,"dataRegion":null,"contractUpdatedAt":null,"sourceUpdatedAt":null,"freshnessSeconds":null},"invocationGuide":{"preferredApi":{"snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/trust"},"curlExamples":["curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/snapshot\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/contract\"","curl -s \"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/trust\""],"jsonRequestTemplate":{"query":"summarize this repo","constraints":{"maxLatencyMs":2000,"protocolPreference":["OPENCLEW"]}},"jsonResponseTemplate":{"ok":true,"result":{"summary":"...","confidence":0.9},"meta":{"source":"CLAWHUB","generatedAt":"2026-10-12T12:05:45.574Z"}},"retryPolicy":{"maxAttempts":3,"backoffMs":[500,1500,3500],"retryableConditions":["HTTP_429","HTTP_503","NETWORK_TIMEOUT"]}},"endpoints":{"dossierUrl":"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/dossier","snapshotUrl":"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/snapshot","contractUrl":"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/contract","trustUrl":"https://www.xpersona.co/api/v1/agents/clawhub-toddpan-feyagate/trust"}},"reliability":{"evidence":{"source":"runtime-metrics","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No trust, reliability, or runtime telemetry is available."},"trust":{"status":"unavailable","handshakeStatus":"UNKNOWN","verificationFreshnessHours":null,"reputationScore":null,"p95LatencyMs":null,"successRate30d":null,"fallbackRate":null,"attempts30d":null,"trustUpdatedAt":null,"trustConfidence":"unknown","sourceUpdatedAt":null,"freshnessSeconds":null},"decisionGuardrails":{"doNotUseIf":["Contract metadata is missing or unavailable for deterministic execution."],"safeUseWhen":[],"riskFlags":["missing_or_unavailable_contract","trust_data_unavailable","schema_references_missing"],"operationalConfidence":"low"},"executionMetrics":{"observedLatencyMsP50":null,"observedLatencyMsP95":null,"estimatedCostUsd":null,"uptime30d":null,"rateLimitRpm":null,"rateLimitBurst":null,"lastVerifiedAt":null,"verificationSource":null},"runtimeMetrics":{"successRate":null,"avgLatencyMs":null,"avgCostUsd":null,"hallucinationRate":null,"retryRate":null,"disputeRate":null,"p50Latency":null,"p95Latency":null,"lastUpdated":null}},"benchmarks":{"evidence":{"source":"no-benchmark-data","verified":false,"confidence":"low","updatedAt":null,"emptyReason":"No benchmark suites or observed failure patterns are available."},"suites":[],"failurePatterns":[]},"artifacts":{"evidence":{"source":"CLAWHUB","verified":false,"confidence":"high","updatedAt":"2026-10-11T23:08:24.753Z","emptyReason":null},"readme":"Skill: Feyagate\n\nOwner: toddpan\n\nSummary: MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol.\n\nTags: latest:1.0.9\n\nVersion history:\n\nv1.0.9 | 2026-06-05T23:45:13.858Z | auto\n\n- Major refactor: skill was simplified with most Python code and scripts removed.\n- SKILL.md restructured and updated for clarity, with enhanced metadata and improved platform summaries.\n- Documentation greatly condensed; details now reference QUICKSTART.md and companion guides.\n- Most implementation files, scripts, and secondary docs deleted; setup is now external or delegated.\n- Troubleshooting, license, and configuration sections streamlined.\n- Sub-skill loading, naming, and CLI instructions clarified.\n\nv1.0.8 | 2026-05-25T23:15:30.684Z | auto\n\n- Added user guides for Hermes and OpenClaw platforms (docs/hermes-guide.md, docs/openclaw-guide.md)\n- Updated skill code and documentation to support new guides\n- Minor improvements and maintenance in core files (README.md, auth.py, installer.py, pyproject.toml)\n- No changes to the public API or skill interface\n\nv1.0.7 | 2026-05-24T10:14:47.116Z | auto\n\n- Initial public Python release with CLI, modular architecture, and core gateway skill system.\n- Added main feyagate CLI tool and service lifecycle management (setup/start/stop/status/log/upgrade/auth).\n- Introduced cross-platform device control and status tools for Xiaomi, Tuya, Midea, eWeLink, serial, GPIO.\n- Integrated sub-skill system (automation, extension, platform-specific skills) with trigger-based loading.\n- Included advanced manual install scripts, full documentation, and API references.\n- Implemented license management: free (Xiaomi-only) and licensed (all platforms) editions.\n\nv1.0.6 | 2026-05-24T00:42:40.745Z | auto\n\nFeyagate-skill 1.0.6 Changelog\n\n- Added detailed SKILL.md documentation describing cross-platform smart home gateway usage, endpoints, commands, and modular sub-skills.\n- Sub-skills for Xiaomi, Tuya, Midea, eWeLink, Automation, and Extension now documented with triggers and usage guidance.\n- Included CLI usage for installation, status, authentication, and manual scripts for Linux/macOS/Windows.\n- Provided license requirement details distinguishing free vs. licensed features.\n- Added configuration sample and troubleshooting guide for common setup and runtime issues.\n- Outlined the recommended workflow for integrating with compatible AI agents and platforms.\n\nArchive index:\n\nArchive v1.0.9: 12 files, 35075 bytes\n\nFiles: FeyaGate_HTTP_API.md (24768b), FeyaGate_MCP_API.md (45334b), QUICKSTART.md (10469b), skill-card.md (2454b), SKILL.md (5683b), skills/automation.md (2473b), skills/ewelink.md (3099b), skills/extension.md (2088b), skills/midea.md (2999b), skills/tuya.md (3014b), skills/xiaomi.md (4105b), _meta.json (127b)\n\nFile v1.0.9:SKILL.md\n\n---\nname: feyagate\ndescription: MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol.\nversion: 1.2.31\nemoji: \"🏠\"\nhomepage: https://www.feyagate.com\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n      config:\n        - ~/.feyagate/config/config.yaml\n    envVars:\n      - name: FEyagate_INSTALL_DIR\n        required: false\n        description: Override installation directory (default ~/.feyagate)\n      - name: FEyagate_PORT\n        required: false\n        description: HTTP port for the MCP proxy server (default 38080)\nsub_skills:\n  - name: feyagate-xiaomi\n    file: skills/xiaomi.md\n    trigger: Xiaomi, Mi Home, MIOT, 小米, camera, P2P, XiaoAI, 小爱, TTS, speaker, 摄像头\n  - name: feyagate-tuya\n    file: skills/tuya.md\n    trigger: Tuya, Smart Life, 涂鸦, DP code, QR auth\n  - name: feyagate-midea\n    file: skills/midea.md\n    trigger: Midea, 美居, 美的, AC, air conditioner, 空调\n  - name: feyagate-ewelink\n    file: skills/ewelink.md\n    trigger: eWeLink, Sonoff, iTEAD, switch, relay\n  - name: feyagate-automation\n    file: skills/automation.md\n    trigger: schedule, timer, trigger, automation, room, memory, note, 定时, 自动化, 房间, 记忆\n  - name: feyagate-extension\n    file: skills/extension.md\n    trigger: serial, RS485, UART, GPIO, Xiaozhi, 小智, license, config, stats, 统计\n---\n\n# FeyaGate Skill — MCP Smart Home Gateway\n\nControl smart home devices (lights, cameras, AC, speakers) from any AI agent via MCP protocol. Supports **Xiaomi · Tuya · Midea · eWeLink · Serial · GPIO**.\n\n## Prerequisites\n\n- Python 3.9+\n- macOS / Linux / Windows\n- `curl` (for installation)\n\n## Before Using Any Tool\n\nRun this check **before** calling any FeyaGate MCP tool:\n\n```bash\nfeyagate status\n```\n\n- **RUNNING** → proceed with tool calls\n- **STOPPED** or command not found → run `feyagate start` first\n- Not installed → `pip install feyagate-skill && feyagate setup && feyagate start`\n\n## Quick Start\n\n```bash\npip install feyagate-skill       # Install Python package\nfeyagate setup                   # Download MCP server binary (~30MB)\nfeyagate start                   # Start service on localhost:38080\nfeyagate install-claude          # Register with your AI agent\nfeyagate auth                    # Authorize smart home platform\n```\n\nOther agents: `install-cursor`, `install-openclaw`, `install-hermes`, `install-codex`, `install-windsurf`, `install-copilot`\n\nFull guide: [QUICKSTART.md](QUICKSTART.md)\n\n## Server Lifecycle\n\n| Action | Command |\n|--------|---------|\n| Install binary | `feyagate setup [--dir PATH]` |\n| Start | `feyagate start [--port PORT]` |\n| Stop | `feyagate stop` |\n| Restart | `feyagate restart [--port PORT]` |\n| Status | `feyagate status` |\n| Logs | `feyagate log [-n 50]` |\n| Update | `feyagate update` |\n| Auth | `feyagate auth [--status] [--code CODE]` |\n\n## Cross-Platform Tools\n\nThese tools work across all platforms (system auto-detects device platform):\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `device/list` | `filter` (string[]), `platform` (opt) | Devices with `platform` field |\n| `device/specs` | `deviceId` (string) | Platform-specific spec: properties, actions |\n| `platform/status` | — | All platform connection/auth/sync status |\n| `gateway/info` | — | Version, device count, ports |\n| `scene/list` | `platform` (string) | Scene list |\n| `scene/trigger` | `platform`, `sceneId` | Trigger result |\n\n> **Parameter convention:** `device/specs` uses `deviceId` (camelCase); platform-specific tools (`xiaomi/*`, `tuya/*`) use `device_id` (snake_case).\n\n## Sub-Skill Loading Strategy\n\nThe main skill provides cross-platform tools. Load sub-skills on demand based on the user's platform:\n\n| Sub-Skill | File | When to Load |\n|-----------|------|-------------|\n| **feyagate-xiaomi** | [skills/xiaomi.md](skills/xiaomi.md) | Xiaomi/Mi Home devices, cameras, XiaoAI speakers |\n| **feyagate-tuya** | [skills/tuya.md](skills/tuya.md) | Tuya/Smart Life devices |\n| **feyagate-midea** | [skills/midea.md](skills/midea.md) | Midea/美的 appliances |\n| **feyagate-ewelink** | [skills/ewelink.md](skills/ewelink.md) | eWeLink/Sonoff devices |\n| **feyagate-automation** | [skills/automation.md](skills/automation.md) | Schedule, triggers, rooms, memory |\n| **feyagate-extension** | [skills/extension.md](skills/extension.md) | Serial, GPIO, Xiaozhi AI, license |\n\n**Workflow:** `device/list` → `device/specs` → identify platform → load corresponding sub-skill\n\n## License\n\n- **Free**: Xiaomi platform (device control, cameras, XiaoAI, MCP proxy)\n- **Licensed**: All platforms (Xiaomi + Tuya + Midea + eWeLink)\n  - `tuya/set_property`, `midea/set_property`, `ewelink/set_property` return `license_required` on free edition\n  - `get_properties` and read tools work without license\n\n## Configuration\n\n`~/.feyagate/config/config.yaml`:\n\n```yaml\nserver:\n  http_port: 38080\n  ws_port: 8765\n  bind_address: \"0.0.0.0\"\nauth:\n  cloud_server: \"cn\"      # cn / de / sg / us / ru / i2\ncamera:\n  frame_interval: 500\n  jpeg_quality: 90\nxiaozhi:\n  endpoint: \"\"            # ws:// or wss:// (empty = disabled)\n```\n\n## Troubleshooting\n\n| Symptom | Fix |\n|---------|-----|\n| `command not found: feyagate` | `pip install feyagate-skill` |\n| `FeyaGate not installed` | `feyagate setup` |\n| `connection refused` | `feyagate start` |\n| `authorized: false` | `feyagate auth` or platform auth tool |\n| `Tool not found` | Check `tools/list` output |\n| `license_required` | Set license via `license/set` tool |\n\nFull API docs: [FeyaGate_MCP_API.md](FeyaGate_MCP_API.md), [FeyaGate_HTTP_API.md](FeyaGate_HTTP_API.md)\n\nFile v1.0.9:_meta.json\n\n{\n  \"ownerId\": \"kn70xdk1j9emqkf281q83fvzb1858rny\",\n  \"slug\": \"feyagate\",\n  \"version\": \"1.0.9\",\n  \"publishedAt\": 1780703113858\n}\n\nFile v1.0.9:FeyaGate_HTTP_API.md\n\n# FeyaGate HTTP API 文档\n\n> **适用产品**: miloco-mcp-server (桌面版虚拟网关 / ESP32 物理网关)\n> **基础 URL**: `http://<网关IP>:<port>` (桌面版默认 `38080`)\n> **协议**: HTTP REST + MCP JSON-RPC 2.0\n> **CORS**: 全局开放 `Access-Control-Allow-Origin: *`\n\n---\n\n## 目录\n\n- [1. 概述](#1-概述)\n- [2. HTTP REST 接口](#2-http-rest-接口)\n  - [2.1 健康检查](#21-健康检查)\n  - [2.2 OAuth 授权回调](#22-oauth-授权回调)\n  - [2.3 网关信息](#23-网关信息)\n  - [2.4 授权管理](#24-授权管理)\n- [3. MCP JSON-RPC 接口](#3-mcp-json-rpc-接口)\n  - [3.1 协议说明](#31-协议说明)\n  - [3.2 协议方法](#32-协议方法)\n- [4. 米家平台](#4-米家平台)\n- [5. 小爱音箱](#5-小爱音箱)\n- [6. 小智平台](#6-小智平台)\n- [7. 授权与网关](#7-授权与网关)\n- [8. Vision AI](#8-vision-ai)\n- [9. 触发规则](#9-触发规则)\n- [10. 配置管理](#10-配置管理)\n- [11. 统计数据](#11-统计数据)\n- [12. 多平台设备](#12-多平台设备)\n- [13. 定时任务](#13-定时任务)\n- [14. 技能管理](#14-技能管理)\n\n---\n\n## 1. 概述\n\nFeyaGate 网关提供两类 HTTP 接口：\n\n1. **HTTP REST 接口** — 标准 GET/POST/DELETE 端点，主要用于健康检查、OAuth 授权回调、网关信息和授权管理。\n2. **MCP JSON-RPC 接口** — 所有智能家居控制、设备管理等核心功能通过 `POST /mcp/http` 以 JSON-RPC 2.0 协议调用。\n\n---\n\n## 2. HTTP REST 接口\n\n### 2.1 健康检查\n\n```\nGET /health\n```\n\n**响应示例**:\n```json\n{\"status\": \"ok\"}\n```\n\n### 2.2 OAuth 授权回调\n\n#### 2.2.1 OAuth 回调\n\n```\nGET /auth/callback?code=xxx&source=browser\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | string | 是 | OAuth 授权码 |\n| `source` | string | 否 | 来源标识，`browser` 时触发页面重定向 |\n\n**响应**: 成功时返回 HTML 页面显示授权结果；失败时返回错误提示。\n\n#### 2.2.2 浏览器 OAuth 回调\n\n```\nGET /auth/browser-callback?code=xxx\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | string | 是 | OAuth 授权码 |\n\n**响应**: 重定向到 `/#/?auth=success` 或 `/#/?auth=failed`。\n\n#### 2.2.3 浏览器 OAuth 启动页\n\n```\nGET /auth/browser-start?oauth_url=xxx&callback=xxx\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `oauth_url` | string | 是 | OAuth 授权 URL |\n| `callback` | string | 是 | 回调地址 |\n\n**响应**: 返回 HTML 页面，含小米登录按钮，500ms 后自动跳转授权。\n\n### 2.3 网关信息\n\n```\nGET /api/v1/gateway/info\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"version\": \"v1.2.14\",\n    \"platform\": \"linux\",\n    \"device_id\": \"xxx\",\n    \"edition\": \"pro\",\n    \"licensed\": true\n  }\n}\n```\n\n### 2.4 授权管理\n\n#### 获取授权状态\n\n```\nGET /api/v1/gateway/license\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"edition\": \"pro\",\n    \"status\": \"active\",\n    \"product\": \"feyagate-linux\",\n    \"license_key\": \"FG-xxxx-****-xxxx\"\n  }\n}\n```\n\n#### 写入授权码\n\n```\nPOST /api/v1/gateway/license\nContent-Type: application/json\n```\n\n**请求体**:\n```json\n{\n  \"license_key\": \"FG-XXXX-XXXX-XXXX\",\n  \"product\": \"feyagate-linux\"\n}\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `license_key` | string | 是 | 授权码，格式 `FG-XXXX-XXXX-XXXX` |\n| `product` | string | 否 | 产品标识，默认使用配置文件中的值 |\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"edition\": \"pro\",\n    \"status\": \"active\",\n    \"activated\": true\n  }\n}\n```\n\n#### 清除授权\n\n```\nDELETE /api/v1/gateway/license\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": { \"edition\": \"free\", \"status\": \"inactive\" },\n  \"message\": \"授权已清除, 恢复免费版\"\n}\n```\n\n---\n\n## 3. MCP JSON-RPC 接口\n\n### 3.1 协议说明\n\n所有 MCP 工具通过单一端点调用：\n\n```\nPOST /mcp/http\nContent-Type: application/json\n```\n\n**请求格式** (JSON-RPC 2.0):\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"<工具名>\",\n    \"arguments\": { ... }\n  }\n}\n```\n\n**响应格式**:\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"result\": { ... }\n}\n```\n\n> **注意**: `GET /mcp/http` 返回 `{\"error\": \"SSE stream not supported yet. Use POST for JSON-RPC.\"}`，暂不支持 SSE。\n\n### 3.2 协议方法\n\n| 方法 | 说明 |\n|------|------|\n| `initialize` | MCP 协议握手 |\n| `ping` | 保活心跳 |\n| `tools/list` | 列出所有已注册工具 |\n| `tools/call` | 调用指定工具 |\n| `notifications/initialized` | 初始化完成通知（无响应） |\n\n---\n\n## 4. 米家平台\n\n### 4.1 xiaomi/auth_status\n\n检查米家 OAuth 授权状态。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"authorized\": true,\n  \"remaining_seconds\": 86400,\n  \"cloud_server\": \"cn\"\n}\n```\n\n### 4.2 xiaomi/auth_url\n\n获取米家 OAuth 授权 URL。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"url\": \"https://account.xiaomi.com/oauth2/authorize?...\",\n  \"message\": \"请在浏览器中打开此 URL 完成米家账号授权。\"\n}\n```\n\n### 4.3 xiaomi/auth_callback\n\n处理 OAuth 授权回调 code。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | string | 是 | OAuth 授权码 |\n\n### 4.4 xiaomi/refresh\n\n刷新米家 Token。\n\n**参数**: 无\n\n### 4.5 xiaomi/camera_list\n\n获取米家摄像头列表。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `filter` | string[] | 否 | 关键词过滤数组 |\n\n**响应示例**:\n```json\n[\n  {\n    \"did\": \"102838844\",\n    \"name\": \"客厅摄像头\",\n    \"model\": \"chuangmi.camera.ipc019\",\n    \"home\": \"我的家\",\n    \"room\": \"客厅\",\n    \"online\": true,\n    \"channel_count\": 1,\n    \"camera_status\": \"connected\"\n  }\n]\n```\n\n### 4.6 xiaomi/camera_status\n\n查询摄像头连接状态。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | string | 否 | 摄像头 DID，留空返回所有 |\n\n### 4.7 xiaomi/camera_connect\n\n连接摄像头。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | string | 是 | 摄像头 DID |\n\n### 4.8 xiaomi/camera_disconnect\n\n断开摄像头连接。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | string | 是 | 摄像头 DID |\n\n### 4.9 xiaomi/camera_snapshot\n\n抓拍摄像头画面。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | string | 是 | 摄像头 DID |\n| `channel` | integer | 否 | 通道号，默认 `0` |\n| `count` | integer | 否 | 抓拍帧数，默认 `1`，最大 `10` |\n| `use_subprocess` | boolean | 否 | 是否使用子进程抓拍 |\n\n### 4.10 xiaomi/get_area_info\n\n获取米家家庭/房间信息。\n\n**参数**: 无\n\n### 4.11 xiaomi/get_device_classes\n\n获取米家设备分类列表。\n\n**参数**: 无\n\n### 4.12 xiaomi/get_devices\n\n获取米家设备列表。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `area_id` | string | 否 | 按房间 ID 过滤 |\n| `device_class` | string | 否 | 按设备分类过滤 |\n\n### 4.13 get_xiaomi_device_properties\n\n获取米家设备属性值。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | string | 是 | 设备 DID |\n| `siid` | integer | 是 | 服务 ID |\n| `piids` | integer[] | 是 | 属性 ID 数组 |\n\n### 4.14 set_xiaomi_device_property\n\n设置米家设备属性。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | string | 是 | 设备 DID |\n| `siid` | integer | 是 | 服务 ID |\n| `piid` | integer | 是 | 属性 ID |\n| `value` | any | 是 | 属性值 |\n\n### 4.15 execute_xiaomi_device_action\n\n执行米家设备动作。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | string | 是 | 设备 DID |\n| `siid` | integer | 是 | 服务 ID |\n| `aiid` | integer | 是 | 动作 ID |\n| `params` | array | 否 | 动作参数 |\n\n### 4.16 xiaomi/scene_list\n\n获取米家场景列表。\n\n**参数**: 无\n\n### 4.17 xiaomi/scene_trigger\n\n触发米家场景。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `sceneId` | string | 是 | 场景 ID |\n\n---\n\n## 5. 小爱音箱\n\n### 5.1 xiaoai/play_music\n\n控制小爱音箱播放音乐/语音。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | string | 是 | 小爱音箱设备 ID |\n| `text` | string | 是 | 播放内容 |\n| `command` | string | 否 | 播放命令（`text` 的别名） |\n\n### 5.2 xiaoai/tts\n\n小爱音箱 TTS 语音播报。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | string | 是 | 小爱音箱设备 ID |\n| `text` | string | 是 | 播报文本 |\n\n### 5.3 xiaoai/control\n\n发送小爱音箱控制命令。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | string | 是 | 小爱音箱设备 ID |\n| `command` | string | 是 | 控制命令 |\n| `silence` | boolean | 否 | 是否静音执行，默认 `true` |\n\n---\n\n## 6. 小智平台\n\n> 小智平台支持多连接（最多由 `XIAOZHI_MAX_CONNECTIONS` 常量定义）。\n\n### 6.1 xiaozhi/status\n\n获取所有小智平台连接状态。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"state\": \"connected\",\n  \"endpoint\": \"wss://xxx\",\n  \"connected\": true,\n  \"initialized\": true,\n  \"bridged_tools\": 42,\n  \"enabled\": true,\n  \"clients\": [\n    {\n      \"index\": 0,\n      \"endpoint\": \"wss://xxx\",\n      \"state\": \"connected\",\n      \"connected\": true,\n      \"initialized\": true,\n      \"bridged_tools\": 42\n    }\n  ],\n  \"count\": 1,\n  \"max_count\": 3\n}\n```\n\n### 6.2 xiaozhi/list\n\n列出所有已配置的小智连接端点。\n\n**参数**: 无\n\n### 6.3 xiaozhi/add\n\n添加新的小智平台 WebSocket 连接。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `endpoint` | string | 是 | WebSocket URL (`ws://` 或 `wss://`) |\n\n### 6.4 xiaozhi/remove\n\n删除指定索引的小智连接。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `index` | integer | 是 | 连接索引（0-based） |\n\n### 6.5 xiaozhi/set_endpoint\n\n设置第一个小智平台端点（向后兼容接口）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `endpoint` | string | 否 | WebSocket URL，留空禁用 |\n\n---\n\n## 7. 授权与网关\n\n### 7.1 license/status\n\n获取设备授权状态。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"edition\": \"pro\",\n  \"status\": \"active\",\n  \"product\": \"feyagate-linux\",\n  \"device_id\": \"xxx\",\n  \"key_masked\": \"FG-xxxx-****-xxxx\"\n}\n```\n\n> 免费版时额外返回 `guidance` 字段，包含授权指引信息。\n\n### 7.2 license/set\n\n写入授权码并激活。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `license_key` | string | 是 | 授权码，格式 `FG-XXXX-XXXX-XXXX` |\n| `product` | string | 否 | 产品标识，默认使用配置文件中的值 |\n\n**响应示例**:\n```json\n{\n  \"edition\": \"pro\",\n  \"status\": \"active\",\n  \"activated\": true,\n  \"message\": \"授权成功! 全平台功能已解锁。\"\n}\n```\n\n### 7.3 license/clear\n\n清除授权码，恢复免费版。\n\n**参数**: 无\n\n### 7.4 gateway/info\n\n获取网关信息（MCP 版本，对应 REST 的 `GET /api/v1/gateway/info`）。\n\n**参数**: 无\n\n---\n\n## 8. Vision AI\n\n### 8.1 xiaomi/camera_vision_chat\n\n向 Vision AI 提问摄像头画面内容。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | string | 是 | 摄像头设备 DID |\n| `query` | string | 是 | 向 AI 提出的问题 |\n| `channel` | integer | 否 | 摄像头通道，默认 `0` |\n| `count` | integer | 否 | 发送最近几帧，默认 `3`，最大 `10` |\n\n**响应示例**:\n```json\n{\n  \"camera_id\": \"102838844\",\n  \"camera_name\": \"客厅摄像头\",\n  \"channel\": 0,\n  \"images_used\": 3,\n  \"model\": \"configured\",\n  \"content\": \"画面中有2个人，正在客厅看电视...\",\n  \"tokens\": {\n    \"prompt\": 1500,\n    \"completion\": 200\n  }\n}\n```\n\n> 需先在 `config.yaml` 中配置 `vision.enabled=true` 和 `api_key`。\n\n---\n\n## 9. 触发规则\n\n### 9.1 trigger/create\n\n创建摄像头触发规则。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | string | 是 | 规则名称 |\n| `cameras` | string[] | 是 | 关联摄像头 DID 列表 |\n| `condition` | string | 是 | 自然语言触发条件 |\n| `actions` | array | 否 | 触发时执行的动作列表 |\n| `notify` | object | 否 | 通知配置 `{title, body}` |\n| `filter` | object | 否 | 过滤器 `{interval, period}` |\n\n**响应示例**:\n```json\n{\n  \"id\": \"rule_001\",\n  \"message\": \"触发规则已创建\",\n  \"rule\": { ... }\n}\n```\n\n### 9.2 trigger/list\n\n列出所有触发规则。\n\n**参数**: 无\n\n### 9.3 trigger/update\n\n更新触发规则。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | string | 是 | 规则 ID |\n| `name` | string | 否 | 新名称 |\n| `cameras` | string[] | 否 | 新摄像头列表 |\n| `condition` | string | 否 | 新触发条件 |\n| `actions` | array | 否 | 新动作列表 |\n| `notify` | object | 否 | 新通知配置 |\n| `filter` | object | 否 | 新过滤器 |\n| `enabled` | boolean | 否 | 启用/禁用 |\n\n### 9.4 trigger/delete\n\n删除触发规则。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | string | 是 | 规则 ID |\n\n### 9.5 trigger/toggle\n\n启用或禁用触发规则。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | string | 是 | 规则 ID |\n| `enabled` | boolean | 是 | `true` 启用，`false` 禁用 |\n\n### 9.6 trigger/logs\n\n查看触发规则执行日志。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `limit` | integer | 否 | 返回数量限制，默认 `50` |\n| `rule_id` | string | 否 | 按规则 ID 过滤 |\n\n---\n\n## 10. 配置管理\n\n### 10.1 config/get_vision\n\n获取 Vision AI 当前配置。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"enabled\": true,\n  \"api_key_masked\": \"sk-x****1234\",\n  \"has_api_key\": true,\n  \"base_url\": \"https://api.openai.com/v1\",\n  \"model\": \"gpt-4o\",\n  \"temperature\": 0.7,\n  \"max_tokens\": 4096,\n  \"timeout_seconds\": 30\n}\n```\n\n### 10.2 config/set_vision\n\n更新 Vision AI 配置并保存到 `config.yaml`，修改后立即生效。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `enabled` | boolean | 否 | 是否启用 Vision AI |\n| `api_key` | string | 否 | LLM API Key |\n| `base_url` | string | 否 | OpenAI 兼容 API 端点 |\n| `model` | string | 否 | 模型名称 |\n| `temperature` | number | 否 | 温度参数 (0-2) |\n| `max_tokens` | integer | 否 | 最大响应 Token 数 |\n| `timeout_seconds` | integer | 否 | HTTP 超时秒数 |\n\n### 10.3 config/get_trigger\n\n获取触发引擎当前配置。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"enabled\": true,\n  \"interval_seconds\": 30,\n  \"vision_img_count\": 3,\n  \"motion_threshold\": 10,\n  \"log_ttl_days\": 30,\n  \"min_trigger_interval\": 300\n}\n```\n\n### 10.4 config/set_trigger\n\n更新触发引擎配置并保存到 `config.yaml`，修改后立即生效。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `enabled` | boolean | 否 | 是否启用触发引擎 |\n| `interval_seconds` | integer | 否 | 规则检查间隔（秒） |\n| `vision_img_count` | integer | 否 | 每次 LLM 调用使用的帧数 |\n| `motion_threshold` | integer | 否 | dHash 运动检测阈值 |\n| `log_ttl_days` | integer | 否 | 日志保留天数 |\n| `min_trigger_interval` | integer | 否 | 单规则最小触发间隔（秒） |\n\n---\n\n## 11. 统计数据\n\n### 11.1 stats/token_usage\n\n获取 Token 消耗统计。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `days` | integer | 否 | 统计最近多少天，默认 `30` |\n\n**响应示例**:\n```json\n{\n  \"summary\": { \"total_tokens\": 150000, \"total_calls\": 300 },\n  \"daily\": [ {\"date\": \"2026-05-20\", \"tokens\": 5000, \"calls\": 10} ],\n  \"by_model\": [ {\"model\": \"gpt-4o\", \"tokens\": 100000} ],\n  \"by_source\": [ {\"source\": \"vision\", \"tokens\": 80000} ]\n}\n```\n\n### 11.2 stats/token_records\n\n获取最近 LLM API 调用记录。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `limit` | integer | 否 | 返回记录数，默认 `50` |\n\n### 11.3 stats/trigger_summary\n\n获取触发事件聚合统计（每日趋势、规则排名、摄像头分布、时间热力图）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `days` | integer | 否 | 统计最近多少天，默认 `30` |\n\n**响应示例**:\n```json\n{\n  \"overview\": {\n    \"today\": 5, \"this_week\": 32, \"total\": 150,\n    \"enabled_rules\": 3, \"total_rules\": 5\n  },\n  \"daily\": [ {\"date\": \"2026-05-20\", \"count\": 8} ],\n  \"by_rule\": [ {\"rule_id\": \"rule_001\", \"rule_name\": \"有人进入\", \"count\": 20} ],\n  \"by_camera\": [ {\"camera_id\": \"102838844\", \"count\": 45} ],\n  \"heatmap\": [ {\"weekday\": \"Mon\", \"weekday_idx\": 0, \"hour\": 9, \"count\": 3} ]\n}\n```\n\n### 11.4 stats/dashboard\n\n获取综合看板摘要数据。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"trigger_engine\": {\n    \"enabled\": true,\n    \"enabled_rules\": 3,\n    \"total_rules\": 5\n  },\n  \"today\": {\n    \"ai_calls\": 42,\n    \"triggers\": 5,\n    \"actions_executed\": 8,\n    \"tokens_used\": 12000\n  },\n  \"token_summary\": { ... },\n  \"action_ranking\": [ {\"action\": \"turn_off_light\", \"count\": 3} ],\n  \"recent_events\": [\n    {\"time\": \"2026-05-24T10:30:00\", \"rule_name\": \"有人进入\", \"camera_id\": \"xxx\"}\n  ]\n}\n```\n\n---\n\n## 12. 多平台设备\n\n### 12.1 auth/platforms\n\n列出所有已注册的智能家居平台及认证状态。\n\n**参数**: 无\n\n### 12.2 device/list\n\n获取所有已认证平台的设备列表（跨平台统一）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `platform` | string | 否 | 按平台过滤: `xiaomi` / `tuya` / `midea` / `ewelink` |\n| `filter` | string[] | 否 | 关键词过滤数组，匹配设备名称、型号、房间名 |\n\n**响应示例**:\n```json\n{\n  \"total\": 24,\n  \"devices\": [\n    {\n      \"id\": \"102838844\",\n      \"name\": \"客厅灯\",\n      \"model\": \"yeelink.light.lamp22\",\n      \"platform\": \"xiaomi\",\n      \"online\": true,\n      \"category\": \"light\",\n      \"home_name\": \"我的家\",\n      \"room_name\": \"客厅\"\n    }\n  ]\n}\n```\n\n### 12.3 device/specs\n\n获取设备功能规格定义（跨平台统一）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | string | 是 | 设备 ID |\n\n### 12.4 涂鸦平台\n\n| 工具名 | 必填参数 | 说明 |\n|--------|----------|------|\n| `auth/tuya_qr` | `user_code` | 获取涂鸦 QR 码授权 |\n| `auth/tuya_qr_status` | `token`, `user_code` | 查询扫码状态 |\n| `auth/tuya_logout` | 无 | 退出涂鸦授权 |\n| `tuya/refresh` | 无 | 刷新涂鸦设备列表 |\n| `get_tuya_device_properties` | `deviceId` | 获取设备 DP 属性 |\n| `set_tuya_device_property` | `deviceId`, `code`, `value` | 设置设备 DP 属性（需授权） |\n\n**set_tuya_device_property 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | string | 是 | 设备 ID |\n| `code` | string | 是 | DP Code（如 `switch_1`, `bright_value`） |\n| `value` | any | 是 | DP 值（boolean/number/string） |\n\n### 12.5 美的平台\n\n| 工具名 | 必填参数 | 说明 |\n|--------|----------|------|\n| `auth/midea_login` | `account`, `password` | 美的平台登录 |\n| `auth/midea_logout` | 无 | 退出美的授权 |\n| `midea/refresh` | 无 | 刷新美的设备列表 |\n| `get_midea_device_properties` | `deviceId` | 获取设备属性 |\n| `set_midea_device_property` | `deviceId`, `property`, `value` | 设置设备属性（需授权） |\n\n**auth/midea_login 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `account` | string | 是 | 手机号或邮箱 |\n| `password` | string | 是 | 密码 |\n| `cloud` | string | 否 | 云端类型: `meiju`(默认) 或 `msmart` |\n\n**set_midea_device_property 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | string | 是 | 设备 ID (applianceCode) |\n| `property` | string | 是 | 属性名（如 `power`, `temperature`, `mode`） |\n| `value` | any | 是 | 属性值 |\n\n### 12.6 易微联 (eWeLink)\n\n| 工具名 | 必填参数 | 说明 |\n|--------|----------|------|\n| `auth/ewelink_login` | `email`, `password` | 易微联平台登录 |\n| `auth/ewelink_logout` | 无 | 退出易微联授权 |\n| `ewelink/refresh` | 无 | 刷新易微联设备列表 |\n| `get_ewelink_device_properties` | `deviceId` | 获取设备属性 |\n| `set_ewelink_device_property` | `deviceId`, `property`, `value` | 设置设备属性（需授权） |\n\n**auth/ewelink_login 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `email` | string | 是 | 邮箱或手机号 |\n| `password` | string | 是 | 密码 |\n| `country_code` | string | 否 | 国家代码，默认 `+86` |\n\n**set_ewelink_device_property 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | string | 是 | 设备 ID |\n| `property` | string | 是 | 属性名（如 `switch`, `switches`） |\n| `value` | any | 是 | 属性值（boolean/string/array） |\n\n---\n\n## 13. 定时任务\n\n### 13.1 schedule/add\n\n创建定时任务。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | string | 是 | 任务名称 |\n| `scheduled_time` | string | 是 | 执行时间 ISO 8601，如 `2026-05-24T08:00:00+08:00` |\n| `tool_name` | string | 是 | 要执行的 MCP 工具名 |\n| `tool_args` | string | 是 | 工具参数 JSON 字符串 |\n| `repeat` | string | 否 | 重复类型: `none`/`daily`/`weekdays`/`weekends`/`weekly`/`custom` |\n| `repeat_days` | string | 否 | 自定义重复天 JSON 数组，如 `[1,2,3,4,5]` (周一到周五) |\n\n### 13.2 schedule/list\n\n列出定时任务。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `status` | string | 否 | 筛选状态: `pending`/`completed`/`cancelled`，留空返回全部 |\n\n### 13.3 schedule/get\n\n获取定时任务详情。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | integer | 是 | 任务 ID |\n\n### 13.4 schedule/update\n\n更新定时任务（仅 pending 状态可修改）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | integer | 是 | 任务 ID |\n| `scheduled_time` | string | 否 | 新执行时间 ISO 8601 |\n| `repeat` | string | 否 | 新重复类型 |\n| `repeat_days` | string | 否 | 新自定义重复天 |\n\n### 13.5 schedule/delete\n\n删除定时任务。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | integer | 是 | 任务 ID |\n\n### 13.6 schedule/cancel\n\n取消定时任务（保留记录，状态变为 `cancelled`）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | integer | 是 | 任务 ID |\n\n---\n\n## 14. 技能管理\n\n### 14.1 skill/list\n\n列出所有技能。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `source` | string | 否 | 来源过滤: `all`(默认) / `builtin` / `user` |\n\n**响应示例**:\n```json\n{\n  \"skills\": [\n    {\n      \"name\": \"smart_light\",\n      \"description\": \"智能灯光控制技能\",\n      \"source\": \"builtin\",\n      \"always\": false,\n      \"tags\": [\"light\", \"control\"],\n      \"path\": \"/path/to/skill.md\"\n    }\n  ],\n  \"count\": 1\n}\n```\n\n### 14.2 skill/read\n\n读取指定技能的完整内容。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | string | 是 | 技能名称 |\n\n**响应示例**:\n```json\n{\n  \"name\": \"smart_light\",\n  \"description\": \"智能灯光控制技能\",\n  \"source\": \"builtin\",\n  \"always\": false,\n  \"tags\": [\"light\"],\n  \"path\": \"/path/to/skill.md\",\n  \"content\": \"---\\nname: smart_light\\n---\\n# 技能正文\",\n  \"body\": \"# 技能正文\"\n}\n```\n\n### 14.3 skill/create\n\n创建新的自定义技能。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | string | 是 | 技能名称（字母数字和连字符） |\n| `content` | string | 是 | 技能内容（Markdown + YAML frontmatter） |\n\n### 14.4 skill/update\n\n更新已有自定义技能内容。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | string | 是 | 技能名称 |\n| `content` | string | 是 | 新的技能内容 |\n\n### 14.5 skill/delete\n\n删除指定自定义技能（内置技能不可删除）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | string | 是 | 技能名称 |\n\n### 14.6 skill/context\n\n获取所有常驻技能的上下文内容。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"context\": \"...\",\n  \"skill_count\": 5\n}\n```\n\n### 14.7 skill/reload\n\n重新扫描技能目录并刷新缓存。\n\n**参数**: 无\n\nFile v1.0.9:FeyaGate_MCP_API.md\n\n# FeyaGate MCP API 文档\n\n> **适用产品**: miloco-mcp-server (桌面版虚拟网关)\n> **协议**: MCP (Model Context Protocol) JSON-RPC 2.0\n> **MCP 端点**: `POST http://<网关IP>:38080/mcp/http`\n> **协议版本**: `2025-03-26`\n\n---\n\n## 目录\n\n- [1. 连接指南](#1-连接指南)\n- [2. JSON-RPC 2.0 规范](#2-json-rpc-20-规范)\n- [3. 协议方法](#3-协议方法)\n- [4. MCP Tools 总览 (76 个)](#4-mcp-tools-总览-76-个)\n- [5. 通用设备工具](#5-通用设备工具)\n- [6. 小米 (Xiaomi) 平台](#6-小米-xiaomi-平台)\n- [7. 涂鸦 (Tuya) 平台](#7-涂鸦-tuya-平台)\n- [8. 美的 (Midea) 平台](#8-美的-midea-平台)\n- [9. 易微联 (eWeLink) 平台](#9-易微联-ewelink-平台)\n- [10. 小爱音箱控制](#10-小爱音箱控制)\n- [11. 小智平台](#11-小智平台)\n- [12. 认证与平台管理](#12-认证与平台管理)\n- [13. Vision AI](#13-vision-ai)\n- [14. 触发规则](#14-触发规则)\n- [15. 定时任务](#15-定时任务)\n- [16. 技能系统](#16-技能系统)\n- [17. 配置管理](#17-配置管理)\n- [18. 统计数据](#18-统计数据)\n- [19. 授权码管理](#19-授权码管理)\n- [20. 网关信息](#20-网关信息)\n- [21. 错误码](#21-错误码)\n- [附录: 快速示例](#附录-快速示例)\n\n---\n\n## 1. 连接指南\n\n所有 MCP 调用均通过 `POST /mcp/http` 以 JSON-RPC 2.0 格式发送，无需事先握手。\n\n```bash\n# 初始化\ncurl -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{},\"clientInfo\":{\"name\":\"MyClient\",\"version\":\"1.0.0\"}}}'\n\n# 列出所有工具\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/list\",\"params\":{}}'\n```\n\n> **无状态**: 服务器不维持 HTTP 会话状态，不返回 `Mcp-Session-Id` header，每次请求均为无状态调用。\n>\n> **无 WebSocket**: 服务器不提供 inbound WebSocket 端点。`/mcp` WebSocket 路径不存在。服务器作为 WebSocket **客户端**主动连接小智平台，由 `xiaozhi/*` 工具管理。\n\n---\n\n## 2. JSON-RPC 2.0 规范\n\n### 请求结构\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"<工具名>\",\n    \"arguments\": { ... }\n  }\n}\n```\n\n### 成功响应\n\n工具返回值被包装为 MCP content 格式：\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"result\": {\n    \"content\": [\n      { \"type\": \"text\", \"text\": \"{\\\"success\\\":true,...}\" }\n    ]\n  }\n}\n```\n\n> 工具返回的 JSON 对象会被序列化为字符串放在 `content[0].text` 中。\n\n### 图片响应\n\n当工具返回含 `images` 数组（含 `data_url` 字段）的结果时，服务器会自动提取图片为独立的 MCP image content：\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"result\": {\n    \"content\": [\n      { \"type\": \"text\", \"text\": \"{\\\"camera_id\\\":\\\"xxx\\\",\\\"images\\\":[...]}\" },\n      { \"type\": \"image\", \"data\": \"<base64>\", \"mimeType\": \"image/jpeg\" }\n    ]\n  }\n}\n```\n\n### 错误响应\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"error\": { \"code\": -32601, \"message\": \"Tool not found: unknown/tool\" }\n}\n```\n\n### 工具执行异常\n\n当工具 handler 抛出异常时，返回 `isError: true`：\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"result\": {\n    \"content\": [\n      { \"type\": \"text\", \"text\": \"{\\\"error\\\":\\\"exception message\\\"}\" }\n    ],\n    \"isError\": true\n  }\n}\n```\n\n---\n\n## 3. 协议方法\n\n| 方法 | 说明 |\n|------|------|\n| `initialize` | MCP 协议握手 |\n| `ping` | 保活心跳 |\n| `tools/list` | 列出所有已注册工具 |\n| `tools/call` | 调用指定工具 |\n| `notifications/initialized` | 初始化完成通知（无响应） |\n\n### initialize\n\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1,\n  \"method\": \"initialize\",\n  \"params\": {\n    \"protocolVersion\": \"2025-03-26\",\n    \"capabilities\": {},\n    \"clientInfo\": { \"name\": \"MyClient\", \"version\": \"1.0.0\" }\n  }\n}\n```\n\n**响应**:\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1,\n  \"result\": {\n    \"protocolVersion\": \"2025-03-26\",\n    \"capabilities\": { \"tools\": {}, \"resources\": {} },\n    \"serverInfo\": { \"name\": \"miloco-mcp-server\", \"version\": \"1.0.0\" }\n  }\n}\n```\n\n### ping\n\n```json\n{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"ping\", \"params\": {} }\n```\n\n**响应**:\n```json\n{ \"jsonrpc\": \"2.0\", \"id\": 1, \"result\": {} }\n```\n\n### tools/list\n\n```json\n{ \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools/list\", \"params\": {} }\n```\n\n**响应**:\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1,\n  \"result\": {\n    \"tools\": [\n      {\n        \"name\": \"device/list\",\n        \"description\": \"获取所有已认证平台的设备列表...\",\n        \"inputSchema\": { \"type\": \"object\", \"properties\": { ... } }\n      }\n    ]\n  }\n}\n```\n\n### tools/call\n\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"device/list\",\n    \"arguments\": { \"filter\": [\"客厅\", \"灯\"], \"platform\": \"xiaomi\" }\n  }\n}\n```\n\n---\n\n## 4. MCP Tools 总览 (76 个)\n\n> **参数命名规则**:\n> - 跨平台统一工具 (`device/list`, `device/specs`) 使用 `snake_case`（如 `device_id`）\n> - 平台专属工具使用 `camelCase`（如 `deviceId`, `siid`, `piids`）\n\n| # | 工具名 | 类别 | 必填参数 |\n|---|--------|------|----------|\n| 1 | `device/list` | 通用设备 | — |\n| 2 | `device/specs` | 通用设备 | `device_id` |\n| 3 | `xiaomi/auth_status` | 小米认证 | — |\n| 4 | `xiaomi/auth_url` | 小米认证 | — |\n| 5 | `xiaomi/auth_callback` | 小米认证 | `code` |\n| 6 | `xiaomi/refresh` | 小米设备 | — |\n| 7 | `xiaomi/get_devices` | 小米设备 | — |\n| 8 | `xiaomi/get_area_info` | 小米设备 | — |\n| 9 | `xiaomi/get_device_classes` | 小米设备 | — |\n| 10 | `get_xiaomi_device_properties` | 小米控制 | `deviceId`, `siid`, `piids` |\n| 11 | `set_xiaomi_device_property` | 小米控制 | `deviceId`, `siid`, `piid`, `value` |\n| 12 | `execute_xiaomi_device_action` | 小米控制 | `deviceId`, `siid`, `aiid` |\n| 13 | `xiaomi/scene_list` | 小米场景 | — |\n| 14 | `xiaomi/scene_trigger` | 小米场景 | `sceneId` |\n| 15 | `xiaomi/camera_list` | 摄像头 | — |\n| 16 | `xiaomi/camera_status` | 摄像头 | — |\n| 17 | `xiaomi/camera_connect` | 摄像头 | `camera_id` |\n| 18 | `xiaomi/camera_disconnect` | 摄像头 | `camera_id` |\n| 19 | `xiaomi/camera_snapshot` | 摄像头 | `camera_id` |\n| 20 | `xiaomi/camera_vision_chat` | Vision AI | `camera_id`, `query` |\n| 21 | `xiaoai/play_music` | 小爱音箱 | `device_id` |\n| 22 | `xiaoai/tts` | 小爱音箱 | `device_id`, `text` |\n| 23 | `xiaoai/control` | 小爱音箱 | `device_id`, `command` |\n| 24 | `xiaozhi/status` | 小智平台 | — |\n| 25 | `xiaozhi/list` | 小智平台 | — |\n| 26 | `xiaozhi/add` | 小智平台 | `endpoint` |\n| 27 | `xiaozhi/remove` | 小智平台 | `index` |\n| 28 | `xiaozhi/set_endpoint` | 小智平台 | — |\n| 29 | `auth/platforms` | 平台认证 | — |\n| 30 | `auth/tuya_qr` | 涂鸦认证 | `user_code` |\n| 31 | `auth/tuya_qr_status` | 涂鸦认证 | `token`, `user_code` |\n| 32 | `auth/tuya_logout` | 涂鸦认证 | — |\n| 33 | `tuya/refresh` | 涂鸦设备 | — |\n| 34 | `get_tuya_device_properties` | 涂鸦控制 | `deviceId` |\n| 35 | `set_tuya_device_property` | 涂鸦控制 | `deviceId`, `code`, `value` |\n| 36 | `auth/midea_login` | 美的认证 | `account`, `password` |\n| 37 | `auth/midea_logout` | 美的认证 | — |\n| 38 | `midea/refresh` | 美的设备 | — |\n| 39 | `get_midea_device_properties` | 美的控制 | `deviceId` |\n| 40 | `set_midea_device_property` | 美的控制 | `deviceId`, `property`, `value` |\n| 41 | `auth/ewelink_login` | 易微联认证 | `email`, `password` |\n| 42 | `auth/ewelink_logout` | 易微联认证 | — |\n| 43 | `ewelink/refresh` | 易微联设备 | — |\n| 44 | `get_ewelink_device_properties` | 易微联控制 | `deviceId` |\n| 45 | `set_ewelink_device_property` | 易微联控制 | `deviceId`, `property`, `value` |\n| 46 | `trigger/create` | 触发规则 | `name`, `cameras`, `condition` |\n| 47 | `trigger/list` | 触发规则 | — |\n| 48 | `trigger/update` | 触发规则 | `id` |\n| 49 | `trigger/delete` | 触发规则 | `id` |\n| 50 | `trigger/toggle` | 触发规则 | `id`, `enabled` |\n| 51 | `trigger/logs` | 触发规则 | — |\n| 52 | `schedule/add` | 定时任务 | `name`, `scheduled_time`, `tool_name`, `tool_args` |\n| 53 | `schedule/list` | 定时任务 | — |\n| 54 | `schedule/get` | 定时任务 | `id` |\n| 55 | `schedule/update` | 定时任务 | `id` |\n| 56 | `schedule/delete` | 定时任务 | `id` |\n| 57 | `schedule/cancel` | 定时任务 | `id` |\n| 58 | `skill/list` | 技能系统 | — |\n| 59 | `skill/read` | 技能系统 | `name` |\n| 60 | `skill/create` | 技能系统 | `name`, `content` |\n| 61 | `skill/update` | 技能系统 | `name`, `content` |\n| 62 | `skill/delete` | 技能系统 | `name` |\n| 63 | `skill/context` | 技能系统 | — |\n| 64 | `skill/reload` | 技能系统 | — |\n| 65 | `config/get_vision` | 配置管理 | — |\n| 66 | `config/set_vision` | 配置管理 | — |\n| 67 | `config/get_trigger` | 配置管理 | — |\n| 68 | `config/set_trigger` | 配置管理 | — |\n| 69 | `stats/token_usage` | 统计数据 | — |\n| 70 | `stats/token_records` | 统计数据 | — |\n| 71 | `stats/trigger_summary` | 统计数据 | — |\n| 72 | `stats/dashboard` | 统计数据 | — |\n| 73 | `license/status` | 授权管理 | — |\n| 74 | `license/set` | 授权管理 | `license_key` |\n| 75 | `license/clear` | 授权管理 | — |\n| 76 | `gateway/info` | 网关信息 | — |\n\n---\n\n## 5. 通用设备工具\n\n### `device/list`\n\n获取所有已认证平台的设备列表（米家/涂鸦/美的/易微联），支持关键词和平台过滤。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `platform` | `string` | ❌ | 平台过滤: `xiaomi` / `tuya` / `midea` / `ewelink` |\n| `filter` | `string[]` | ❌ | 关键词过滤数组，匹配设备名称、型号、房间名、家庭名 |\n\n**响应示例**:\n```json\n{\n  \"total\": 24,\n  \"devices\": [\n    {\n      \"id\": \"102838844\",\n      \"name\": \"客厅灯\",\n      \"model\": \"yeelink.light.lamp22\",\n      \"platform\": \"xiaomi\",\n      \"online\": true,\n      \"category\": \"light\",\n      \"home_name\": \"我的家\",\n      \"room_name\": \"客厅\"\n    }\n  ]\n}\n```\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"device/list\",\"arguments\":{\"filter\":[\"客厅\",\"灯\"],\"platform\":\"xiaomi\"}}}'\n```\n\n### `device/specs`\n\n获取设备的功能规格定义（跨平台统一）。系统自动识别设备所属平台并路由，返回属性列表、Action 定义及参数格式。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | `string` | ✅ | 设备 ID |\n\n**响应示例**:\n```json\n{\n  \"success\": true,\n  \"properties\": [...],\n  \"actions\": [...]\n}\n```\n\n---\n\n## 6. 小米 (Xiaomi) 平台\n\n**控制流程**: `device/list` → `device/specs`（获取 siid/piid/aiid）→ `set_xiaomi_device_property` 或 `execute_xiaomi_device_action`\n\n### 6.1 认证\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `xiaomi/auth_status` | 检查米家 OAuth 授权状态及 Token 剩余时间 | — |\n| `xiaomi/auth_url` | 获取米家 OAuth 授权 URL | — |\n| `xiaomi/auth_callback` | 处理米家 OAuth 授权回调 code | `code` |\n\n**`xiaomi/auth_status` 响应**:\n```json\n{\n  \"authorized\": true,\n  \"remaining_seconds\": 86400,\n  \"cloud_server\": \"cn\"\n}\n```\n\n**`xiaomi/auth_url` 响应**:\n```json\n{\n  \"url\": \"https://account.xiaomi.com/oauth2/authorize?...\",\n  \"message\": \"请在浏览器中打开此 URL 完成米家账号授权。\"\n}\n```\n\n**`xiaomi/auth_callback` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | `string` | ✅ | OAuth 授权码 |\n\n**米家 OAuth 流程**:\n\n```bash\n# 1. 获取授权 URL\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/auth_url\",\"arguments\":{}}}'\n\n# 2. 用户在浏览器打开 URL 完成授权，从回调 URL 获取 code\n\n# 3. 提交 code\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/auth_callback\",\"arguments\":{\"code\":\"CALLBACK_CODE\"}}}'\n```\n\n### 6.2 设备查询\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `xiaomi/refresh` | 从云端重新拉取米家设备列表 | — |\n| `xiaomi/get_devices` | 获取小米设备列表，支持按区域和类别过滤 | — |\n| `xiaomi/get_area_info` | 获取小米智能家居房间/区域列表 | — |\n| `xiaomi/get_device_classes` | 获取当前已导入的小米设备类别列表 | — |\n\n**`xiaomi/refresh` 响应**:\n```json\n{\n  \"success\": true,\n  \"device_count\": 42,\n  \"camera_count\": 3\n}\n```\n\n**`xiaomi/get_devices` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `area_id` | `string` | ❌ | 区域 ID，从 `xiaomi/get_area_info` 获取 |\n| `device_class` | `string` | ❌ | 设备类别，如 `light`、`switch`、`curtain` |\n\n**`xiaomi/get_devices` 响应**:\n```json\n{\n  \"devices\": [\n    {\n      \"did\": \"102838844\",\n      \"name\": \"客厅灯\",\n      \"online\": true,\n      \"home_info\": \"客厅\",\n      \"device_class\": \"light\",\n      \"model\": \"yeelink.light.lamp22\"\n    }\n  ],\n  \"count\": 1\n}\n```\n\n### 6.3 属性读写\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `get_xiaomi_device_properties` | 获取小米设备属性当前值 | `deviceId`, `siid`, `piids` |\n| `set_xiaomi_device_property` | 设置小米设备属性值 | `deviceId`, `siid`, `piid`, `value` |\n| `execute_xiaomi_device_action` | 执行小米设备动作 | `deviceId`, `siid`, `aiid` |\n\n**`get_xiaomi_device_properties` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 设备 ID (did) |\n| `siid` | `integer` | ✅ | Service ID |\n| `piids` | `integer[]` | ✅ | Property ID 列表，如 `[1, 2]` |\n\n**`set_xiaomi_device_property` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 设备 ID |\n| `siid` | `integer` | ✅ | Service ID |\n| `piid` | `integer` | ✅ | Property ID |\n| `value` | `any` | ✅ | 属性值（布尔/数字/字符串） |\n\n**响应**: `{\"success\": true, \"data\": {...}}`\n\n**`execute_xiaomi_device_action` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 设备 ID |\n| `siid` | `integer` | ✅ | Service ID |\n| `aiid` | `integer` | ✅ | Action ID |\n| `params` | `array` | ❌ | Action 参数列表 |\n\n**示例 — 开灯**:\n\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"set_xiaomi_device_property\",\n    \"arguments\": { \"deviceId\": \"YOUR_DID\", \"siid\": 2, \"piid\": 1, \"value\": true }\n  }\n}\n```\n\n### 6.4 场景\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `xiaomi/scene_list` | 获取小米手动场景列表，返回 sceneId 和名称 | — |\n| `xiaomi/scene_trigger` | 触发执行小米手动场景 | `sceneId` |\n\n**`xiaomi/scene_trigger` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `sceneId` | `string` | ✅ | 场景 ID，从 `xiaomi/scene_list` 获取 |\n\n### 6.5 摄像头\n\n> 仅支持 macOS 和 Linux。Windows 版本会返回 `{\"error\": \"当前平台不支持摄像头功能\"}`。\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `xiaomi/camera_list` | 获取所有已发现的米家摄像头 | — |\n| `xiaomi/camera_status` | 获取摄像头流连接状态 | — |\n| `xiaomi/camera_connect` | 连接摄像头并开始接收视频流 | `camera_id` |\n| `xiaomi/camera_disconnect` | 停止流并断开连接 | `camera_id` |\n| `xiaomi/camera_snapshot` | 抓取摄像头 JPEG 截图 | `camera_id` |\n\n**`xiaomi/camera_list` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `filter` | `string[]` | ❌ | 关键词过滤数组（匹配名称/型号/房间） |\n\n**`xiaomi/camera_list` 响应**:\n```json\n{\n  \"cameras\": [\n    {\n      \"did\": \"102838844\",\n      \"name\": \"客厅摄像头\",\n      \"model\": \"chuangmi.camera.ipc019\",\n      \"home\": \"我的家\",\n      \"room\": \"客厅\",\n      \"online\": true,\n      \"channel_count\": 1,\n      \"camera_status\": \"connected\"\n    }\n  ],\n  \"count\": 1\n}\n```\n\n**`xiaomi/camera_status` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | `string` | ❌ | 摄像头 DID，不传则返回所有已连接摄像头状态 |\n\n**`xiaomi/camera_status` 响应** (指定 camera_id):\n```json\n{\n  \"did\": \"102838844\",\n  \"camera_id\": \"102838844\",\n  \"status\": \"connected\",\n  \"buffered_frames\": 5\n}\n```\n\n**`xiaomi/camera_connect` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | `string` | ✅ | 摄像头设备 ID |\n\n**`xiaomi/camera_connect` 响应**:\n```json\n{\n  \"camera_id\": \"102838844\",\n  \"success\": true,\n  \"status\": \"connected\",\n  \"message\": \"Camera connected, streaming started\"\n}\n```\n\n> 连接为异步操作，服务器会等待最多 3 秒轮询连接状态。若超时返回 `\"Connection initiated, current status: connecting. Status will update via polling.\"`。\n\n**`xiaomi/camera_disconnect` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | `string` | ✅ | 摄像头设备 ID |\n\n**`xiaomi/camera_snapshot` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | `string` | ✅ | 摄像头设备 ID |\n| `channel` | `integer` | ❌ | 通道号，默认 `0` |\n| `count` | `integer` | ❌ | 截图帧数，默认 `1`，最大 `10` |\n| `use_subprocess` | `boolean` | ❌ | 强制子进程模式（进程隔离防挂死），默认 `false` |\n\n**`xiaomi/camera_snapshot` 响应** (缓冲区模式):\n```json\n{\n  \"camera_id\": \"102838844\",\n  \"channel\": 0,\n  \"images\": [\n    {\n      \"data_url\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n      \"timestamp\": 1716518400000,\n      \"size_bytes\": 45678\n    }\n  ],\n  \"count\": 1,\n  \"mode\": \"buffered\"\n}\n```\n\n**`xiaomi/camera_snapshot` 响应** (子进程模式):\n```json\n{\n  \"camera_id\": \"102838844\",\n  \"channel\": 0,\n  \"images\": [\n    {\n      \"data_url\": \"data:image/jpeg;base64,/9j/4AAQ...\",\n      \"timestamp\": 1716518400000,\n      \"size_bytes\": 45678\n    }\n  ],\n  \"count\": 1,\n  \"mode\": \"subprocess\"\n}\n```\n\n> **模式说明**: 默认优先从已连接的帧缓冲区读取；若缓冲区为空或指定 `use_subprocess=true`，则启动独立子进程连接摄像头抓拍，避免原生库挂死影响主服务。\n\n**摄像头使用流程**:\n\n```bash\n# 1. 查找摄像头\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/camera_list\",\"arguments\":{}}}'\n\n# 2. 连接摄像头（建立 P2P 流）\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/camera_connect\",\"arguments\":{\"camera_id\":\"CAMERA_DID\"}}}'\n\n# 3. 等待 3-5 秒后截图\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/camera_snapshot\",\"arguments\":{\"camera_id\":\"CAMERA_DID\",\"count\":1}}}'\n\n# 4. 断开连接\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":4,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/camera_disconnect\",\"arguments\":{\"camera_id\":\"CAMERA_DID\"}}}'\n```\n\n---\n\n## 7. 涂鸦 (Tuya) 平台\n\n> 设置设备属性 (`set_tuya_device_property`) 需要设备授权（非免费版）。\n\n### 授权（QR 码扫描）\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `auth/tuya_qr` | 获取涂鸦 QR 码授权，返回 qr_url 和 token | `user_code` |\n| `auth/tuya_qr_status` | 查询 QR 码扫码授权状态 | `token`, `user_code` |\n| `auth/tuya_logout` | 退出涂鸦平台授权 | — |\n| `tuya/refresh` | 刷新涂鸦设备列表（授权后调用） | — |\n\n**QR 码授权流程**:\n\n1. 在涂鸦智能 / Smart Life App 中获取用户代码：**我的 → 设置 → 账号与安全**\n2. 调用 `auth/tuya_qr` 传入 `user_code`，获取 `qr_url` 和 `token`（有效期 5 分钟）\n3. 将 `qr_url` 转为二维码，用涂鸦 App 扫描并确认\n4. 轮询 `auth/tuya_qr_status`，返回 `\"status\": \"success\"` 表示授权成功\n5. 调用 `tuya/refresh` 同步设备\n\n**`auth/tuya_qr` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `user_code` | `string` | ✅ | 涂鸦 App 中的用户代码 |\n\n**`auth/tuya_qr_status` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `token` | `string` | ✅ | `auth/tuya_qr` 返回的 token |\n| `user_code` | `string` | ✅ | 涂鸦用户代码 |\n\n**`tuya/refresh` 响应**:\n```json\n{\n  \"success\": true,\n  \"device_count\": 12\n}\n```\n\n### 设备控制\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `get_tuya_device_properties` | 获取涂鸦设备所有 DP 属性值 | `deviceId` |\n| `set_tuya_device_property` | 设置涂鸦设备 DP 属性值（需授权） | `deviceId`, `code`, `value` |\n\n**`get_tuya_device_properties` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 涂鸦设备 ID |\n\n**`set_tuya_device_property` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 涂鸦设备 ID |\n| `code` | `string` | ✅ | DP 功能点 code（如 `switch_1`, `bright_value`） |\n| `value` | `any` | ✅ | 属性值（boolean/number/string） |\n\n**`set_tuya_device_property` 响应**:\n```json\n{\n  \"success\": true,\n  \"message\": \"...\",\n  \"data\": { ... }\n}\n```\n\n---\n\n## 8. 美的 (Midea) 平台\n\n> 设置设备属性 (`set_midea_device_property`) 需要设备授权（非免费版）。\n\n### 授权（账号密码）\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `auth/midea_login` | 美的账号密码登录（美居/MSmartHome） | `account`, `password` |\n| `auth/midea_logout` | 退出美的平台授权 | — |\n| `midea/refresh` | 刷新美的设备列表 | — |\n\n**`auth/midea_login` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `account` | `string` | ✅ | 手机号或邮箱 |\n| `password` | `string` | ✅ | 账号密码 |\n| `cloud` | `string` | ❌ | 云端类型: `meiju`（美居，默认）或 `msmart`（MSmartHome） |\n\n**`auth/midea_login` 响应**:\n```json\n{\n  \"success\": true,\n  \"device_count\": 8,\n  \"auth_status\": { ... }\n}\n```\n\n**`midea/refresh` 响应**:\n```json\n{\n  \"success\": true,\n  \"device_count\": 8\n}\n```\n\n### 设备控制\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `get_midea_device_properties` | 获取美的设备所有属性值 | `deviceId` |\n| `set_midea_device_property` | 设置美的设备属性值（需授权） | `deviceId`, `property`, `value` |\n\n**`get_midea_device_properties` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 美的设备 ID (applianceCode) |\n\n**`set_midea_device_property` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 美的设备 ID (applianceCode) |\n| `property` | `string` | ✅ | 属性名（如 `power`, `temperature`, `mode`, `fan_speed`） |\n| `value` | `any` | ✅ | 属性值 |\n\n**`set_midea_device_property` 响应**:\n```json\n{\n  \"success\": true,\n  \"message\": \"...\",\n  \"data\": { ... }\n}\n```\n\n**常用属性值参考**:\n- `power`: `0` / `1`（关/开）\n- `temperature`: 整数（如 `26`）\n- `mode`: `cool` / `heat` / `auto`\n- `fan_speed`: `low` / `medium` / `high`\n\n---\n\n## 9. 易微联 (eWeLink) 平台\n\n> 设置设备属性 (`set_ewelink_device_property`) 需要设备授权（非免费版）。\n\n### 授权（账号密码）\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `auth/ewelink_login` | 易微联账号密码登录 | `email`, `password` |\n| `auth/ewelink_logout` | 退出易微联平台授权 | — |\n| `ewelink/refresh` | 刷新易微联设备列表 | — |\n\n**`auth/ewelink_login` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `email` | `string` | ✅ | 邮箱或手机号 |\n| `password` | `string` | ✅ | 账号密码 |\n| `country_code` | `string` | ❌ | 国家代码，默认 `+86` |\n\n**`auth/ewelink_login` 响应**:\n```json\n{\n  \"success\": true,\n  \"device_count\": 5,\n  \"auth_status\": { ... }\n}\n```\n\n### 设备控制\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `get_ewelink_device_properties` | 获取易微联设备所有属性值 | `deviceId` |\n| `set_ewelink_device_property` | 设置易微联设备属性值（需授权） | `deviceId`, `property`, `value` |\n\n**`set_ewelink_device_property` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `deviceId` | `string` | ✅ | 易微联设备 ID |\n| `property` | `string` | ✅ | 属性名（如 `switch`, `switches`） |\n| `value` | `any` | ✅ | 属性值（boolean/string/array） |\n\n**常用属性**:\n- `switch`: `on` / `off`\n- `switches`: JSON 数组，如 `[{\"switch\": \"on\", \"outlet\": 0}]`（多路开关）\n\n---\n\n## 10. 小爱音箱控制\n\n> 使用前先通过 `device/list` 获取音箱 `device_id`（model 以 `xiaomi.wifispeaker` 开头）。\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `xiaoai/play_music` | 控制小爱音箱播放音乐/故事/调整音量 | `device_id` |\n| `xiaoai/tts` | 通过小爱音箱朗读文本（TTS 语音播报） | `device_id`, `text` |\n| `xiaoai/control` | 通过小爱音箱语音指令间接控制设备 | `device_id`, `command` |\n\n**`xiaoai/play_music` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | `string` | ✅ | 音箱设备 ID |\n| `text` | `string` | ⚠️ | 自然语言指令（如\"播放刘德华的歌\"、\"讲个笑话\"、\"音量调到50\"） |\n| `command` | `string` | ⚠️ | `text` 的别名，两者等价。`text` 与 `command` 至少传一个 |\n\n**`xiaoai/tts` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | `string` | ✅ | 音箱设备 ID |\n| `text` | `string` | ✅ | 播报文本内容 |\n\n**`xiaoai/control` 参数**:\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `device_id` | `string` | ✅ | 音箱设备 ID |\n| `command` | `string` | ✅ | 语音指令（如\"打开客厅灯\"、\"调高空调温度\"） |\n| `silence` | `boolean` | ❌ | 静默执行（音箱不语音回复），默认 `true` |\n\n---\n\n## 11. 小智平台\n\nFeyaGate 支持多个并行小智 AI WebSocket 连接。\n\n### `xiaozhi/status`\n\n获取所有小智平台连接状态。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"state\": \"connected\",\n  \"endpoint\": \"wss://xxx\",\n  \"connected\": true,\n  \"initialized\": true,\n  \"bridged_tools\": 42,\n  \"enabled\": true,\n  \"clients\": [\n    {\n      \"index\": 0,\n      \"endpoint\": \"wss://xxx\",\n      \"state\": \"connected\",\n      \"connected\": true,\n      \"initialized\": true,\n      \"bridged_tools\": 42\n    }\n  ],\n  \"count\": 1,\n  \"max_count\": 10\n}\n```\n\n### `xiaozhi/list`\n\n列出所有已配置的小智连接端点及状态。\n\n**参数**: 无\n\n### `xiaozhi/add`\n\n添加一个新的小智平台 WebSocket 连接。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `endpoint` | `string` | ✅ | WebSocket URL（`ws://` 或 `wss://`） |\n\n**响应示例**:\n```json\n{\n  \"success\": true,\n  \"endpoint\": \"wss://xxx\",\n  \"index\": 0,\n  \"count\": 1\n}\n```\n\n### `xiaozhi/remove`\n\n删除指定索引的小智连接。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `index` | `integer` | ✅ | 连接索引（从 `xiaozhi/list` 获取） |\n\n### `xiaozhi/set_endpoint`\n\n设置第一个小智端点（向后兼容接口）。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `endpoint` | `string` | ❌ | WebSocket URL，留空则禁用并删除 |\n\n---\n\n## 12. 认证与平台管理\n\n### `auth/platforms`\n\n列出所有已注册的智能家居平台及认证状态。\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"xiaomi\": { \"connected\": true, \"authenticated\": true },\n  \"tuya\": { \"connected\": false, \"authenticated\": false },\n  \"midea\": { \"connected\": true, \"authenticated\": true },\n  \"ewelink\": { \"connected\": false, \"authenticated\": false }\n}\n```\n\n---\n\n## 13. Vision AI\n\n### `xiaomi/camera_vision_chat`\n\n向 Vision AI 提问摄像头画面内容。发送摄像头最近几帧图像和用户问题给 LLM，返回 AI 分析结果。\n\n> 需先在 `config.yaml` 中配置 `vision.enabled=true` 和 `api_key`。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `camera_id` | `string` | ✅ | 摄像头设备 DID |\n| `query` | `string` | ✅ | 向 AI 提出的问题（如\"现在有几个人？\"） |\n| `channel` | `integer` | ❌ | 摄像头通道，默认 `0` |\n| `count` | `integer` | ❌ | 发送最近几帧，默认 `3`，最大 `10` |\n\n**响应示例**:\n```json\n{\n  \"camera_id\": \"102838844\",\n  \"camera_name\": \"客厅摄像头\",\n  \"channel\": 0,\n  \"images_used\": 3,\n  \"model\": \"configured\",\n  \"content\": \"画面中有2个人，正在客厅看电视...\",\n  \"tokens\": {\n    \"prompt\": 1500,\n    \"completion\": 200\n  }\n}\n```\n\n---\n\n## 14. 触发规则\n\n触发引擎监控摄像头画面，当满足自然语言描述的条件时自动执行智能家居动作。\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `trigger/create` | 创建摄像头触发规则 | `name`, `cameras`, `condition` |\n| `trigger/list` | 列出所有触发规则 | — |\n| `trigger/update` | 更新触发规则 | `id` |\n| `trigger/delete` | 删除触发规则 | `id` |\n| `trigger/toggle` | 启用或禁用触发规则 | `id`, `enabled` |\n| `trigger/logs` | 查看触发规则执行日志 | — |\n\n### `trigger/create`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | `string` | ✅ | 规则名称 |\n| `cameras` | `string[]` | ✅ | 关联摄像头 DID 列表 |\n| `condition` | `string` | ✅ | 自然语言触发条件（如\"有人进入客厅\"） |\n| `actions` | `array` | ❌ | 触发时执行的动作列表 |\n| `notify` | `object` | ❌ | 通知配置 `{title, body}` |\n| `filter` | `object` | ❌ | 过滤器 `{interval, period}` |\n\n**响应示例**:\n```json\n{\n  \"id\": \"rule_001\",\n  \"message\": \"触发规则已创建\",\n  \"rule\": { ... }\n}\n```\n\n### `trigger/update`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | `string` | ✅ | 规则 ID |\n| `name` | `string` | ❌ | 新名称 |\n| `cameras` | `string[]` | ❌ | 新摄像头列表 |\n| `condition` | `string` | ❌ | 新触发条件 |\n| `actions` | `array` | ❌ | 新动作列表 |\n| `notify` | `object` | ❌ | 新通知配置 |\n| `filter` | `object` | ❌ | 新过滤器 |\n| `enabled` | `boolean` | ❌ | 启用/禁用 |\n\n### `trigger/toggle`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | `string` | ✅ | 规则 ID |\n| `enabled` | `boolean` | ✅ | `true` 启用，`false` 禁用 |\n\n### `trigger/logs`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `limit` | `integer` | ❌ | 返回条数限制，默认 `50` |\n| `rule_id` | `string` | ❌ | 按规则 ID 过滤 |\n\n---\n\n## 15. 定时任务\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `schedule/add` | 创建定时任务，到时自动执行指定 MCP 工具 | `name`, `scheduled_time`, `tool_name`, `tool_args` |\n| `schedule/list` | 列出定时任务，可按状态筛选 | — |\n| `schedule/get` | 获取定时任务详情 | `id` |\n| `schedule/update` | 修改任务（仅 pending 状态可修改） | `id` |\n| `schedule/delete` | 删除定时任务 | `id` |\n| `schedule/cancel` | 取消待执行任务（保留记录，状态变为 cancelled） | `id` |\n\n### `schedule/add`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | `string` | ✅ | 任务名称 |\n| `scheduled_time` | `string` | ✅ | 执行时间，ISO 8601 格式（如 `2026-05-24T22:00:00+08:00`） |\n| `tool_name` | `string` | ✅ | 要执行的 MCP 工具名（如 `set_xiaomi_device_property`） |\n| `tool_args` | `string` | ✅ | 工具参数 JSON 字符串 |\n| `repeat` | `string` | ❌ | 重复类型: `none` / `daily` / `weekdays` / `weekends` / `weekly` / `custom` |\n| `repeat_days` | `string` | ❌ | 自定义重复天 JSON 数组字符串，如 `\"[1,2,3,4,5]\"`（0=周日） |\n\n**示例 — 每天晚上 10 点关灯**:\n\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"schedule/add\",\n    \"arguments\": {\n      \"name\": \"晚上关灯\",\n      \"scheduled_time\": \"2026-05-24T22:00:00+08:00\",\n      \"tool_name\": \"set_xiaomi_device_property\",\n      \"tool_args\": \"{\\\"deviceId\\\":\\\"YOUR_DID\\\",\\\"siid\\\":2,\\\"piid\\\":1,\\\"value\\\":false}\",\n      \"repeat\": \"daily\"\n    }\n  }\n}\n```\n\n### `schedule/list`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `status` | `string` | ❌ | 状态过滤: `pending` / `completed` / `cancelled`，留空返回全部 |\n\n### `schedule/get` / `schedule/delete` / `schedule/cancel`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | `integer` | ✅ | 任务 ID（整数） |\n\n### `schedule/update`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `id` | `integer` | ✅ | 任务 ID（整数） |\n| `scheduled_time` | `string` | ❌ | 新执行时间 ISO 8601 |\n| `repeat` | `string` | ❌ | 新重复类型 |\n| `repeat_days` | `string` | ❌ | 自定义重复天 JSON 数组字符串 |\n\n---\n\n## 16. 技能系统\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `skill/list` | 列出所有技能，可按来源过滤 | — |\n| `skill/read` | 读取指定技能的完整内容（含 frontmatter） | `name` |\n| `skill/create` | 创建新的自定义技能 | `name`, `content` |\n| `skill/update` | 更新已有自定义技能的内容 | `name`, `content` |\n| `skill/delete` | 删除指定自定义技能（内置技能不可删除） | `name` |\n| `skill/context` | 获取所有常驻技能的上下文内容和技能摘要 | — |\n| `skill/reload` | 重新扫描技能目录并刷新缓存 | — |\n\n### `skill/list`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `source` | `string` | ❌ | 来源过滤: `all`（默认）/ `builtin` / `user` |\n\n**响应示例**:\n```json\n{\n  \"skills\": [\n    {\n      \"name\": \"smart_light\",\n      \"description\": \"智能灯光控制技能\",\n      \"source\": \"builtin\",\n      \"always\": false,\n      \"tags\": [\"light\", \"control\"],\n      \"path\": \"/path/to/skill.md\"\n    }\n  ],\n  \"count\": 1\n}\n```\n\n### `skill/read`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | `string` | ✅ | 技能名称 |\n\n**响应示例**:\n```json\n{\n  \"name\": \"smart_light\",\n  \"description\": \"智能灯光控制技能\",\n  \"source\": \"builtin\",\n  \"always\": false,\n  \"tags\": [\"light\"],\n  \"path\": \"/path/to/skill.md\",\n  \"content\": \"---\\nname: smart_light\\n---\\n# 技能正文\",\n  \"body\": \"# 技能正文\"\n}\n```\n\n### `skill/create` / `skill/update`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | `string` | ✅ | 技能名称（字母数字和连字符） |\n| `content` | `string` | ✅ | 技能内容（Markdown + YAML frontmatter 格式） |\n\n### `skill/delete`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `name` | `string` | ✅ | 技能名称（内置技能不可删除） |\n\n### `skill/context`\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"context\": \"...\",\n  \"skill_count\": 5\n}\n```\n\n### `skill/reload`\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"success\": true,\n  \"skill_count\": 5\n}\n```\n\n---\n\n## 17. 配置管理\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `config/get_vision` | 获取 Vision AI 当前配置（API Key 脱敏显示） | — |\n| `config/set_vision` | 更新 Vision AI 配置并保存到 `config.yaml`，修改后立即生效 | — |\n| `config/get_trigger` | 获取触发引擎当前配置 | — |\n| `config/set_trigger` | 更新触发引擎配置并保存到 `config.yaml`，修改后立即生效 | — |\n\n### `config/get_vision`\n\n**响应示例**:\n```json\n{\n  \"enabled\": true,\n  \"api_key_masked\": \"sk-x****1234\",\n  \"has_api_key\": true,\n  \"base_url\": \"https://api.openai.com/v1\",\n  \"model\": \"gpt-4o\",\n  \"temperature\": 0.7,\n  \"max_tokens\": 4096,\n  \"timeout_seconds\": 30\n}\n```\n\n### `config/set_vision`\n\n所有参数可选，仅传入需要修改的字段。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `enabled` | `boolean` | ❌ | 是否启用 Vision AI |\n| `api_key` | `string` | ❌ | Vision AI API 密钥 |\n| `base_url` | `string` | ❌ | OpenAI 兼容 API 端点 |\n| `model` | `string` | ❌ | 模型名称 |\n| `temperature` | `number` | ❌ | 温度参数 (0-2) |\n| `max_tokens` | `integer` | ❌ | 最大响应 Token 数 |\n| `timeout_seconds` | `integer` | ❌ | HTTP 超时秒数 |\n\n**响应示例**:\n```json\n{\n  \"success\": true,\n  \"config_saved\": true,\n  \"message\": \"Vision AI 配置已保存并生效\",\n  \"enabled\": true,\n  \"api_key_masked\": \"sk-x****1234\",\n  \"base_url\": \"https://api.openai.com/v1\",\n  \"model\": \"gpt-4o\",\n  \"temperature\": 0.7,\n  \"max_tokens\": 4096,\n  \"timeout_seconds\": 30\n}\n```\n\n### `config/get_trigger`\n\n**响应示例**:\n```json\n{\n  \"enabled\": true,\n  \"interval_seconds\": 30,\n  \"vision_img_count\": 3,\n  \"motion_threshold\": 10,\n  \"log_ttl_days\": 30,\n  \"min_trigger_interval\": 300\n}\n```\n\n### `config/set_trigger`\n\n所有参数可选，仅传入需要修改的字段。启用/禁用会自动启停引擎。\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `enabled` | `boolean` | ❌ | 是否启用触发引擎 |\n| `interval_seconds` | `integer` | ❌ | 规则检查间隔（秒） |\n| `vision_img_count` | `integer` | ❌ | 每次 LLM 调用使用的帧数 |\n| `motion_threshold` | `integer` | ❌ | dHash 运动检测阈值 |\n| `log_ttl_days` | `integer` | ❌ | 日志保留天数 |\n| `min_trigger_interval` | `integer` | ❌ | 单规则最小触发间隔（秒，防抖） |\n\n---\n\n## 18. 统计数据\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `stats/token_usage` | 获取 Token 消耗统计（按天/按模型/按来源/总览） | — |\n| `stats/token_records` | 获取最近的 LLM API 调用记录 | — |\n| `stats/trigger_summary` | 获取触发事件聚合统计（每日趋势、规则排名、摄像头分布、热力图） | — |\n| `stats/dashboard` | 获取综合看板摘要（系统状态、今日概览） | — |\n\n### `stats/token_usage`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `days` | `integer` | ❌ | 统计最近多少天，默认 `30` |\n\n**响应示例**:\n```json\n{\n  \"summary\": { \"total_tokens\": 150000, \"total_calls\": 300 },\n  \"daily\": [ {\"date\": \"2026-05-20\", \"tokens\": 5000, \"calls\": 10} ],\n  \"by_model\": [ {\"model\": \"gpt-4o\", \"tokens\": 100000} ],\n  \"by_source\": [ {\"source\": \"vision\", \"tokens\": 80000} ]\n}\n```\n\n### `stats/token_records`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `limit` | `integer` | ❌ | 返回记录数，默认 `50` |\n\n**响应示例**:\n```json\n{\n  \"records\": [ ... ]\n}\n```\n\n### `stats/trigger_summary`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `days` | `integer` | ❌ | 统计最近多少天，默认 `30` |\n\n**响应示例**:\n```json\n{\n  \"overview\": {\n    \"today\": 5,\n    \"this_week\": 32,\n    \"total\": 150,\n    \"enabled_rules\": 3,\n    \"total_rules\": 5\n  },\n  \"daily\": [ {\"date\": \"2026-05-20\", \"count\": 8} ],\n  \"by_rule\": [ {\"rule_id\": \"rule_001\", \"rule_name\": \"有人进入\", \"count\": 20} ],\n  \"by_camera\": [ {\"camera_id\": \"102838844\", \"count\": 45} ],\n  \"heatmap\": [ {\"weekday\": \"Mon\", \"weekday_idx\": 0, \"hour\": 9, \"count\": 3} ]\n}\n```\n\n### `stats/dashboard`\n\n**参数**: 无\n\n**响应示例**:\n```json\n{\n  \"trigger_engine\": {\n    \"enabled\": true,\n    \"enabled_rules\": 3,\n    \"total_rules\": 5\n  },\n  \"today\": {\n    \"ai_calls\": 42,\n    \"triggers\": 5,\n    \"actions_executed\": 8,\n    \"tokens_used\": 12000\n  },\n  \"token_summary\": { ... },\n  \"action_ranking\": [ {\"action\": \"turn_off_light\", \"count\": 3} ],\n  \"recent_events\": [\n    {\"time\": \"2026-05-24T10:30:00\", \"rule_name\": \"有人进入\", \"camera_id\": \"xxx\"}\n  ]\n}\n```\n\n---\n\n## 19. 授权码管理\n\nFeyaGate 免费版仅支持米家平台，授权版支持全平台（涂鸦/美的/易微联）。\n\n| 工具名 | 说明 | 必填参数 |\n|--------|------|----------|\n| `license/status` | 获取虚拟网关授权状态 | — |\n| `license/set` | 写入授权码并触发云端激活 | `license_key` |\n| `license/clear` | 清除授权码，恢复免费版 | — |\n\n### `license/status`\n\n**响应示例** (已授权):\n```json\n{\n  \"edition\": \"pro\",\n  \"status\": \"active\",\n  \"product\": \"feyagate-linux\",\n  \"device_id\": \"xxx\",\n  \"key_masked\": \"FG-xxxx-****-xxxx\"\n}\n```\n\n**响应示例** (免费版):\n```json\n{\n  \"edition\": \"free\",\n  \"status\": \"inactive\",\n  \"product\": \"feyagate-linux\",\n  \"device_id\": \"xxx\",\n  \"key_masked\": \"\",\n  \"guidance\": {\n    \"message\": \"当前为免费版，仅支持米家平台。如需使用涂鸦/美的/易微联等平台，请获取授权码。\",\n    \"how_to_authorize\": \"1. 联系代理商购买授权版虚拟网关\\n2. 获取授权码 (格式: FG-XXXX-XXXX-XXXX)\\n3. 使用 license/set 工具写入授权码\\n4. 系统自动向云端激活\",\n    \"free_features\": \"米家平台、设备控制、摄像头、小爱音箱、MCP代理、小智AI\",\n    \"licensed_features\": \"以上全部 + 涂鸦平台 + 美的平台 + 易微联平台\"\n  }\n}\n```\n\n### `license/set`\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `license_key` | `string` | ✅ | 授权码，格式 `FG-XXXX-XXXX-XXXX` |\n| `product` | `string` | ❌ | 产品标识，默认使用配置文件中的值 |\n\n**响应示例**:\n```json\n{\n  \"edition\": \"pro\",\n  \"status\": \"active\",\n  \"activated\": true,\n  \"message\": \"授权成功! 全平台功能已解锁。\"\n}\n```\n\n> 授权码绑定设备，一码一机，激活后不可转移。\n\n### `license/clear`\n\n**响应示例**:\n```json\n{\n  \"edition\": \"free\",\n  \"status\": \"inactive\",\n  \"message\": \"授权已清除，已恢复为免费版 (仅米家平台)。\"\n}\n```\n\n---\n\n## 20. 网关信息\n\n### `gateway/info`\n\n获取虚拟网关信息，包括版本、平台、设备 ID、授权状态。\n\n**参数**: 无\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"gateway/info\",\"arguments\":{}}}'\n```\n\n---\n\n## 21. 错误码\n\n### JSON-RPC 协议错误\n\n| 错误码 | 含义 |\n|--------|------|\n| `-32700` | 解析错误（Invalid JSON） |\n| `-32600` | 非法请求（非 JSON-RPC 2.0） |\n| `-32601` | 方法不存在 |\n| `-32602` | 参数错误（缺少 `params.name` 或工具不存在） |\n| `-32603` | 服务器内部错误 |\n\n### 工具业务错误\n\n工具返回的 JSON 中可能包含以下错误：\n\n| 字段 | 说明 |\n|------|------|\n| `{\"error\": \"...\"}` | 通用业务错误 |\n| `{\"success\": false, \"error\": \"license_required\"}` | 需要设备授权（涂鸦/美的/易微联设置操作） |\n| `{\"error\": \"当前平台不支持摄像头功能\"}` | Windows 平台不支持摄像头 |\n\n---\n\n## 附录: 快速示例\n\n### 查找并控制客厅灯\n\n```bash\n# 1. 查找设备\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"device/list\",\"arguments\":{\"filter\":[\"客厅\",\"灯\"]}}}'\n\n# 2. 查询设备规格\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"device/specs\",\"arguments\":{\"device_id\":\"YOUR_DID\"}}}'\n\n# 3. 开灯\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"set_xiaomi_device_property\",\"arguments\":{\"deviceId\":\"YOUR_DID\",\"siid\":2,\"piid\":1,\"value\":true}}}'\n```\n\n### 检查各平台授权状态\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"auth/platforms\",\"arguments\":{}}}'\n```\n\n### 创建触发规则（有人进门开灯）\n\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1, \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"trigger/create\",\n    \"arguments\": {\n      \"name\": \"玄关感应开灯\",\n      \"cameras\": [\"CAMERA_DID\"],\n      \"condition\": \"有人进入玄关\",\n      \"actions\": [\n        {\n          \"tool\": \"set_xiaomi_device_property\",\n          \"args\": { \"deviceId\": \"LIGHT_DID\", \"siid\": 2, \"piid\": 1, \"value\": true }\n        }\n      ]\n    }\n  }\n}\n```\n\nFile v1.0.9:QUICKSTART.md\n\n# FeyaGate Skill — Quick Start Guide\n\n```\n  _____                 ____       _\n |  ___|__ _   _  __ _ / ___| __ _| |_ ___\n | |_ / _ \\ | | |/ _` | |  _ / _` | __/ _ \\\n |  _|  __/ |_| | (_| | |_| | (_| | ||  __/\n |_|  \\___|\\__, |\\__,_|\\____|\\__,_|\\__\\___|\n           |___/\n```\n\n> **For AI Assistants (OpenClaw, Claude Code, Hermes, Codex, Windsurf, Copilot, 小智AI, Cursor):**\n> Follow Steps 1-4 sequentially. Report progress at each step. Do NOT skip steps.\n> Steps marked with **[AUTO]** can be executed without asking the user.\n> Steps marked with **[ASK]** require user input before proceeding.\n\n## Prerequisites\n\n- Python 3.9+\n- Internet access (for downloading MCP server binary ~30MB)\n\n## One-Line Install [AUTO]\n\n**macOS / Linux** — installs the Python package and MCP server binary in one step:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.sh | bash\n```\n\n**Windows (PowerShell):**\n\n```powershell\niwr -useb https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.ps1 | iex\n```\n\nAfter one-line install, skip to **Step 3** (install agent skill). If you prefer manual steps, continue below.\n\n> **For developers:** Clone the repo and use `pip install -e .` instead of the one-line script — see Step 1 Option B.\n\n## Step 1: Install [AUTO]\n\n**Option A — from PyPI (standard online install):**\n\n```bash\npip install feyagate-skill\n```\n\n**Option B — from source (developers / contributors):**\n\n```bash\ngit clone https://github.com/toddpan/feyagate-skill.git\ncd feyagate-skill\npip install -e \".[dev]\"     # includes pytest and other dev dependencies\n```\n\nVerify:\n\n```bash\nfeyagate --version\n```\n\n## Step 2: Setup & Start [AUTO]\n\nDownload and install the MCP server binary (may take 1-2 minutes):\n\n```bash\nfeyagate setup\n```\n\nDefault directory: `~/.feyagate`. Customize with `feyagate setup --dir ~/my-feyagate`.\n\nStart the service:\n\n```bash\nfeyagate start\n```\n\nVerify:\n\n```bash\nfeyagate status\n```\n\nService URL: `http://localhost:38080/mcp/http`. Custom port: `feyagate start --port 9090`.\n\n## Step 3: Install as AI Agent Skill [ASK]\n\n> **IMPORTANT:** This step installs the FeyaGate skill (SKILL.md + sub-skills) for the AI agent you are currently running in.\n> Ask the user: \"Which AI agent should I install for?\" or detect from the environment.\n\n```bash\nfeyagate install-claude     # Claude Code\nfeyagate install-cursor     # Cursor\nfeyagate install-openclaw   # OpenClaw\nfeyagate install-hermes     # Hermes Agent\nfeyagate install-windsurf   # Windsurf\nfeyagate install-copilot    # GitHub Copilot (VS Code)\nfeyagate install-codex      # OpenAI Codex CLI\n```\n\nAfter install, **restart the AI agent** to load the skill.\n\n## Step 4: Authorize Smart Home Platform [ASK]\n\n> Ask the user which platform(s) they want to authorize.\n\n### Xiaomi / Mi Home (OAuth)\n\n```bash\nfeyagate auth --status    # Check current status\nfeyagate auth             # Interactive OAuth authorization\n```\n\nThe interactive flow will output a URL → user opens in browser → logs in → pastes the callback URL back.\n\n### Tuya (QR Code Scan)\n\nRequires Tuya Smart or Smart Life app. User Code location: **Me → Settings → Account & Security → User Code**.\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"auth/tuya_qr\",\"arguments\":{\"user_code\":\"USER_CODE\"}}}' \\\n  | python3 -m json.tool\n```\n\nScan the returned `qr_url` with the Tuya app, then check status with `auth/tuya_qr_status`.\n\n### Midea (Password Login)\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"auth/midea_login\",\"arguments\":{\"account\":\"PHONE_OR_EMAIL\",\"password\":\"PASSWORD\"}}}' \\\n  | python3 -m json.tool\n```\n\n### eWeLink (Password Login)\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"auth/ewelink_login\",\"arguments\":{\"email\":\"EMAIL\",\"password\":\"PASSWORD\",\"country_code\":\"+86\"}}}' \\\n  | python3 -m json.tool\n```\n\n### Verify Authorization\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"auth/platforms\",\"arguments\":{}}}' \\\n  | python3 -m json.tool\n```\n\n## Setup Complete\n\nAfter completing Steps 1-4, the user can control smart home devices through their AI agent.\nThe AI agent will automatically use the MCP tools (e.g. `device/list`, `device/specs`, `xiaomi/set_property`).\n\n---\n\n## Service Management\n\n```bash\nfeyagate status      # Check service status\nfeyagate log         # View server logs\nfeyagate log -n 50   # View last 50 lines of logs\nfeyagate stop        # Stop service\nfeyagate restart     # Restart service\nfeyagate update      # Update MCP server to latest version\n```\n\n## Usage Examples\n\n> These examples show how to use the MCP tools via curl.\n> When using through an AI agent, the agent calls these tools automatically — no curl needed.\n\n### List & Search Devices\n\n```bash\n# All devices\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"device/list\",\"arguments\":{\"filter\":[]}}}' \\\n  | python3 -m json.tool\n\n# Search by keyword\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"device/list\",\"arguments\":{\"filter\":[\"living room\",\"light\"]}}}' \\\n  | python3 -m json.tool\n\n# Filter by platform\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"device/list\",\"arguments\":{\"filter\":[],\"platform\":\"xiaomi\"}}}' \\\n  | python3 -m json.tool\n```\n\n### Control Xiaomi / MIOT Device\n\n**Control flow:** `device/list` → `device/specs` (get siid/piid/aiid) → `xiaomi/set_property` or `xiaomi/execute_action`\n\n> **Parameter naming:** Cross-platform tool `device/specs` uses `deviceId` (camelCase); platform-specific tools use `device_id` (snake_case).\n\n```bash\n# Query device spec\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"device/specs\",\"arguments\":{\"deviceId\":\"YOUR_DID\"}}}' \\\n  | python3 -m json.tool\n\n# Read property\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/get_properties\",\"arguments\":{\"device_id\":\"YOUR_DID\",\"siid\":2,\"piids\":[1]}}}' \\\n  | python3 -m json.tool\n\n# Set property (turn on light)\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/set_property\",\"arguments\":{\"device_id\":\"YOUR_DID\",\"siid\":2,\"piid\":1,\"value\":true}}}' \\\n  | python3 -m json.tool\n\n# Execute action\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":4,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/execute_action\",\"arguments\":{\"device_id\":\"YOUR_DID\",\"siid\":2,\"aiid\":1}}}' \\\n  | python3 -m json.tool\n```\n\n### Scenes\n\n```bash\n# List scenes\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"scene/list\",\"arguments\":{\"platform\":\"xiaomi\"}}}' \\\n  | python3 -m json.tool\n\n# Trigger scene\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"scene/trigger\",\"arguments\":{\"platform\":\"xiaomi\",\"sceneId\":\"SCENE_ID\"}}}' \\\n  | python3 -m json.tool\n```\n\n### Xiao AI Speaker\n\n```bash\n# TTS broadcast\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaoai/tts\",\"arguments\":{\"device_id\":\"SPEAKER_DID\",\"text\":\"Hello, welcome home\"}}}' \\\n  | python3 -m json.tool\n\n# Play music\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaoai/play_music\",\"arguments\":{\"device_id\":\"SPEAKER_DID\",\"text\":\"Play some pop music\"}}}' \\\n  | python3 -m json.tool\n\n# Voice control (silent mode)\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaoai/control\",\"arguments\":{\"device_id\":\"SPEAKER_DID\",\"command\":\"turn on the living room light\",\"silence\":true}}}' \\\n  | python3 -m json.tool\n```\n\n### Camera\n\n```bash\n# CLI\nfeyagate snapshot --list\nfeyagate snapshot --camera-id CAMERA_DID --connect --count 3\n\n# API: connect → wait → snapshot → disconnect\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/camera_connect\",\"arguments\":{\"camera_id\":\"CAMERA_DID\"}}}'\n# Wait 3-5 seconds for P2P connection\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/camera_snapshot\",\"arguments\":{\"camera_id\":\"CAMERA_DID\",\"count\":1}}}' \\\n  | python3 -m json.tool\n```\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| `command not found: feyagate` | `pip install feyagate-skill` or `pip install -e .` from repo root |\n| `FeyaGate not installed` | `feyagate setup` |\n| `connection refused` | `feyagate start` |\n| `authorized: false` | `feyagate auth` |\n| `cannot open shared object file` | `feyagate update` or re-run `feyagate setup` |\n| `Tool not found` | Check tool name with `tools/list` |\n| `key 'device_id' not found` | `device/specs` uses `deviceId`; platform tools use `device_id` |\n| `camera_connect` fails | Check camera native libraries in `lib/` |\n| No frame data | Wait 3-5 seconds, check `xiaomi/camera_status` |\n\nFor full API reference, see [SKILL.md](SKILL.md), [FeyaGate_MCP_API.md](FeyaGate_MCP_API.md), and [FeyaGate_HTTP_API.md](FeyaGate_HTTP_API.md).\n\nFile v1.0.9:skill-card.md\n\n## Description:\n\nMCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol.\n\nThis skill is ready for commercial/non-commercial use.\n\n## Publisher:\n\n[toddpan](https://clawhub.ai/user/toddpan)\n\n### License/Terms of Use:\n\nMIT-0\n\n## Use Case:\n\nDevelopers and smart-home operators use Feyagate to connect AI agents to a local MCP/HTTP gateway for supported device discovery, authorization, control, camera access, automation, and configuration workflows.\n\n### Deployment Geography for Use:\n\nGlobal\n\n## Known Risks and Mitigations:\n\nRisk: Auto-install instructions and binary download can execute code that has not been independently reviewed.\n\nMitigation: Review the installer and binary source first, prefer pinned versions with checksums, and require explicit approval before running one-line install commands.\n\nRisk: The gateway can expose smart-home controls, account credentials, camera data, and Vision AI settings.\n\nMitigation: Run the gateway on localhost only, keep it behind a firewall, and avoid entering account passwords over non-loopback HTTP.\n\nRisk: Camera/Vision AI, schedules, memory, and skill-management tools can create persistent or sensitive changes.\n\nMitigation: Treat those tools as admin-only actions and require explicit user approval before use.\n\n## Reference(s):\n\n- [ClawHub skill page](https://clawhub.ai/toddpan/skills/feyagate)\n- [Server-resolved GitHub provenance](https://github.com/toddpan/feyagate-skill)\n- [Feyagate homepage](https://www.feyagate.com)\n- [Quick Start Guide](artifact/QUICKSTART.md)\n- [FeyaGate MCP API](artifact/FeyaGate_MCP_API.md)\n- [FeyaGate HTTP API](artifact/FeyaGate_HTTP_API.md)\n\n## Skill Output:\n\n**Output Type(s):** [guidance, shell commands, configuration, API calls]\n\n**Output Format:** [Markdown guidance with command snippets, JSON tool-call examples, and configuration snippets]\n\n**Output Parameters:** [1D]\n\n**Other Properties Related to Output:** [May initiate MCP/HTTP requests and smart-home device actions through a local gateway after user authorization.]\n\n## Skill Version(s):\n\n1.0.9 (source: server release metadata; artifact frontmatter reports 1.2.31)\n\n## Ethical Considerations:\n\nUsers should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.\n\nFile v1.0.9:skills/automation.md\n\n---\nname: automation\ndescription: Automation tools. Schedule tasks, trigger engine, room management, memory/note system, skill management.\nversion: 1.2.31\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n---\n\n# Automation & Utility Tools\n\n> **Parent skill:** [SKILL.md](../SKILL.md) — provides cross-platform tools and MCP endpoint config.\n\n## Schedule\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `schedule/add` | `name`, `scheduledTime`, `toolName`, `toolArgs`, `repeat`, `repeatDays` (opt) | Task ID |\n| `schedule/list` | — | `tasks[]` |\n| `schedule/get` | `id` | Task detail |\n| `schedule/update` | `id` + fields to update | Update result |\n| `schedule/delete` | `id` | Delete result |\n| `schedule/cancel` | `id` | Cancel result |\n\n**Repeat types:** `none` / `daily` / `weekdays` / `weekends` / `weekly` / `custom_days`\n\n**Example:**\n```json\n{\n  \"name\": \"schedule/add\",\n  \"arguments\": {\n    \"name\": \"睡前关灯\",\n    \"scheduledTime\": \"2026-05-16T23:00:00+08:00\",\n    \"toolName\": \"xiaomi/set_property\",\n    \"toolArgs\": \"{\\\"device_id\\\":\\\"xxx\\\",\\\"siid\\\":2,\\\"piid\\\":1,\\\"value\\\":false}\",\n    \"repeat\": \"daily\"\n  }\n}\n```\n\n## Trigger Engine (PC proxy)\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `trigger/create` | `name`, `cameras`, `condition`, `actions` | Rule ID |\n| `trigger/list` | — | `rules[]` |\n| `trigger/update` | `id`, fields to update | Update result |\n| `trigger/delete` | `id` | Delete result |\n| `trigger/toggle` | `id`, `enabled` | Toggle result |\n| `trigger/logs` | `limit`, `rule_id` (opt) | `logs[]` |\n\n## Room Management\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `room/list` | — | Unique room name list |\n| `room/set_device` | `device_ids` (string[]), `room_name` (string) | Assignment result |\n\n## Memory System\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `memory/read` | — | All long-term memories |\n| `memory/add` | `content`, `category` (opt) | Added entry |\n| `memory/update` | `id`, `content` | Update result |\n| `memory/delete` | `id` | Delete result |\n| `memory/search` | `keyword` | Matching entries |\n| `memory/note` | `content` | Add today's note |\n| `memory/today` | — | Today's notes |\n\n## Skill System\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `skill/list` | — | Available skills |\n| `skill/read` | `id` | Skill content |\n| `skill/manage` | `action` (add/update/delete) + other fields | Manage result |\n\nFile v1.0.9:skills/ewelink.md\n\n---\nname: ewelink\ndescription: eWeLink platform tools. Account/password auth, read/write device properties for Sonoff and eWeLink devices.\nversion: 1.2.31\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n---\n\n# eWeLink Platform Tools\n\n> **Parent skill:** [SKILL.md](../SKILL.md) — provides cross-platform tools (`device/list`, `device/specs`, `platform/status`) and MCP endpoint config.\n\n## Authorization\n\n### Account Login\n\neWeLink uses email/phone and password login.\n\n**Login:**\n\n```json\n{\n  \"name\": \"auth/ewelink_login\",\n  \"arguments\": {\n    \"email\": \"YOUR_EMAIL_OR_PHONE\",\n    \"password\": \"YOUR_PASSWORD\",\n    \"country_code\": \"+86\"\n  }\n}\n```\n\n| Parameter | Required | Description |\n|-----------|----------|-------------|\n| `email` | Yes | eWeLink account email or phone number |\n| `password` | Yes | eWeLink account password |\n| `country_code` | No | Country code (e.g., `+86` for China, `+1` for US) |\n\nReturns on success:\n```json\n{\n  \"success\": true,\n  \"auth_status\": {\n    \"authenticated\": true,\n    \"region\": \"cn\",\n    \"token_remaining_seconds\": 2592000,\n    \"ws_connected\": true,\n    \"ws_handshaked\": true\n  },\n  \"device_count\": 1\n}\n```\n\nToken is valid for 2592000 seconds (30 days). WebSocket connection is established automatically for real-time updates. Re-login when expired.\n\n**Refresh device list after login:**\n\n```json\n{\n  \"name\": \"ewelink/refresh\",\n  \"arguments\": {}\n}\n```\n\n### Other Auth Tools\n\n| Tool | Description |\n|------|-------------|\n| `ewelink/refresh` | Refresh device list from cloud |\n| `auth/ewelink_logout` | Clear eWeLink authorization |\n\n### Check Authorization Status\n\n```json\n{\n  \"name\": \"auth/platforms\",\n  \"arguments\": {}\n}\n```\n\nLook for the `ewelink` entry to verify `authenticated: true`.\n\n## Device Control\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `ewelink/get_properties` | `device_id` | Property values |\n| `ewelink/set_property` | `device_id`, `property`, `value` | Set result (**requires license**) |\n| `ewelink/execute_action` | `device_id`, `action` | Action result (**requires license**) |\n\n**Parameter convention:** eWeLink tools use `device_id` (snake_case).\nCross-platform tool `device/specs` uses `deviceId` (camelCase).\n\n**Property examples:**\n- `switch`: `on` / `off` (single channel)\n- `switches`: JSON array `[{\"switch\": \"on\", \"outlet\": 0}]` (multi-channel)\n\n**Workflow (steps 3-4 use parent skill tools):**\n1. `auth/ewelink_login` → login with email/phone and password\n2. `ewelink/refresh` → refresh device list from cloud\n3. `device/list` with `{\"filter\": [], \"platform\": \"ewelink\"}` → list devices\n4. `device/specs` with `{\"deviceId\": \"xxx\"}` → get property definitions\n5. `ewelink/set_property` → control (e.g., `property: \"switch\"`, `value: \"on\"`)\n\n### Device Control Example\n\n```json\n{\n  \"name\": \"ewelink/set_property\",\n  \"arguments\": {\n    \"device_id\": \"DEVICE_ID\",\n    \"property\": \"switch\",\n    \"value\": \"on\"\n  }\n}\n```\n\n## License\n\n`ewelink/set_property` and `ewelink/execute_action` require a license. `ewelink/get_properties` works without license.\nActivate via `license/set` tool.\n\nFile v1.0.9:skills/extension.md\n\n---\nname: extension\ndescription: Hardware extension tools. Serial (RS485/UART), GPIO, Xiaozhi AI, license, config, stats.\nversion: 1.2.31\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n---\n\n# Hardware Extension & Integration Tools\n\n> **Parent skill:** [SKILL.md](../SKILL.md) — provides cross-platform tools and MCP endpoint config.\n\n## Serial Extension\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `serial/get_properties` | `device_id`, `siid`, `piids` | Property values |\n| `serial/set_property` | `device_id`, `siid`, `piid`, `value` | Set result |\n| `serial/execute_action` | `device_id`, `siid`, `aiid` | Action result |\n\n## GPIO Extension\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `gpio/get_properties` | `device_id`, `siid`, `piids` | Property values |\n| `gpio/set_property` | `device_id`, `siid`, `piid`, `value` | Set result |\n| `gpio/execute_action` | `device_id`, `siid`, `aiid` | Action result |\n\n## Xiaozhi AI Platform\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `xiaozhi/status` | — | Connection state |\n| `xiaozhi/set_endpoint` | `endpoint` | Set WebSocket URL |\n\n## System Tools\n\n### License\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `license/status` | — | `edition`, `status`, `guidance` |\n| `license/set` | `license_key`, `product` (opt) | Activation result |\n| `license/clear` | — | Clear result |\n\n### Configuration\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `config/get_vision` | — | Vision AI settings |\n| `config/set_vision` | `enabled`, `api_key`, `model`, etc. | Update result |\n| `config/get_trigger` | — | Trigger engine settings |\n| `config/set_trigger` | `enabled`, `interval_seconds`, etc. | Update result |\n\n### Statistics\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `stats/token_usage` | `days` (opt) | Token usage summary |\n| `stats/token_records` | `limit` (opt) | Recent records |\n| `stats/trigger_summary` | `days` (opt) | Trigger statistics |\n| `stats/dashboard` | — | Full dashboard data |\n\nFile v1.0.9:skills/midea.md\n\n---\nname: midea\ndescription: Midea platform tools. Account/password auth, read/write device properties (AC, appliances).\nversion: 1.2.31\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n---\n\n# Midea Platform Tools\n\n> **Parent skill:** [SKILL.md](../SKILL.md) — provides cross-platform tools (`device/list`, `device/specs`, `platform/status`) and MCP endpoint config.\n\n## Authorization\n\n### Account Login\n\nMidea uses account/password login via the Meiju (美居) app credentials.\n\n**Login:**\n\n```json\n{\n  \"name\": \"auth/midea_login\",\n  \"arguments\": {\n    \"account\": \"YOUR_PHONE_OR_EMAIL\",\n    \"password\": \"YOUR_PASSWORD\",\n    \"cloud\": \"meiju\"\n  }\n}\n```\n\n| Parameter | Required | Description |\n|-----------|----------|-------------|\n| `account` | Yes | Meiju app phone number or email |\n| `password` | Yes | Meiju app password |\n| `cloud` | No | Cloud type: `meiju` (美居, default) or `msmart` (MSmartHome) |\n\nReturns on success:\n```json\n{\n  \"success\": true,\n  \"auth_status\": {\n    \"authenticated\": true,\n    \"cloud\": \"meiju\",\n    \"home_group_id\": \"18503420\",\n    \"token_remaining_seconds\": 7200\n  },\n  \"device_count\": 0\n}\n```\n\nToken is valid for 7200 seconds (2 hours). Re-login when expired.\n\n**Refresh device list after login:**\n\n```json\n{\n  \"name\": \"midea/refresh\",\n  \"arguments\": {}\n}\n```\n\n### Other Auth Tools\n\n| Tool | Description |\n|------|-------------|\n| `midea/refresh` | Refresh device list from cloud |\n| `auth/midea_logout` | Clear Midea authorization |\n\n### Check Authorization Status\n\n```json\n{\n  \"name\": \"auth/platforms\",\n  \"arguments\": {}\n}\n```\n\nLook for the `midea` entry to verify `authenticated: true`.\n\n## Device Control\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `midea/get_properties` | `device_id` | Property values |\n| `midea/set_property` | `device_id`, `property`, `value` | Set result (**requires license**) |\n| `midea/execute_action` | `device_id`, `action` | Action result (**requires license**) |\n\n**Parameter convention:** Midea tools use `device_id` (snake_case).\nCross-platform tool `device/specs` uses `deviceId` (camelCase).\n\n**Common properties:**\n- `power`: `0` / `1` (off/on)\n- `temperature`: number (e.g., `26`)\n- `mode`: string (`cool`, `heat`, `auto`)\n- `fan_speed`: string (`low`, `medium`, `high`)\n\n**Workflow (steps 3-4 use parent skill tools):**\n1. `auth/midea_login` → login with account/password\n2. `midea/refresh` → refresh device list from cloud\n3. `device/list` with `{\"filter\": [], \"platform\": \"midea\"}` → list devices\n4. `device/specs` with `{\"deviceId\": \"xxx\"}` → get property/action definitions\n5. `midea/set_property` → control (e.g., `property: \"power\"`, `value: 1`)\n\n### Device Control Example\n\n```json\n{\n  \"name\": \"midea/set_property\",\n  \"arguments\": {\n    \"device_id\": \"DEVICE_ID\",\n    \"property\": \"power\",\n    \"value\": 1\n  }\n}\n```\n\n## License\n\n`midea/set_property` and `midea/execute_action` require a license. `midea/get_properties` works without license.\nActivate via `license/set` tool.\n\nFile v1.0.9:skills/tuya.md\n\n---\nname: tuya\ndescription: Tuya/Smart Life platform tools. QR code auth, device DP property read/write.\nversion: 1.2.31\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n---\n\n# Tuya Platform Tools\n\n> **Parent skill:** [SKILL.md](../SKILL.md) — provides cross-platform tools (`device/list`, `device/specs`, `platform/status`) and MCP endpoint config.\n\n## Authorization\n\n### QR Code Authorization Flow\n\nTuya uses QR code scanning for authorization via the Smart Life / Tuya app.\n\n**Step 1: Get user code**\n\nOpen the Smart Life (涂鸦智能) or Tuya app on your phone:\n- Go to **My (我的) → Settings (设置) → Account & Security (账号与安全)**\n- Find your **User Code (用户代码)**, e.g. `AxNmcp2`\n\n**Step 2: Generate QR code**\n\n```json\n{\n  \"name\": \"auth/tuya_qr\",\n  \"arguments\": { \"user_code\": \"YOUR_USER_CODE\" }\n}\n```\n\nReturns:\n```json\n{\n  \"success\": true,\n  \"qr_url\": \"tuyaSmart--qrLogin/?token=xxx\",\n  \"token\": \"xxx\",\n  \"expire_time\": 300\n}\n```\n\n**Step 3: Scan QR code**\n\nConvert `qr_url` to a QR code image and scan it with the Smart Life / Tuya app.\nConfirm the authorization on the app when prompted.\n\n**Step 4: Check scan status**\n\nPoll until authorized (within 5 minutes):\n```json\n{\n  \"name\": \"auth/tuya_qr_status\",\n  \"arguments\": {\n    \"token\": \"QR_TOKEN_FROM_STEP_2\",\n    \"user_code\": \"YOUR_USER_CODE\"\n  }\n}\n```\n\nReturns on success:\n```json\n{ \"success\": true, \"status\": \"success\" }\n```\n\nOther statuses: `\"error\"` (not scanned / expired), `\"scanned\"` (scanned but not confirmed).\n\n**Step 5: Refresh device list**\n\n```json\n{\n  \"name\": \"tuya/refresh\",\n  \"arguments\": {}\n}\n```\n\n### Other Auth Tools\n\n| Tool | Description |\n|------|-------------|\n| `auth/tuya_logout` | Clear Tuya authorization |\n| `auth/platforms` | Check auth status for all platforms |\n\n### Check Authorization Status\n\n```json\n{\n  \"name\": \"auth/platforms\",\n  \"arguments\": {}\n}\n```\n\nLook for the `tuya` entry to verify `authenticated: true`.\n\n## Device Control\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `tuya/get_properties` | `device_id`, `codes` (opt) | DP property values |\n| `tuya/set_property` | `device_id`, `code`, `value` | Set result (**requires license**) |\n| `tuya/refresh` | — | Refresh device list from cloud |\n\n**Parameter convention:** Tuya tools use `device_id` (snake_case).\nCross-platform tool `device/specs` uses `deviceId` (camelCase).\n\n**Workflow (steps 2-3 use parent skill tools):**\n1. `auth/tuya_qr` → authorize (first time only)\n2. `device/list` with `{\"filter\": [], \"platform\": \"tuya\"}` → list devices\n3. `device/specs` with `{\"deviceId\": \"xxx\"}` → get DP definitions (codes)\n4. `tuya/set_property` → control (e.g., `code: \"switch_1\"`, `value: true`)\n\n### Device Control Example\n\n```json\n{\n  \"name\": \"tuya/set_property\",\n  \"arguments\": {\n    \"device_id\": \"DEVICE_ID\",\n    \"code\": \"switch_1\",\n    \"value\": true\n  }\n}\n```\n\n## License\n\n`tuya/set_property` requires a license. `tuya/get_properties` works without license.\nActivate via `license/set` tool.\n\nFile v1.0.9:skills/xiaomi.md\n\n---\nname: feyagate-xiaomi\ndescription: Xiaomi/Mi Home platform tools. MIOT device control, OAuth auth, camera P2P, XiaoAI speaker TTS/music. Use when controlling Xiaomi devices, cameras, or XiaoAI speakers.\nversion: 1.2.31\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n---\n\n# Xiaomi Platform Tools\n\n> **Parent skill:** [SKILL.md](../SKILL.md) — provides cross-platform tools (`device/list`, `device/specs`, `platform/status`, `gateway/info`) and MCP endpoint config.\n\n## Device Control\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `xiaomi/get_properties` | `device_id` (string), `siid` (int/string), `piids` (int[]) | Property values |\n| `xiaomi/set_property` | `device_id` (string), `siid` (int/string), `piid` (int/string), `value` | Control result |\n| `xiaomi/execute_action` | `device_id` (string), `siid` (int/string), `aiid` (int/string), `params` (opt) | Action result |\n\n**Workflow (step 1-2 use parent skill tools):**\n1. `device/list` with `{\"filter\": [\"keyword\"], \"platform\": \"xiaomi\"}` → find target device\n2. `device/specs` with `{\"deviceId\": \"xxx\"}` → get `siid`/`piid`/`aiid` definitions\n3. `xiaomi/get_properties` → read current values\n4. `xiaomi/set_property` → set property value\n\n**`xiaomi/set_property` example:**\n```json\n{\n  \"name\": \"xiaomi/set_property\",\n  \"arguments\": {\"device_id\": \"1234567890\", \"siid\": \"2\", \"piid\": \"1\", \"value\": true}\n}\n```\n\n## Auth & Device Management (PC proxy extensions)\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `xiaomi/auth_status` | — | `authorized`, `remaining_seconds`, `cloud_server` |\n| `xiaomi/auth_url` | — | OAuth login URL |\n| `xiaomi/auth_callback` | `code` | Token exchange result |\n| `xiaomi/refresh` | — | Re-fetch devices from cloud |\n| `xiaomi/get_area_info` | — | `areas[]`, `total_areas` |\n| `xiaomi/get_device_classes` | — | `device_classes[]` with counts |\n| `xiaomi/get_devices` | `area_id`, `device_class` (opt) | `devices[]`, `count` |\n\n### OAuth Flow\n\n```bash\n# 1. Get OAuth URL\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/auth_url\",\"arguments\":{}}}'\n\n# 2. Open URL in browser → login → copy redirect URL → extract code\n\n# 3. Submit code\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/auth_callback\",\"arguments\":{\"code\":\"YOUR_CODE\"}}}'\n\n# 4. Verify\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"xiaomi/auth_status\",\"arguments\":{}}}'\n\n# Or use auth.py script\npython3 scripts/auth.py              # Interactive\npython3 scripts/auth.py --status     # Check status\n```\n\n## Camera Control (PC proxy extensions)\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `xiaomi/camera_list` | — | `cameras[]` with metadata |\n| `xiaomi/camera_status` | `camera_id` (opt) | Connection status, `buffered_frames` |\n| `xiaomi/camera_connect` | `camera_id` | Start P2P stream |\n| `xiaomi/camera_disconnect` | `camera_id` | Stop stream |\n| `xiaomi/camera_snapshot` | `camera_id`, `channel` (opt), `count` (opt) | `images[]` (base64 JPEG) |\n| `xiaomi/camera_vision_chat` | `camera_id`, `query` | AI vision analysis |\n\n**Camera workflow:**\n1. `xiaomi/camera_list` → discover cameras\n2. `xiaomi/camera_connect` → establish P2P connection (wait 3-5s)\n3. `xiaomi/camera_snapshot` → capture JPEG frames\n4. `xiaomi/camera_disconnect` → release connection when done\n\n## XiaoAI Speaker Control\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `xiaoai/tts` | `device_id`, `text` | TTS playback result |\n| `xiaoai/play_music` | `device_id`, `text` | Music playback result |\n| `xiaoai/control` | `device_id`, `command`, `silence` (opt) | Voice command result |\n\n```json\n{\"name\": \"xiaoai/control\", \"arguments\": {\"device_id\": \"xxx\", \"command\": \"打开客厅灯\", \"silence\": true}}\n```\n\nArchive v1.0.8: 62 files, 134654 bytes\n\nFiles: CLAUDE.md (5370b), config/camera_extra_info.yaml (1383b), docs/hermes-guide.md (6726b), docs/openclaw-guide.md (6763b), docs/zhihu_openclaw_feyagate.md (10894b), FeyaGate_HTTP_API.md (24768b), FeyaGate_MCP_API.md (45334b), feyagate_skill/__init__.py (398b), feyagate_skill/auth.py (4391b), feyagate_skill/cli.py (8279b), feyagate_skill/config.py (1547b), feyagate_skill/data/camera_extra_info.yaml (1383b), feyagate_skill/data/SKILL.md (7771b), feyagate_skill/data/skills/automation.md (2500b), feyagate_skill/data/skills/ewelink.md (3100b), feyagate_skill/data/skills/extension.md (2109b), feyagate_skill/data/skills/midea.md (3012b), feyagate_skill/data/skills/tuya.md (3015b), feyagate_skill/data/skills/xiaomi.md (4043b), feyagate_skill/installer.py (13713b), feyagate_skill/mcp.py (6721b), feyagate_skill/scheduled.py (6825b), feyagate_skill/service.py (9028b), feyagate_skill/snapshot.py (4306b), pyproject.toml (1646b), QUICKSTART.md (10471b), README.md (11767b), reference.md (10243b), scripts/auth.py (8008b), scripts/build.sh (392b), scripts/health_check.sh (1593b), scripts/install.ps1 (7340b), scripts/install.sh (7661b), scripts/publish.sh (1419b), scripts/scheduled_analysis.py (7126b), scripts/setup.sh (8519b), scripts/snapshot.py (5279b), scripts/start.sh (2447b), scripts/stop.sh (666b), scripts/upgrade.ps1 (17473b), scripts/upgrade.sh (18720b), scripts/verify.sh (2269b), skill-card.md (2542b), SKILL.md (7771b), skills/automation.md (2500b), skills/ewelink.md (3100b), skills/extension.md (2109b), skills/midea.md (3012b), skills/tuya.md (3015b), skills/xiaomi.md (4043b), tests/__init__.py (16b), tests/conftest.py (16b), tests/test_auth.py (3353b), tests/test_cli.py (12466b), tests/test_config.py (2841b), tests/test_init.py (1142b), tests/test_installer.py (11540b), tests/test_mcp.py (8978b), tests/test_scheduled.py (5984b), tests/test_service.py (9723b), tests/test_snapshot.py (5763b), _meta.json (127b)\n\nFile v1.0.8:feyagate_skill/data/SKILL.md\n\n---\nname: feyagate\ndescription: MCP smart home gateway for AI agents. Multi-platform IoT device control via MCP protocol.\nsub_skills:\n  - name: feyagate-xiaomi\n    file: skills/xiaomi.md\n    trigger: Xiaomi, Mi Home, MIOT, 小米, camera, P2P, XiaoAI, 小爱, TTS, speaker, 摄像头\n  - name: feyagate-tuya\n    file: skills/tuya.md\n    trigger: Tuya, Smart Life, 涂鸦, DP code, QR auth\n  - name: feyagate-midea\n    file: skills/midea.md\n    trigger: Midea, 美居, 美的, AC, air conditioner, 空调\n  - name: feyagate-ewelink\n    file: skills/ewelink.md\n    trigger: eWeLink, Sonoff, iTEAD, switch, relay\n  - name: feyagate-automation\n    file: skills/automation.md\n    trigger: schedule, timer, trigger, automation, room, memory, note, 定时, 自动化, 房间, 记忆\n  - name: feyagate-extension\n    file: skills/extension.md\n    trigger: serial, RS485, UART, GPIO, Xiaozhi, 小智, license, config, stats, 统计\n---\n\n# FeyaGate Skill — MCP Smart Home Gateway for AI Agents\n\nMCP-based multi-platform smart home gateway supporting Xiaomi, Tuya, Midea, eWeLink, Serial, and GPIO. Compatible with OpenClaw, Claude Code, Hermes, Codex, Windsurf, Copilot, 小智AI and other MCP-compatible AI agents.\n\n## Before Using Any Tool\n\nRun this check **before** calling any FeyaGate MCP tool:\n\n```bash\nfeyagate status\n```\n\n- If status is **RUNNING** → proceed with tool calls.\n- If status is **STOPPED** or command not found → run `feyagate start` first. If `feyagate` is not installed, run `pip install feyagate-skill && feyagate setup && feyagate start`.\n\n**Dual API endpoints:**\n\n| Endpoint | Protocol | URL |\n|----------|----------|-----|\n| MCP (PC proxy) | Streamable HTTP JSON-RPC 2.0 | `http://localhost:38080/mcp/http` |\n| MCP (ESP32 gateway) | WebSocket / Streamable HTTP | `ws://<gateway>:8765/mcp` / `http://<gateway>:8765/mcp/http` |\n| HTTP REST (ESP32 gateway) | REST API | `http://<gateway>:8080/api/v1/...` |\n\n> **Note:** The PC proxy (miloco-mcp-server) provides all gateway MCP tools plus additional extensions (camera P2P, Xiaomi auth, etc.).\n\n## Quick Start\n\n```bash\npip install feyagate-skill       # Step 1: Install Python package\nfeyagate setup                   # Step 2: Download MCP server binary (~30MB)\nfeyagate start                   #        Start service (localhost:38080)\nfeyagate install-claude          # Step 3: Register with your AI agent\nfeyagate auth                    # Step 4: Authorize smart home platform\n```\n\nOther agent install commands: `install-cursor`, `install-openclaw`, `install-hermes`, `install-codex`, `install-windsurf`, `install-copilot`\n\nFull step-by-step guide: [QUICKSTART.md](QUICKSTART.md)\n\n## Server Lifecycle (CLI)\n\n| Action | Command |\n|--------|---------|\n| Install binary | `feyagate setup [--dir PATH]` |\n| Start | `feyagate start [--port PORT]` |\n| Stop | `feyagate stop` |\n| Restart | `feyagate restart [--port PORT]` |\n| Status | `feyagate status` |\n| Logs | `feyagate log [-n 50]` |\n| Upgrade | `feyagate upgrade` |\n| Auth Xiaomi | `feyagate auth [--status] [--code CODE]` |\n\n### Manual Scripts (Advanced)\n\n| Action | macOS/Linux | Windows |\n|--------|-------------|---------|\n| Install | `bash scripts/install.sh` | `scripts\\install.ps1` |\n| Setup | `bash scripts/setup.sh` | `scripts\\setup.bat` |\n| Start | `bash scripts/start.sh` | `scripts\\start.bat` |\n| Stop | `bash scripts/stop.sh` | `scripts\\stop.bat` |\n| Verify | `bash scripts/verify.sh` | `scripts\\verify.bat` |\n| Status | `bash scripts/health_check.sh` | `scripts\\health_check.bat` |\n| Custom port | `bash scripts/start.sh --port 9090` | `scripts\\start.bat --port 9090` |\n| Upgrade | `bash scripts/upgrade.sh` | `powershell -File scripts\\upgrade.ps1` |\n| Check updates | `bash scripts/upgrade.sh --check` | `powershell -File scripts\\upgrade.ps1 -Check` |\n\n## Cross-Platform Tools\n\nUnified interfaces that work across all platforms. System auto-detects device platform.\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `device/list` | `filter` (string[]), `platform` (opt) | `devices[]` with `platform` field |\n| `device/specs` | `deviceId` (string) | Platform-specific spec: properties, actions |\n| `platform/status` | — | All platform connection/auth/sync status |\n| `gateway/info` | — | Version, device count, ports |\n| `scene/list` | `platform` (string) | `scenes[]` |\n| `scene/trigger` | `platform` (string), `sceneId` (string) | Trigger result |\n\n> **Parameter convention:** `device/specs` uses `deviceId` (camelCase); platform-specific tools (`xiaomi/*`, `tuya/*`, etc.) use `device_id` (snake_case).\n\n## Sub-Skill Loading Guide (for AI agents)\n\nThis skill uses a modular structure. The main skill defines cross-platform tools; platform-specific tools are in sub-skill files.\n\n**Loading strategy:**\n1. **Always load** this main SKILL.md first — it provides the core cross-platform tools and MCP endpoint info.\n2. **Load sub-skills on demand** based on the user's intent. Each sub-skill's `trigger` keywords (listed in frontmatter `sub_skills`) indicate when to load it.\n3. **Cross-platform workflow** (no sub-skill needed): `device/list` → `device/specs` → identify platform → load corresponding sub-skill for control operations.\n\n| Sub-Skill | File | When to Load | Covers |\n|-----------|------|-------------|--------|\n| **feyagate-xiaomi** | [skills/xiaomi.md](skills/xiaomi.md) | Xiaomi/Mi Home devices, cameras, XiaoAI speakers | MIOT device control, OAuth auth, camera P2P, XiaoAI TTS/music |\n| **feyagate-tuya** | [skills/tuya.md](skills/tuya.md) | Tuya/Smart Life devices | DP property read/write, QR code auth |\n| **feyagate-midea** | [skills/midea.md](skills/midea.md) | Midea/美的 appliances | AC/appliance control, account auth |\n| **feyagate-ewelink** | [skills/ewelink.md](skills/ewelink.md) | eWeLink/Sonoff devices | Switch control, multi-channel |\n| **feyagate-automation** | [skills/automation.md](skills/automation.md) | Scheduling, automation, rooms, memory | Schedule, trigger engine, room, memory, skill system |\n| **feyagate-extension** | [skills/extension.md](skills/extension.md) | Serial, GPIO, license, config | Serial, GPIO, Xiaozhi AI, license, config, stats |\n\n## License System\n\n- **Free edition**: Xiaomi platform only (device control, cameras, XiaoAI, MCP proxy)\n- **Licensed edition**: All platforms (Xiaomi + Tuya + Midea + eWeLink)\n- `tuya/set_property`, `midea/set_property`, `ewelink/set_property` return `license_required` on free edition\n- `get_properties` and all other tools work without license\n\n## Configuration\n\n`config/config.yaml`:\n\n```yaml\nserver:\n  http_port: 38080\n  ws_port: 8765\n  bind_address: \"0.0.0.0\"\nauth:\n  cloud_server: \"cn\"      # cn / de / sg / us / ru / i2\n  token_file: \"data/auth_token.json\"\ncamera:\n  frame_interval: 500\n  buffer_max_size: 20\n  buffer_ttl: 300\n  jpeg_quality: 90\ntuya:\n  token_file: \"data/tuya_token.json\"\nmidea:\n  token_file: \"data/midea_token.json\"\newelink:\n  token_file: \"data/ewelink_token.json\"\nxiaozhi:\n  endpoint: \"\"            # ws:// or wss:// (empty = disabled)\n```\n\n## Troubleshooting\n\n| Symptom | Fix |\n|---------|-----|\n| `command not found: feyagate` | `pip install feyagate-skill` |\n| `FeyaGate not installed` | `feyagate setup` |\n| `connection refused` | `feyagate start` |\n| `authorized: false` | `feyagate auth` (Xiaomi) or use platform-specific auth tool |\n| `cannot open shared object file` | `feyagate upgrade` or re-run `feyagate setup` |\n| `Tool not found` | Check tool name (see `tools/list` output) |\n| `key 'device_id' not found` | Platform tools use `device_id`; cross-platform `device/specs` uses `deviceId` |\n| `license_required` error | Set license key via `license/set` tool |\n\nFull API reference: [FeyaGate_MCP_API.md](FeyaGate_MCP_API.md), [FeyaGate_HTTP_API.md](FeyaGate_HTTP_API.md)\n\nFile v1.0.8:SKILL.md\n\n---\nname: feyagate\ndescription: MCP smart home gateway for AI agents. Multi-platform IoT device control via MCP protocol.\nsub_skills:\n  - name: feyagate-xiaomi\n    file: skills/xiaomi.md\n    trigger: Xiaomi, Mi Home, MIOT, 小米, camera, P2P, XiaoAI, 小爱, TTS, speaker, 摄像头\n  - name: feyagate-tuya\n    file: skills/tuya.md\n    trigger: Tuya, Smart Life, 涂鸦, DP code, QR auth\n  - name: feyagate-midea\n    file: skills/midea.md\n    trigger: Midea, 美居, 美的, AC, air conditioner, 空调\n  - name: feyagate-ewelink\n    file: skills/ewelink.md\n    trigger: eWeLink, Sonoff, iTEAD, switch, relay\n  - name: feyagate-automation\n    file: skills/automation.md\n    trigger: schedule, timer, trigger, automation, room, memory, note, 定时, 自动化, 房间, 记忆\n  - name: feyagate-extension\n    file: skills/extension.md\n    trigger: serial, RS485, UART, GPIO, Xiaozhi, 小智, license, config, stats, 统计\n---\n\n# FeyaGate Skill — MCP Smart Home Gateway for AI Agents\n\nMCP-based multi-platform smart home gateway supporting Xiaomi, Tuya, Midea, eWeLink, Serial, and GPIO. Compatible with OpenClaw, Claude Code, Hermes, Codex, Windsurf, Copilot, 小智AI and other MCP-compatible AI agents.\n\n## Before Using Any Tool\n\nRun this check **before** calling any FeyaGate MCP tool:\n\n```bash\nfeyagate status\n```\n\n- If status is **RUNNING** → proceed with tool calls.\n- If status is **STOPPED** or command not found → run `feyagate start` first. If `feyagate` is not installed, run `pip install feyagate-skill && feyagate setup && feyagate start`.\n\n**Dual API endpoints:**\n\n| Endpoint | Protocol | URL |\n|----------|----------|-----|\n| MCP (PC proxy) | Streamable HTTP JSON-RPC 2.0 | `http://localhost:38080/mcp/http` |\n| MCP (ESP32 gateway) | WebSocket / Streamable HTTP | `ws://<gateway>:8765/mcp` / `http://<gateway>:8765/mcp/http` |\n| HTTP REST (ESP32 gateway) | REST API | `http://<gateway>:8080/api/v1/...` |\n\n> **Note:** The PC proxy (miloco-mcp-server) provides all gateway MCP tools plus additional extensions (camera P2P, Xiaomi auth, etc.).\n\n## Quick Start\n\n```bash\npip install feyagate-skill       # Step 1: Install Python package\nfeyagate setup                   # Step 2: Download MCP server binary (~30MB)\nfeyagate start                   #        Start service (localhost:38080)\nfeyagate install-claude          # Step 3: Register with your AI agent\nfeyagate auth                    # Step 4: Authorize smart home platform\n```\n\nOther agent install commands: `install-cursor`, `install-openclaw`, `install-hermes`, `install-codex`, `install-windsurf`, `install-copilot`\n\nFull step-by-step guide: [QUICKSTART.md](QUICKSTART.md)\n\n## Server Lifecycle (CLI)\n\n| Action | Command |\n|--------|---------|\n| Install binary | `feyagate setup [--dir PATH]` |\n| Start | `feyagate start [--port PORT]` |\n| Stop | `feyagate stop` |\n| Restart | `feyagate restart [--port PORT]` |\n| Status | `feyagate status` |\n| Logs | `feyagate log [-n 50]` |\n| Upgrade | `feyagate upgrade` |\n| Auth Xiaomi | `feyagate auth [--status] [--code CODE]` |\n\n### Manual Scripts (Advanced)\n\n| Action | macOS/Linux | Windows |\n|--------|-------------|---------|\n| Install | `bash scripts/install.sh` | `scripts\\install.ps1` |\n| Setup | `bash scripts/setup.sh` | `scripts\\setup.bat` |\n| Start | `bash scripts/start.sh` | `scripts\\start.bat` |\n| Stop | `bash scripts/stop.sh` | `scripts\\stop.bat` |\n| Verify | `bash scripts/verify.sh` | `scripts\\verify.bat` |\n| Status | `bash scripts/health_check.sh` | `scripts\\health_check.bat` |\n| Custom port | `bash scripts/start.sh --port 9090` | `scripts\\start.bat --port 9090` |\n| Upgrade | `bash scripts/upgrade.sh` | `powershell -File scripts\\upgrade.ps1` |\n| Check updates | `bash scripts/upgrade.sh --check` | `powershell -File scripts\\upgrade.ps1 -Check` |\n\n## Cross-Platform Tools\n\nUnified interfaces that work across all platforms. System auto-detects device platform.\n\n| Tool | Arguments | Returns |\n|------|-----------|---------|\n| `device/list` | `filter` (string[]), `platform` (opt) | `devices[]` with `platform` field |\n| `device/specs` | `deviceId` (string) | Platform-specific spec: properties, actions |\n| `platform/status` | — | All platform connection/auth/sync status |\n| `gateway/info` | — | Version, device count, ports |\n| `scene/list` | `platform` (string) | `scenes[]` |\n| `scene/trigger` | `platform` (string), `sceneId` (string) | Trigger result |\n\n> **Parameter convention:** `device/specs` uses `deviceId` (camelCase); platform-specific tools (`xiaomi/*`, `tuya/*`, etc.) use `device_id` (snake_case).\n\n## Sub-Skill Loading Guide (for AI agents)\n\nThis skill uses a modular structure. The main skill defines cross-platform tools; platform-specific tools are in sub-skill files.\n\n**Loading strategy:**\n1. **Always load** this main SKILL.md first — it provides the core cross-platform tools and MCP endpoint info.\n2. **Load sub-skills on demand** based on the user's intent. Each sub-skill's `trigger` keywords (listed in frontmatter `sub_skills`) indicate when to load it.\n3. **Cross-platform workflow** (no sub-skill needed): `device/list` → `device/specs` → identify platform → load corresponding sub-skill for control operations.\n\n| Sub-Skill | File | When to Load | Covers |\n|-----------|------|-------------|--------|\n| **feyagate-xiaomi** | [skills/xiaomi.md](skills/xiaomi.md) | Xiaomi/Mi Home devices, cameras, XiaoAI speakers | MIOT device control, OAuth auth, camera P2P, XiaoAI TTS/music |\n| **feyagate-tuya** | [skills/tuya.md](skills/tuya.md) | Tuya/Smart Life devices | DP property read/write, QR code auth |\n| **feyagate-midea** | [skills/midea.md](skills/midea.md) | Midea/美的 appliances | AC/appliance control, account auth |\n| **feyagate-ewelink** | [skills/ewelink.md](skills/ewelink.md) | eWeLink/Sonoff devices | Switch control, multi-channel |\n| **feyagate-automation** | [skills/automation.md](skills/automation.md) | Scheduling, automation, rooms, memory | Schedule, trigger engine, room, memory, skill system |\n| **feyagate-extension** | [skills/extension.md](skills/extension.md) | Serial, GPIO, license, config | Serial, GPIO, Xiaozhi AI, license, config, stats |\n\n## License System\n\n- **Free edition**: Xiaomi platform only (device control, cameras, XiaoAI, MCP proxy)\n- **Licensed edition**: All platforms (Xiaomi + Tuya + Midea + eWeLink)\n- `tuya/set_property`, `midea/set_property`, `ewelink/set_property` return `license_required` on free edition\n- `get_properties` and all other tools work without license\n\n## Configuration\n\n`config/config.yaml`:\n\n```yaml\nserver:\n  http_port: 38080\n  ws_port: 8765\n  bind_address: \"0.0.0.0\"\nauth:\n  cloud_server: \"cn\"      # cn / de / sg / us / ru / i2\n  token_file: \"data/auth_token.json\"\ncamera:\n  frame_interval: 500\n  buffer_max_size: 20\n  buffer_ttl: 300\n  jpeg_quality: 90\ntuya:\n  token_file: \"data/tuya_token.json\"\nmidea:\n  token_file: \"data/midea_token.json\"\newelink:\n  token_file: \"data/ewelink_token.json\"\nxiaozhi:\n  endpoint: \"\"            # ws:// or wss:// (empty = disabled)\n```\n\n## Troubleshooting\n\n| Symptom | Fix |\n|---------|-----|\n| `command not found: feyagate` | `pip install feyagate-skill` |\n| `FeyaGate not installed` | `feyagate setup` |\n| `connection refused` | `feyagate start` |\n| `authorized: false` | `feyagate auth` (Xiaomi) or use platform-specific auth tool |\n| `cannot open shared object file` | `feyagate upgrade` or re-run `feyagate setup` |\n| `Tool not found` | Check tool name (see `tools/list` output) |\n| `key 'device_id' not found` | Platform tools use `device_id`; cross-platform `device/specs` uses `deviceId` |\n| `license_required` error | Set license key via `license/set` tool |\n\nFull API reference: [FeyaGate_MCP_API.md](FeyaGate_MCP_API.md), [FeyaGate_HTTP_API.md](FeyaGate_HTTP_API.md)\n\nFile v1.0.8:README.md\n\n![](images/1.png)\n\n# FeyaGate — MCP Smart Home Gateway for AI Agents\n\n[中文](#中文) | [English](#english)\n\n[![MCP](https://img.shields.io/badge/Protocol-MCP-blue)](https://modelcontextprotocol.io)\n[![PyPI](https://img.shields.io/badge/PyPI-feyagate--skill-blue)](#)\n[![AI Agents](https://img.shields.io/badge/AI_Agents-8-green)](#)\n[![IoT Platforms](https://img.shields.io/badge/IoT-Xiaomi%20%7C%20Tuya%20%7C%20Midea%20%7C%20eWeLink-orange)](#)\n\n> Let your AI coding assistant control smart home devices — lights, cameras, AC, speakers — directly through MCP protocol.\n\n**Website:** [www.feyagate.com](https://www.feyagate.com)\n\n---\n\n<a id=\"english\"></a>\n\n## Features\n\n- **Multi-platform IoT control** — Xiaomi/Mi Home, Tuya, Midea, eWeLink, Serial, GPIO\n- **Camera P2P streaming** — real-time snapshots, AI vision analysis\n- **Xiao AI speaker** — TTS, music playback, voice commands\n- **Automation** — scheduled tasks, trigger engine, room management\n- **Memory system** — persistent notes and long-term memory for AI agents\n- **8 AI agents supported** — Claude Code, Cursor, OpenClaw, Hermes, Codex, Windsurf, Copilot, 小智AI\n\n## Quick Start\n\n**Prerequisites:** Mac / Linux / Windows · Python 3.9+ · Terminal or PowerShell\n\n### Option 1 — One command (recommended)\n\nCopy the **entire line** below, paste into Terminal, press Enter, and wait a few minutes:\n\n**Mac / Linux** — open **Terminal** (Spotlight: type `Terminal`):\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.sh | bash\n```\n\n**Windows** — open **PowerShell**, paste and run:\n\n```powershell\niwr -useb https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.ps1 | iex\n```\n\n> No Python yet? Install from [python.org](https://www.python.org/downloads/) and check **Add Python to PATH** on Windows.\n\n> **Let AI do it for you?** Send this to Claude, Cursor, or any AI assistant:\n```bash\nPlease read https://github.com/toddpan/feyagate-skill/blob/main/QUICKSTART.md and follow the instructions to install and set up FeyaGate Skill on my machine.\n```\n### Option 2 — Install from PyPI (step by step)\n\n```bash\npip install feyagate-skill    # 1. Install the CLI tool\nfeyagate setup              # 2. Download the gateway binary (~30MB)\nfeyagate start              # 3. Start the service\nfeyagate install-cursor     # 4. Connect your AI assistant (pick one)\nfeyagate auth               # 5. Sign in to Mi Home\n```\n\n### Option 3 — Install from source (developers)\n\n```bash\ngit clone https://github.com/toddpan/feyagate-skill.git\ncd feyagate-skill\npip install -e \".[dev]\"     # Editable install with dev dependencies (pytest, etc.)\nfeyagate setup\nfeyagate start\nfeyagate install-cursor     # or install-claude, install-hermes, etc.\nfeyagate auth\n```\n\n### After install — connect your AI assistant\n\n| Your AI assistant | Run this command |\n|:------------------|:-----------------|\n| Cursor | `feyagate install-cursor` |\n| Claude Code | `feyagate install-claude` |\n| OpenClaw | `feyagate install-openclaw` |\n| Codex | `feyagate install-codex` |\n| Windsurf | `feyagate install-windsurf` |\n| Copilot (VS Code) | `feyagate install-copilot` |\n| Hermes | `feyagate install-hermes` |\n\nThen **restart your AI assistant** and try: *\"List my smart home devices.\"*\n\n- **Web dashboard:** [http://localhost:38080](http://localhost:38080)\n- **Stuck?** See [QUICKSTART.md](QUICKSTART.md) troubleshooting\n\n## CLI Commands\n\n| Action | Command |\n|:-------|:--------|\n| Install gateway | `feyagate setup` |\n| Start / stop | `feyagate start` · `feyagate stop` |\n| Restart | `feyagate restart` |\n| Status / logs | `feyagate status` · `feyagate log [-n 50]` |\n| Mi Home login | `feyagate auth` |\n| Camera snapshot | `feyagate snapshot --list` · `feyagate snapshot --camera-id ID --connect` |\n| Scheduled capture | `feyagate scheduled --camera-id ID --interval 300` |\n| Version | `feyagate --version` |\n| Upgrade | `feyagate upgrade` or `pip install --upgrade feyagate-skill` |\n\n## MCP Tools at a Glance\n\n| Category | Tools |\n|:---------|:------|\n| **Device Discovery** | `device/list` `device/specs` `platform/status` `gateway/info` |\n| **Xiaomi** | `xiaomi/get_properties` `xiaomi/set_property` `xiaomi/execute_action` |\n| **Xiao AI Speaker** | `xiaoai/tts` `xiaoai/play_music` `xiaoai/control` |\n| **Camera** | `xiaomi/camera_list` `xiaomi/camera_connect` `xiaomi/camera_snapshot` |\n| **Tuya / Midea / eWeLink** | Platform tools + `auth/*` login helpers |\n| **Scenes / Rooms / Schedule** | `scene/*` `room/*` `schedule/*` `trigger/*` |\n| **Memory** | `memory/read` `memory/add` `memory/search` |\n\n> Full API reference: [SKILL.md](SKILL.md) · [FeyaGate_MCP_API.md](FeyaGate_MCP_API.md) · [FeyaGate_HTTP_API.md](FeyaGate_HTTP_API.md)\n\n## How It Works\n\n```\n┌─────────────┐     MCP Protocol      ┌──────────────────┐     MIOT/DP/etc     ┌──────────┐\n│  AI Agent   │ ◄──────────────────► │  feyagate server  │ ◄──────────────────► │  IoT     │\n│ (Claude etc)│   localhost:38080     │  (miloco-mcp)     │                      │  Devices │\n└─────────────┘                       └──────────────────┘                      └──────────┘\n```\n\n## Development\n\n```bash\ngit clone https://github.com/toddpan/feyagate-skill.git\ncd feyagate-skill\npip install -e \".[dev]\"\npytest                        # run all tests\npytest tests/test_cli.py      # run single file\npytest tests/test_cli.py::TestClass::test_method  # run single test\nbash scripts/build.sh         # build PyPI package (outputs to dist/)\nbash scripts/publish.sh pypi  # publish to PyPI (requires PYPI_TOKEN env var)\n```\n\nTests use `pytest` with `unittest.mock`. Each module has a corresponding test file in `tests/` (e.g. `test_cli.py`, `test_service.py`, `test_installer.py`).\n\n## License\n\nMIT License\n\n---\n\n<a id=\"中文\"></a>\n\n## 功能特点\n\n- **多平台智能家居** — 小米/米家、涂鸦、美的、易微联、串口、GPIO\n- **摄像头** — 实时抓拍、AI 视觉分析\n- **小爱音箱** — 语音播报、放音乐、语音控制\n- **自动化** — 定时任务、触发器、房间管理\n- **记忆** — AI 可记住你的习惯和笔记\n- **支持 8 款 AI 助手** — Cursor、Claude Code、OpenClaw、Codex、Windsurf、Copilot、Hermes、小智AI\n\n## 快速开始\n\n**准备：** 一台 Mac / Linux / Windows 电脑 · 已安装 [Python 3.9+](https://www.python.org/downloads/) · 能打开「终端」或 PowerShell\n\n### 方式一：一条命令自动安装（推荐）\n\n**复制下面整行**，粘贴到终端里按回车，等几分钟即可：\n\n**Mac / Linux** — 打开「**终端**」（Mac 可按 `Command + 空格`，搜索「终端」）：\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.sh | bash\n```\n\n**Windows** — 打开 **PowerShell**，粘贴并运行：\n\n```powershell\niwr -useb https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.ps1 | iex\n```\n\n> 还没有 Python？到 [python.org](https://www.python.org/downloads/) 下载安装；Windows 安装时务必勾选 **Add Python to PATH**。\n\n> **想让 AI 帮你装？** 把下面这段话发给 Cursor、Claude 等 AI 助手：\n```bash\n请阅读 https://github.com/toddpan/feyagate-skill/blob/main/QUICKSTART.md 并按照指南在我的机器上安装和配置 FeyaGate Skill。\n```\n\n### 方式二：从 PyPI 安装（逐步执行）\n\n```bash\npip install feyagate-skill    # 1. 安装命令行工具\nfeyagate setup              # 2. 下载网关程序（约 30MB，需联网）\nfeyagate start              # 3. 启动服务\nfeyagate install-cursor     # 4. 接入 AI 助手（按下表选一个）\nfeyagate auth               # 5. 登录小米账号\n```\n\n### 方式三：从源码安装（开发者）\n\n```bash\ngit clone https://github.com/toddpan/feyagate-skill.git\ncd feyagate-skill\npip install -e \".[dev]\"     # 可编辑安装，含开发依赖（pytest 等），代码修改即时生效\nfeyagate setup\nfeyagate start\nfeyagate install-cursor     # 或 install-claude、install-hermes 等\nfeyagate auth\n```\n\n### 装好之后 — 让 AI 助手认识 FeyaGate\n\n| 你用的 AI 助手 | 运行这条命令 |\n|:---------------|:-------------|\n| Cursor | `feyagate install-cursor` |\n| Claude Code | `feyagate install-claude` |\n| OpenClaw | `feyagate install-openclaw` |\n| Codex | `feyagate install-codex` |\n| Windsurf | `feyagate install-windsurf` |\n| Copilot（VS Code） | `feyagate install-copilot` |\n| Hermes | `feyagate install-hermes` |\n\n完成后 **重启你的 AI 助手**，试着说：「列出我家的智能设备」。\n\n- **网页管理：** 浏览器打开 [http://localhost:38080](http://localhost:38080)\n- **遇到问题？** 查看 [QUICKSTART.md](QUICKSTART.md) 故障排除\n\n## 常用命令\n\n| 想做什么 | 命令 |\n|:---------|:-----|\n| 下载/更新网关程序 | `feyagate setup` |\n| 启动 / 停止 | `feyagate start` · `feyagate stop` |\n| 重启 | `feyagate restart` |\n| 查看状态 / 日志 | `feyagate status` · `feyagate log [-n 50]` |\n| 登录米家 | `feyagate auth` |\n| 摄像头抓拍 | `feyagate snapshot --list` · `feyagate snapshot --camera-id ID --connect` |\n| 定时抓拍分析 | `feyagate scheduled --camera-id ID --interval 300` |\n| 查看版本 | `feyagate --version` |\n| 升级 | `feyagate upgrade` 或 `pip install --upgrade feyagate-skill` |\n\n## MCP 工具一览\n\n| 类别 | 工具 |\n|:-----|:-----|\n| **查设备** | `device/list` `device/specs` `platform/status` `gateway/info` |\n| **小米控制** | `xiaomi/get_properties` `xiaomi/set_property` `xiaomi/execute_action` |\n| **小爱音箱** | `xiaoai/tts` `xiaoai/play_music` `xiaoai/control` |\n| **摄像头** | `xiaomi/camera_list` `xiaomi/camera_connect` `xiaomi/camera_snapshot` |\n| **涂鸦 / 美的 / 易微联** | 各平台控制 + `auth/*` 登录 |\n| **场景 / 房间 / 定时** | `scene/*` `room/*` `schedule/*` `trigger/*` |\n| **记忆** | `memory/read` `memory/add` `memory/search` |\n\n> 完整 API 文档：[SKILL.md](SKILL.md) · [FeyaGate_MCP_API.md](FeyaGate_MCP_API.md) · [FeyaGate_HTTP_API.md](FeyaGate_HTTP_API.md)\n\n\n## 工作原理\n\n```\n┌─────────────┐     MCP 协议       ┌──────────────────┐    各平台协议     ┌──────────┐\n│  AI 助手    │ ◄───────────────► │  FeyaGate 网关   │ ◄───────────────► │ 智能设备 │\n│ (Cursor 等) │  本机 38080 端口   │                  │                   │ 灯/空调等 │\n└─────────────┘                    └──────────────────┘                   └──────────┘\n```\n\n你对 AI 说「开灯」→ AI 调用 FeyaGate → 设备执行。\n\n## 开发\n\n```bash\ngit clone https://github.com/toddpan/feyagate-skill.git\ncd feyagate-skill\npip install -e \".[dev]\"\npytest                        # 运行所有测试\npytest tests/test_cli.py      # 运行单个文件\npytest tests/test_cli.py::TestClass::test_method  # 运行单个测试\nbash scripts/build.sh         # 打包（输出到 dist/）\nbash scripts/publish.sh pypi  # 发布到 PyPI（需设置 PYPI_TOKEN 环境变量）\n```\n\n测试使用 `pytest` + `unittest.mock`。`tests/` 下每个模块对应一个测试文件（如 `test_cli.py`、`test_service.py`、`test_installer.py`）。\n\n## 许可证\n\nMIT License\n\nFile v1.0.8:_meta.json\n\n{\n  \"ownerId\": \"kn70xdk1j9emqkf281q83fvzb1858rny\",\n  \"slug\": \"feyagate\",\n  \"version\": \"1.0.8\",\n  \"publishedAt\": 1779750930684\n}\n\nFile v1.0.8:CLAUDE.md\n\n# CLAUDE.md\n\nThis file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.\n\n## What this repo is\n\n`feyagate-skill` is a Python PyPI package that acts as a CLI installer and wrapper around a pre-built Go binary (`miloco-mcp-server`). The Python code handles download, install, start/stop, and AI agent integration. The actual MCP smart home logic lives in the binary, not in this repo. Python modules communicate with the Go binary exclusively via HTTP JSON-RPC calls through `mcp.py`.\n\n## Commands\n\n**Development install:**\n```bash\npip install -e \".[dev]\"\n```\n\n**Run tests:**\n```bash\npytest                          # all tests\npytest tests/test_cli.py        # single file\npytest tests/test_cli.py::TestClass::test_method  # single test\n```\n\n**Build package:**\n```bash\nbash scripts/build.sh           # produces dist/\n```\n\n**Publish to PyPI:**\n```bash\nPYPI_TOKEN=xxx bash scripts/publish.sh pypi       # production\nTEST_PYPI_TOKEN=xxx bash scripts/publish.sh testpypi  # staging\n```\n\n## Architecture\n\n```\nfeyagate_skill/\n  cli.py        # argparse entry point; routes subcommands to modules below\n  installer.py  # fetches fota.json from FOTA_URL, downloads binary archive, extracts to ~/.feyagate/\n  service.py    # start/stop/status of miloco-mcp-server binary via PID file\n  config.py     # loads ~/.feyagate/config/config.yaml (YAML, never raises)\n  auth.py       # Xiaomi/Mi Home OAuth flow via HTTP to running MCP server\n  mcp.py        # HTTP client for calling MCP server tools (sync + optional async via aiohttp)\n  snapshot.py   # camera snapshot via mcp.py\n  scheduled.py  # recurring camera capture loop\n  data/         # bundled files copied to ~/.feyagate on setup: SKILL.md, skills/*.md, config.yaml.example\n```\n\n**Runtime layout** (installed at `~/.feyagate/` by default):\n- `bin/miloco-mcp-server` — the actual MCP server binary\n- `config/config.yaml` — server config (HTTP port 38080, WS port 8765)\n- `data/miloco-mcp-server.pid` — PID file used by service.py\n- `data/miloco-mcp-server.log` — server log\n- `lib/` — shared libraries; symlinked into `bin/lib` for rpath\n\n**AI agent skill installation** (`feyagate install-<agent>`): creates a symlink from `~/<agent-dir>/skills/feyagate` → `~/.feyagate/`. This exposes `SKILL.md` and `skills/*.md` to the agent.\n\nAgent symlink targets per agent:\n- `install-claude` → `~/.claude/skills/feyagate`\n- `install-cursor` → `~/.cursor/skills/feyagate`\n- `install-openclaw` → `~/.openclaw/skills/feyagate`\n- `install-hermes` → `~/.hermes/skills/feyagate`\n- `install-windsurf` → `~/.codeium/windsurf/skills/feyagate`\n- `install-copilot` → platform-dependent VS Code dir + `/skills/feyagate`\n- `install-codex` → `~/.codex/skills/feyagate`\n\n## Key conventions\n\n- **Lazy imports in cli.py**: subcommand modules (`installer`, `service`, `auth`, etc.) are imported inside the `elif` branches, not at module top. This keeps CLI startup fast.\n- **config.py never raises**: `load_config()` returns `{}` on any error (missing file, YAML parse error, etc.). Callers can safely index the result without try/except.\n- **mcp.py dual interface**: `mcp_call()` is synchronous (stdlib `urllib`), `async_mcp_call()` uses `aiohttp` (optional dependency). Both target `POST /mcp/http` on the Go binary using JSON-RPC 2.0.\n- **service.py process lifecycle**: managed via a PID file (`miloco-mcp-server.pid`). Start spawns the binary with `subprocess.Popen`, stop sends SIGTERM then SIGKILL after 5s timeout.\n- **installer.py FOTA flow**: fetches `fota.json` → matches platform via `FOTA_TYPE_MAP` → downloads archive → verifies MD5 → extracts binary + libs + webui to `~/.feyagate/`.\n\n## Key constants\n\nAll in `feyagate_skill/__init__.py`:\n- `DEFAULT_INSTALL_DIR = \"~/.feyagate\"`\n- `FOTA_URL` — FOTA server endpoint for binary release metadata\n- `MCP_DEFAULT_PORT = 38080`\n- `MCP_DEFAULT_HOST = \"127.0.0.1\"`\n\n## Version management\n\nThe version string exists in **two places** and must be kept in sync manually:\n1. `feyagate_skill/__init__.py` — `__version__`\n2. `pyproject.toml` — `version`\n\nBump both before building and publishing.\n\n## MCP server endpoints\n\nWhen running, `miloco-mcp-server` exposes:\n- `GET /health` — health check (used by `service.py` startup wait loop)\n- `POST /mcp/http` — MCP tool calls (JSON-RPC 2.0)\n- `GET /` — WebUI dashboard\n\n## Testing patterns\n\nTests use `pytest` with `unittest.mock`. Key patterns:\n- Filesystem-dependent tests use `tmp_path` fixture and monkeypatch `DEFAULT_INSTALL_DIR` and `Path.home()`.\n- Tests that invoke CLI subcommands patch the corresponding `_install_*` function and check it was called, or patch `sys.argv` and call `main()`.\n- No integration tests that hit a real MCP server — all MCP calls are mocked or skipped.\n\n## Gotchas\n\n- `feyagate upgrade` is an alias for `feyagate setup` — both call `installer.do_setup()`.\n- `--port` on `start`/`restart` only affects the health-check URL used during startup. The binary always reads its actual listening port from `config.yaml`. To change the port, edit `~/.feyagate/config/config.yaml`.\n- The `scripts/` directory contains both build/publish shell scripts (`build.sh`, `publish.sh`) and standalone Python utility scripts (`snapshot.py`, `auth.py`, `scheduled_analysis.py`) that are not part of the package — they are developer tools.\n\nFile v1.0.8:docs/hermes-guide.md\n\n# FeyaGate + Hermes 小白安装配置教程\n\n> 从零开始，让 Hermes AI 助手控制你的智能家居设备。\n\n## 你需要准备什么\n\n| 准备项 | 说明 |\n|:-------|:-----|\n| 电脑 | Mac、Linux 或 Windows 都行 |\n| Python | 版本 3.9 或更高（[下载地址](https://www.python.org/downloads/)） |\n| Hermes | 已安装 Hermes Agent（[官网](https://hermes.ai)） |\n| 智能设备 | 至少一个已绑定米家/涂鸦/美的/易微联的设备 |\n| 网络 | 电脑能联网（安装时需要下载约 30MB 的网关程序） |\n\n---\n\n## 第一步：安装 FeyaGate Skill\n\n打开终端（Mac 按 `Command + 空格`，搜索「终端」；Windows 打开 PowerShell）。\n\n### 方式 A：一条命令搞定（推荐）\n\n**Mac / Linux：**\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.sh | bash\n```\n\n**Windows（PowerShell）：**\n\n```powershell\niwr -useb https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.ps1 | iex\n```\n\n运行后等待 1-2 分钟，看到 `Setup complete` 就说明安装成功了。安装完跳到**第三步**。\n\n### 方式 B：手动一步步来\n\n如果一条命令没成功，或者你想了解每一步在做什么：\n\n```bash\n# 1. 安装 Python 包\npip install feyagate-skill\n\n# 2. 验证安装成功\nfeyagate --version\n```\n\n看到版本号输出就说明装好了。如果提示 `command not found`，试试：\n- Mac/Linux：关闭终端重新打开\n- Windows：重启 PowerShell\n- 或者用 `python -m feyagate_skill.cli --version`\n\n---\n\n## 第二步：下载网关并启动服务\n\n```bash\n# 下载 MCP 网关程序（约 30MB，需联网）\nfeyagate setup\n\n# 启动服务\nfeyagate start\n\n# 确认服务正在运行\nfeyagate status\n```\n\n看到类似下面的输出就说明成功了：\n\n```\nFeyaGate is running (PID: 12345)\nService URL: http://localhost:38080\n```\n\n如果提示 `not running`，检查：\n- 再跑一次 `feyagate start`\n- 看日志找原因：`feyagate log -n 20`\n\n---\n\n## 第三步：将 FeyaGate 接入 Hermes\n\n这是关键一步——让 Hermes 能发现并使用 FeyaGate 的智能家居控制能力。\n\n```bash\nfeyagate install-hermes\n```\n\n成功后会输出：\n\n```\nFeyaGate skill installed for Hermes Agent.\nPlease restart Hermes Agent to load the skill.\n```\n\n这条命令做了什么：在 `~/.hermes/skills/` 下创建了一个名为 `feyagate` 的快捷方式，指向 `~/.feyagate/`。Hermes 启动时会自动读取里面的技能描述文件。\n\n**重要：装完后必须重启 Hermes，技能才会生效。**\n\n---\n\n## 第四步：登录智能家居平台\n\nFeyaGate 需要你的账号授权才能控制设备。根据你用的平台选择：\n\n### 小米 / 米家（最常用）\n\n```bash\nfeyagate auth\n```\n\n终端会输出一个网址，类似：\n\n```\nPlease open this URL in your browser:\nhttps://account.xiaomi.com/oauth2/authorize?...\n```\n\n操作步骤：\n1. 复制这个网址，粘贴到浏览器打开\n2. 用你的小米账号登录\n3. 登录成功后，浏览器地址栏会变成一个新的网址（以 `http://localhost` 开头）\n4. 把这个新网址完整复制，粘贴回终端按回车\n\n看到 `Authorization successful` 就大功告成了。\n\n验证登录状态：\n\n```bash\nfeyagate auth --status\n```\n\n### 涂鸦 / 美的 / 易微联\n\n这些平台需要通过 Hermes 对话来完成授权（因为流程稍复杂）。等第五步验证 Hermes 能用后，对 Hermes 说：\n\n- 涂鸦：「帮我登录涂鸦平台」\n- 美的：「帮我登录美的平台」\n- 易微联：「帮我登录易微联平台」\n\nHermes 会引导你完成。\n\n---\n\n## 第五步：验证一切正常\n\n重启 Hermes 后，试着对它说：\n\n> 「列出我的智能设备」\n\n如果一切正常，Hermes 会返回你账号下绑定的设备列表，包括设备名称、类型、房间等信息。\n\n### 更多你可以试的指令\n\n| 你说的话 | Hermes 会做什么 |\n|:---------|:---------------|\n| 列出我的智能设备 | 调用 `device/list` 显示所有设备 |\n| 打开客厅的灯 | 找到设备并调用 `xiaomi/set_property` |\n| 把空调温度设为 26 度 | 读取设备规格并设置属性 |\n| 用小爱音箱播放音乐 | 调用 `xiaoai/play_music` |\n| 小爱播报\"该吃饭了\" | 调用 `xiaoai/tts` |\n| 抓拍一下摄像头画面 | 调用 camera 相关工具 |\n| 创建一个定时任务，每天早上 7 点开灯 | 调用 `schedule/*` 工具 |\n\n---\n\n## 日常管理命令\n\n装好之后，这些命令会经常用到：\n\n```bash\nfeyagate status       # 看服务是否在跑\nfeyagate stop         # 停止服务\nfeyagate start        # 启动服务\nfeyagate restart      # 重启服务\nfeyagate log -n 30    # 查看最近 30 行日志\nfeyagate upgrade      # 升级到最新版本\n```\n\n网页管理界面：浏览器打开 http://localhost:38080\n\n---\n\n## 常见问题\n\n### Q：`command not found: feyagate`\n\nPython 的 scripts 目录不在系统 PATH 里。解决：\n\n```bash\n# Mac/Linux 试试\npython3 -m pip install feyagate-skill\n# 然后用完整路径\n~/.local/bin/feyagate --version\n\n# 或者把路径加到 PATH\necho 'export PATH=\"$HOME/.local/bin:$PATH\"' >> ~/.zshrc\nsource ~/.zshrc\n```\n\nWindows 的话确保安装 Python 时勾选了「Add Python to PATH」。\n\n### Q：`feyagate start` 后提示 not running\n\n```bash\n# 看日志\nfeyagate log -n 20\n\n# 常见原因：端口被占用\nlsof -i :38080        # Mac/Linux\nnetstat -ano | findstr 38080  # Windows\n```\n\n### Q：Hermes 重启后说不认识 FeyaGate 的命令\n\n确认 symlink 存在：\n\n```bash\nls -la ~/.hermes/skills/feyagate\n```\n\n应该看到箭头指向 `~/.feyagate`。如果不存在，重新跑：\n\n```bash\nfeyagate install-hermes\n```\n\n### Q：设备列表为空\n\n- 确认已完成授权：`feyagate auth --status`\n- 确认账号下确实绑定了设备（打开米家 App 检查）\n- 重启服务试试：`feyagate restart`\n\n### Q：能列出设备，但控制失败\n\n- 设备需要在线（检查 App 里设备状态）\n- 设备和电脑需要在同一局域网（部分局域网设备）\n- 查看日志定位错误：`feyagate log -n 50`\n\n---\n\n## 整体流程回顾\n\n```\n安装 Python 包          下载网关程序           启动服务\npip install ...    →   feyagate setup    →   feyagate start\n                                                   ↓\n   对 Hermes 说         重启 Hermes          接入 Hermes\n  \"列出我的设备\"   ←   restart Hermes   ←   feyagate install-hermes\n                                                   ↓\n                                            登录智能家居平台\n                                            feyagate auth\n```\n\n全部完成后，你就可以通过和 Hermes 对话来控制家里的智能设备了。\n\nFile v1.0.8:docs/openclaw-guide.md\n\n# FeyaGate + OpenClaw 小白安装配置教程\n\n> 从零开始，让 OpenClaw AI 助手控制你的智能家居设备。\n\n## 你需要准备什么\n\n| 准备项 | 说明 |\n|:-------|:-----|\n| 电脑 | Mac、Linux 或 Windows 都行 |\n| Python | 版本 3.9 或更高（[下载地址](https://www.python.org/downloads/)） |\n| OpenClaw | 已安装 OpenClaw（[官网](https://openclaw.ai)） |\n| 智能设备 | 至少一个已绑定米家/涂鸦/美的/易微联的设备 |\n| 网络 | 电脑能联网（安装时需要下载约 30MB 的网关程序） |\n\n---\n\n## 第一步：安装 FeyaGate Skill\n\n打开终端（Mac 按 `Command + 空格`，搜索「终端」；Windows 打开 PowerShell）。\n\n### 方式 A：一条命令搞定（推荐）\n\n**Mac / Linux：**\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.sh | bash\n```\n\n**Windows（PowerShell）：**\n\n```powershell\niwr -useb https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.ps1 | iex\n```\n\n运行后等待 1-2 分钟，看到 `Setup complete` 就说明安装成功了。安装完跳到**第三步**。\n\n### 方式 B：手动一步步来\n\n如果一条命令没成功，或者你想了解每一步在做什么：\n\n```bash\n# 1. 安装 Python 包\npip install feyagate-skill\n\n# 2. 验证安装成功\nfeyagate --version\n```\n\n看到版本号输出就说明装好了。如果提示 `command not found`，试试：\n- Mac/Linux：关闭终端重新打开\n- Windows：重启 PowerShell\n- 或者用 `python -m feyagate_skill.cli --version`\n\n---\n\n## 第二步：下载网关并启动服务\n\n```bash\n# 下载 MCP 网关程序（约 30MB，需联网）\nfeyagate setup\n\n# 启动服务\nfeyagate start\n\n# 确认服务正在运行\nfeyagate status\n```\n\n看到类似下面的输出就说明成功了：\n\n```\nFeyaGate is running (PID: 12345)\nService URL: http://localhost:38080\n```\n\n如果提示 `not running`，检查：\n- 再跑一次 `feyagate start`\n- 看日志找原因：`feyagate log -n 20`\n\n---\n\n## 第三步：将 FeyaGate 接入 OpenClaw\n\n这是关键一步——让 OpenClaw 能发现并使用 FeyaGate 的智能家居控制能力。\n\n```bash\nfeyagate install-openclaw\n```\n\n成功后会输出：\n\n```\nFeyaGate skill installed for OpenClaw.\nPlease restart OpenClaw to load the skill.\n```\n\n这条命令做了什么：在 `~/.openclaw/skills/` 下创建了一个名为 `feyagate` 的快捷方式，指向 `~/.feyagate/`。OpenClaw 启动时会自动读取里面的技能描述文件。\n\n**重要：装完后必须重启 OpenClaw，技能才会生效。**\n\n---\n\n## 第四步：登录智能家居平台\n\nFeyaGate 需要你的账号授权才能控制设备。根据你用的平台选择：\n\n### 小米 / 米家（最常用）\n\n```bash\nfeyagate auth\n```\n\n终端会输出一个网址，类似：\n\n```\nPlease open this URL in your browser:\nhttps://account.xiaomi.com/oauth2/authorize?...\n```\n\n操作步骤：\n1. 复制这个网址，粘贴到浏览器打开\n2. 用你的小米账号登录\n3. 登录成功后，浏览器地址栏会变成一个新的网址（以 `http://localhost` 开头）\n4. 把这个新网址完整复制，粘贴回终端按回车\n\n看到 `Authorization successful` 就大功告成了。\n\n验证登录状态：\n\n```bash\nfeyagate auth --status\n```\n\n### 涂鸦 / 美的 / 易微联\n\n这些平台需要通过 OpenClaw 对话来完成授权（因为流程稍复杂）。等第五步验证 OpenClaw 能用后，对 OpenClaw 说：\n\n- 涂鸦：「帮我登录涂鸦平台」\n- 美的：「帮我登录美的平台」\n- 易微联：「帮我登录易微联平台」\n\nOpenClaw 会引导你完成。\n\n---\n\n## 第五步：验证一切正常\n\n重启 OpenClaw 后，试着对它说：\n\n> 「列出我的智能设备」\n\n如果一切正常，OpenClaw 会返回你账号下绑定的设备列表，包括设备名称、类型、房间等信息。\n\n### 更多你可以试的指令\n\n| 你说的话 | OpenClaw 会做什么 |\n|:---------|:-----------------|\n| 列出我的智能设备 | 调用 `device/list` 显示所有设备 |\n| 打开客厅的灯 | 找到设备并调用 `xiaomi/set_property` |\n| 把空调温度设为 26 度 | 读取设备规格并设置属性 |\n| 用小爱音箱播放音乐 | 调用 `xiaoai/play_music` |\n| 小爱播报\"该吃饭了\" | 调用 `xiaoai/tts` |\n| 抓拍一下摄像头画面 | 调用 camera 相关工具 |\n| 创建一个定时任务，每天早上 7 点开灯 | 调用 `schedule/*` 工具 |\n\n---\n\n## 日常管理命令\n\n装好之后，这些命令会经常用到：\n\n```bash\nfeyagate status       # 看服务是否在跑\nfeyagate stop         # 停止服务\nfeyagate start        # 启动服务\nfeyagate restart      # 重启服务\nfeyagate log -n 30    # 查看最近 30 行日志\nfeyagate upgrade      # 升级到最新版本\n```\n\n网页管理界面：浏览器打开 http://localhost:38080\n\n---\n\n## 常见问题\n\n### Q：`command not found: feyagate`\n\nPython 的 scripts 目录不在系统 PATH 里。解决：\n\n```bash\n# Mac/Linux 试试\npython3 -m pip install feyagate-skill\n# 然后用完整路径\n~/.local/bin/feyagate --version\n\n# 或者把路径加到 PATH\necho 'export PATH=\"$HOME/.local/bin:$PATH\"' >> ~/.zshrc\nsource ~/.zshrc\n```\n\nWindows 的话确保安装 Python 时勾选了「Add Python to PATH」。\n\n### Q：`feyagate start` 后提示 not running\n\n```bash\n# 看日志\nfeyagate log -n 20\n\n# 常见原因：端口被占用\nlsof -i :38080        # Mac/Linux\nnetstat -ano | findstr 38080  # Windows\n```\n\n### Q：OpenClaw 重启后说不认识 FeyaGate 的命令\n\n确认 symlink 存在：\n\n```bash\nls -la ~/.openclaw/skills/feyagate\n```\n\n应该看到箭头指向 `~/.feyagate`。如果不存在，重新跑：\n\n```bash\nfeyagate install-openclaw\n```\n\n### Q：设备列表为空\n\n- 确认已完成授权：`feyagate auth --status`\n- 确认账号下确实绑定了设备（打开米家 App 检查）\n- 重启服务试试：`feyagate restart`\n\n### Q：能列出设备，但控制失败\n\n- 设备需要在线（检查 App 里设备状态）\n- 设备和电脑需要在同一局域网（部分局域网设备）\n- 查看日志定位错误：`feyagate log -n 50`\n\n---\n\n## 整体流程回顾\n\n```\n安装 Python 包          下载网关程序           启动服务\npip install ...    →   feyagate setup    →   feyagate start\n                                                   ↓\n  对 OpenClaw 说        重启 OpenClaw         接入 OpenClaw\n \"列出我的设备\"   ←   restart OpenClaw  ←   feyagate install-openclaw\n                                                   ↓\n                                            登录智能家居平台\n                                            feyagate auth\n```\n\n全部完成后，你就可以通过和 OpenClaw 对话来控制家里的智能设备了。\n\nFile v1.0.8:docs/zhihu_openclaw_feyagate.md\n\n# 用 OpenClaw + FeyaGate 让 AI 助手直接控制你的米家、涂鸦智能家居\n\n> 写代码写到一半，突然想开个灯？对 AI 说一句「把客厅灯打开」就行了。\n\n---\n\n## 什么是 FeyaGate？\n\n[FeyaGate](https://www.feyagate.com) 是一个基于 MCP（Model Context Protocol）协议的智能家居网关。它做了一件很简单但很酷的事情：**让你的 AI 编程助手（OpenClaw、Claude Code、Cursor 等）能直接控制你家里的智能设备**。\n\n支持的平台：\n\n| 平台 | 设备类型 |\n|------|---------|\n| **小米/米家** | 灯、空调、扫地机、摄像头、小爱音箱… |\n| **涂鸦（Tuya）** | 开关、插座、传感器、灯具… |\n| **美的（Midea）** | 空调、全屋家电… |\n| **易微联（eWeLink）** | Sonoff 开关、继电器… |\n| **串口/GPIO** | RS485、UART、树莓派 GPIO… |\n\n架构非常清晰：\n\n```\n┌─────────────┐     MCP 协议       ┌──────────────────┐    各平台协议     ┌──────────┐\n│  OpenClaw   │ ◄───────────────► │  FeyaGate 网关   │ ◄───────────────► │ 智能设备 │\n│  (AI 助手)  │  本机 38080 端口   │  (Go 二进制)     │                   │ 灯/空调等 │\n└─────────────┘                    └──────────────────┘                   └──────────┘\n```\n\n你对 AI 说「开灯」→ AI 调用 FeyaGate MCP 工具 → 设备执行。整个过程不需要你写任何代码。\n\n---\n\n## 为什么选择 OpenClaw？\n\nOpenClaw 是一款支持 MCP 协议的 AI 编程助手。它能读取项目里的 Skill 文件，自动发现并调用 FeyaGate 提供的 76 个智能家居工具。\n\n和其他 AI 助手（Claude Code、Cursor 等）相比，OpenClaw 的优势在于它是开源的，社区活跃，且对 MCP 工具的调用非常自然——你只需要用自然语言描述你想要什么，它就会自动选择合适的工具。\n\n---\n\n## 安装教程（5 分钟搞定）\n\n### 前置条件\n\n- Mac / Linux / Windows 任意系统\n- Python 3.9+（[下载地址](https://www.python.org/downloads/)）\n- 已安装 OpenClaw\n\n### 第一步：一条命令安装 FeyaGate\n\n打开终端，复制粘贴下面这整行命令：\n\n**Mac / Linux：**\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.sh | bash\n```\n\n**Windows（PowerShell）：**\n\n```powershell\niwr -useb https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.ps1 | iex\n```\n\n这条命令会自动完成三件事：\n1. 安装 `feyagate` 命令行工具（从 PyPI 下载）\n2. 下载智能家居网关程序（约 30MB）\n3. 启动后台服务（监听 `localhost:38080`）\n\n安装完成后你会看到类似这样的输出：\n\n```\n  ✓ 安装完成！\n```\n\n### 第二步：把 FeyaGate 接入 OpenClaw\n\n运行这条命令：\n\n```bash\nfeyagate install-openclaw\n```\n\n这条命令会在 `~/.openclaw/skills/feyagate` 创建一个符号链接，指向 FeyaGate 的 Skill 文件。OpenClaw 启动后会自动读取这些 Skill，知道怎么调用智能家居工具。\n\n> **重要：** 运行完这条命令后，需要**重启 OpenClaw**，Skill 才会生效。\n\n### 第三步：登录你的智能设备平台\n\n#### 小米/米家（最常用）\n\n```bash\nfeyagate auth\n```\n\n运行后会弹出一个小米 OAuth 授权页面，在浏览器中登录你的小米账号，授权完成后把回调 URL 粘贴回终端即可。\n\n#### 涂鸦（Tuya）\n\n需要先在涂鸦智能 App 中找到你的 User Code：**我的 → 设置 → 账号与安全 → 用户码**，然后运行：\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"jsonrpc\":\"2.0\",\n    \"id\":1,\n    \"method\":\"tools/call\",\n    \"params\":{\n      \"name\":\"auth/tuya_qr\",\n      \"arguments\":{\"user_code\":\"你的用户码\"}\n    }\n  }' | python3 -m json.tool\n```\n\n返回的 `qr_url` 用涂鸦智能 App 扫码即可完成授权。\n\n#### 美的（Midea）\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"jsonrpc\":\"2.0\",\n    \"id\":1,\n    \"method\":\"tools/call\",\n    \"params\":{\n      \"name\":\"auth/midea_login\",\n      \"arguments\":{\"account\":\"手机号或邮箱\", \"password\":\"密码\"}\n    }\n  }' | python3 -m json.tool\n```\n\n#### 易微联（eWeLink）\n\n```bash\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"jsonrpc\":\"2.0\",\n    \"id\":1,\n    \"method\":\"tools/call\",\n    \"params\":{\n      \"name\":\"auth/ewelink_login\",\n      \"arguments\":{\"email\":\"邮箱\", \"password\":\"密码\", \"country_code\":\"+86\"}\n    }\n  }' | python3 -m json.tool\n```\n\n### 第四步：验证一切正常\n\n```bash\nfeyagate status\n```\n\n看到 `RUNNING` 就说明网关已经在运行了。\n\n也可以打开浏览器访问 **http://localhost:38080** 查看 Web 管理面板。\n\n---\n\n## 实际使用：让 AI 帮你操控智能家居\n\n装好之后，打开 OpenClaw，直接用自然语言对话就行。\n\n### 场景 1：列出家中所有设备\n\n你对 OpenClaw 说：\n\n> 「帮我列出家里所有的智能设备」\n\nOpenClaw 会调用 `device/list` 工具，返回所有设备的名称、型号、平台、在线状态：\n\n```\n找到 23 个设备：\n- 客厅灯（小米，yeelink.light.lamp1）在线\n- 主卧空调（小米，chuangmi.aircondition.v1）在线\n- 浴室插座（涂鸦，智能插座）在线\n- 书房台灯（易微联，Sonoff B05）在线\n...\n```\n\n### 场景 2：开灯/关灯\n\n> 「把客厅灯打开」\n\nOpenClaw 会先调用 `device/specs` 查询设备规格，找到对应的 `siid` 和 `piid`，然后调用 `xiaomi/set_property` 执行操作：\n\n```\n已将「客厅灯」打开 ✓\n```\n\n### 场景 3：调节空调温度\n\n> 「把主卧空调调到 26 度，制冷模式」\n\nOpenClaw 自动执行：\n1. 查询设备规格 → 找到温度属性（siid=2, piid=5）和模式属性（siid=2, piid=3）\n2. 设置温度为 26\n3. 设置模式为制冷\n\n```\n已将「主卧空调」温度设为 26°C，模式设为制冷 ✓\n```\n\n### 场景 4：跨平台控制\n\n> 「把所有灯都关了」\n\nFeyaGate 会自动识别每个灯属于哪个平台，调用对应的工具：\n\n```\n已关闭 5 盏灯：\n- 小米：客厅灯 ✓\n- 小米：卧室灯 ✓\n- 涂鸦：厨房灯 ✓\n- 易微联：书房台灯 ✓\n- 小米：阳台灯 ✓\n```\n\n### 场景 5：摄像头抓拍 + AI 分析\n\n> 「帮我看看客厅摄像头现在拍到了什么」\n\nOpenClaw 会依次调用：\n1. `xiaomi/camera_connect` — 建立 P2P 连接\n2. `xiaomi/camera_snapshot` — 抓拍一张图片\n3. 将图片交给视觉模型分析\n\n```\n客厅摄像头当前画面：\n- 画面中有 1 人坐在沙发上\n- 客厅灯已打开\n- 电视正在播放\n- 室温约 25°C\n```\n\n### 场景 6：让小爱音箱说话\n\n> 「让小爱音箱说：欢迎回家」\n\n```\n已通过小爱音箱播报：「欢迎回家」 ✓\n```\n\n还可以播放音乐：「让小爱放一首周杰伦的歌」，或者语音控制：「让小爱把客厅灯打开」。\n\n### 场景 7：设置定时任务\n\n> 「每天晚上 10 点帮我关掉客厅灯」\n\nOpenClaw 会调用 `schedule/add` 创建一个定时任务：\n\n```\n已创建定时任务：每天 22:00 关闭客厅灯 ✓\n```\n\n---\n\n## 进阶玩法\n\n### 查看设备详细规格\n\n不确定某个设备支持哪些操作？让 AI 帮你查：\n\n> 「空调支持哪些功能？」\n\nOpenClaw 调用 `device/specs` 返回完整的 MIOT 规格，包括所有属性（温度、模式、风速等）和动作（开机、关机等）。\n\n### 触发场景\n\n> 「帮我执行离家模式」\n\n```\n已触发「离家模式」场景 ✓\n（关闭所有灯、关闭空调、打开扫地机）\n```\n\n### 摄像头持续监控\n\n通过 CLI 命令可以设置定时抓拍分析：\n\n```bash\nfeyagate scheduled --camera-id CAMERA_DID --interval 300\n```\n\n每 5 分钟自动抓拍一次，配合视觉 AI 进行分析。\n\n### Web 管理面板\n\n浏览器打开 **http://localhost:38080**，可以：\n- 查看所有设备列表和在线状态\n- 查看各平台授权状态\n- 查看网关版本信息\n- 管理配置\n\n---\n\n## 常见问题\n\n**Q：安装时报错 `command not found: feyagate`**\n\n确保 Python 3.9+ 已安装，并且 `pip` 在 PATH 中。运行 `python3 --version` 检查。\n\n**Q：`feyagate status` 显示 STOPPED**\n\n运行 `feyagate start` 启动服务。\n\n**Q：AI 助手说找不到工具**\n\n1. 确认已运行 `feyagate install-openclaw`\n2. 重启 OpenClaw\n3. 检查 `~/.openclaw/skills/feyagate` 符号链接是否存在\n\n**Q：小米设备控制失败**\n\n运行 `feyagate auth` 重新授权。Token 过期后需要重新登录。\n\n**Q：涂鸦设备提示 `license_required`**\n\nFeyaGate 免费版支持小米平台全功能。涂鸦、美的、易微联需要授权版。详情查看 [feyagate.com](https://www.feyagate.com)。\n\n**Q：怎么升级到最新版？**\n\n```bash\npip install --upgrade feyagate-skill\nfeyagate upgrade\n```\n\n---\n\n## 完整工具列表（76 个）\n\nFeyaGate 提供了 76 个 MCP 工具，覆盖以下类别：\n\n| 类别 | 工具示例 |\n|------|---------|\n| 设备发现 | `device/list`、`device/specs`、`platform/status` |\n| 小米控制 | `xiaomi/get_properties`、`xiaomi/set_property`、`xiaomi/execute_action` |\n| 涂鸦控制 | `tuya/get_property`、`tuya/set_property` |\n| 美的控制 | `midea/get_property`、`midea/set_property` |\n| 易微联控制 | `ewelink/get_property`、`ewelink/set_property` |\n| 小爱音箱 | `xiaoai/tts`、`xiaoai/play_music`、`xiaoai/control` |\n| 摄像头 | `xiaomi/camera_list`、`xiaomi/camera_connect`、`xiaomi/camera_snapshot`、`xiaomi/camera_vision_chat` |\n| 场景 | `xiaomi/scene_list`、`xiaomi/scene_trigger` |\n| 定时 | `schedule/add`、`schedule/list`、`schedule/delete` |\n| 触发器 | `trigger/add`、`trigger/list`（摄像头+自然语言条件） |\n| 认证 | `auth/platforms`、`auth/tuya_qr`、`auth/midea_login` |\n| 配置 | `config/get`、`config/set`、`config/set_vision` |\n\n完整 API 文档见：[FeyaGate_MCP_API.md](https://github.com/toddpan/feyagate-skill/blob/main/FeyaGate_MCP_API.md)\n\n---\n\n## 总结\n\n整个流程非常简单：\n\n1. **一条命令**安装 FeyaGate（`curl ... | bash`）\n2. **一条命令**接入 OpenClaw（`feyagate install-openclaw`）\n3. **登录**你的智能设备平台（`feyagate auth`）\n4. **用自然语言**和 AI 对话，控制家里的设备\n\n从此以后，写代码写累了，对 AI 说一句「帮我把灯关了」就行。\n\n---\n\n**项目地址：** [https://github.com/toddpan/feyagate-skill](https://github.com/toddpan/feyagate-skill)\n\n**官网：** [https://www.feyagate.com](https://www.feyagate.com)\n\n**协议：** MIT License\n\nFile v1.0.8:FeyaGate_HTTP_API.md\n\n# FeyaGate HTTP API 文档\n\n> **适用产品**: miloco-mcp-server (桌面版虚拟网关 / ESP32 物理网关)\n> **基础 URL**: `http://<网关IP>:<port>` (桌面版默认 `38080`)\n> **协议**: HTTP REST + MCP JSON-RPC 2.0\n> **CORS**: 全局开放 `Access-Control-Allow-Origin: *`\n\n---\n\n## 目录\n\n- [1. 概述](#1-概述)\n- [2. HTTP REST 接口](#2-http-rest-接口)\n  - [2.1 健康检查](#21-健康检查)\n  - [2.2 OAuth 授权回调](#22-oauth-授权回调)\n  - [2.3 网关信息](#23-网关信息)\n  - [2.4 授权管理](#24-授权管理)\n- [3. MCP JSON-RPC 接口](#3-mcp-json-rpc-接口)\n  - [3.1 协议说明](#31-协议说明)\n  - [3.2 协议方法](#32-协议方法)\n- [4. 米家平台](#4-米家平台)\n- [5. 小爱音箱](#5-小爱音箱)\n- [6. 小智平台](#6-小智平台)\n- [7. 授权与网关](#7-授权与网关)\n- [8. Vision AI](#8-vision-ai)\n- [9. 触发规则](#9-触发规则)\n- [10. 配置管理](#10-配置管理)\n- [11. 统计数据](#11-统计数据)\n- [12. 多平台设备](#12-多平台设备)\n- [13. 定时任务](#13-定时任务)\n- [14. 技能管理](#14-技能管理)\n\n---\n\n## 1. 概述\n\nFeyaGate 网关提供两类 HTTP 接口：\n\n1. **HTTP REST 接口** — 标准 GET/POST/DELETE 端点，主要用于健康检查、OAuth 授权回调、网关信息和授权管理。\n2. **MCP JSON-RPC 接口** — 所有智能家居控制、设备管理等核心功能通过 `POST /mcp/http` 以 JSON-RPC 2.0 协议调用。\n\n---\n\n## 2. HTTP REST 接口\n\n### 2.1 健康检查\n\n```\nGET /health\n```\n\n**响应示例**:\n```json\n{\"status\": \"ok\"}\n```\n\n### 2.2 OAuth 授权回调\n\n#### 2.2.1 OAuth 回调\n\n```\nGET /auth/callback?code=xxx&source=browser\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | string | 是 | OAuth 授权码 |\n| `source` | string | 否 | 来源标识，`browser` 时触发页面重定向 |\n\n**响应**: 成功时返回 HTML 页面显示授权结果；失败时返回错误提示。\n\n#### 2.2.2 浏览器 OAuth 回调\n\n```\nGET /auth/browser-callback?code=xxx\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | string | 是 | OAuth 授权码 |\n\n**响应**: 重定向到 `/#/?auth=success` 或 `/#/?auth=failed`。\n\n#### 2.2.3 浏览器 OAuth 启动页\n\n```\nGET /auth/browser-start?oauth_url=xxx&callback=xxx\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `oauth_url` | string | 是 | OAuth 授权 URL |\n| `callback` | string | 是 | 回调地址 |\n\n**响应**: 返回 HTML 页面，含小米登录按钮，500ms 后自动跳转授权。\n\n### 2.3 网关信息\n\n```\nGET /api/v1/gateway/info\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"version\": \"v1.2.14\",\n    \"platform\": \"linux\",\n    \"device_id\": \"xxx\",\n    \"edition\": \"pro\",\n    \"licensed\": true\n  }\n}\n```\n\n### 2.4 授权管理\n\n#### 获取授权状态\n\n```\nGET /api/v1/gateway/license\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"edition\": \"pro\",\n    \"status\": \"active\",\n    \"product\": \"feyagate-linux\",\n    \"license_key\": \"FG-xxxx-****-xxxx\"\n  }\n}\n```\n\n#### 写入授权码\n\n```\nPOST /api/v1/gateway/license\nContent-Type: application/json\n```\n\n**请求体**:\n```json\n{\n  \"license_key\": \"FG-XXXX-XXXX-XXXX\",\n  \"product\": \"feyagate-linux\"\n}\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `license_key` | string | 是 | 授权码，格式 `FG-XXXX-XXXX-XXXX` |\n| `product` | string | 否 | 产品标识，默认使用配置文件中的值 |\n\n**响应示例**:\n```json\n{\n  \"\n\nArchive v1.0.7: 59 files, 126034 bytes\n\nFiles: CLAUDE.md (5370b), config/camera_extra_info.yaml (1383b), docs/zhihu_openclaw_feyagate.md (10894b), FeyaGate_HTTP_API.md (24768b), FeyaGate_MCP_API.md (45334b), feyagate_skill/__init__.py (398b), feyagate_skill/auth.py (4276b), feyagate_skill/cli.py (8279b), feyagate_skill/config.py (1547b), feyagate_skill/data/camera_extra_info.yaml (1383b), feyagate_skill/data/SKILL.md (7771b), feyagate_skill/data/skills/automation.md (2500b), feyagate_skill/data/skills/ewelink.md (3100b), feyagate_skill/data/skills/extension.md (2109b), feyagate_skill/data/skills/midea.md (3012b), feyagate_skill/data/skills/tuya.md (3015b), feyagate_skill/data/skills/xiaomi.md (4043b), feyagate_skill/installer.py (12327b), feyagate_skill/mcp.py (6721b), feyagate_skill/scheduled.py (6825b), feyagate_skill/service.py (9028b), feyagate_skill/snapshot.py (4306b), pyproject.toml (1646b), QUICKSTART.md (10471b), README.md (11748b), reference.md (10243b), scripts/auth.py (8008b), scripts/build.sh (392b), scripts/health_check.sh (1593b), scripts/install.ps1 (7340b), scripts/install.sh (7661b), scripts/publish.sh (1419b), scripts/scheduled_analysis.py (7126b), scripts/setup.sh (8519b), scripts/snapshot.py (5279b), scripts/start.sh (2447b), scripts/stop.sh (666b), scripts/upgrade.ps1 (17473b), scripts/upgrade.sh (18720b), scripts/verify.sh (2269b), SKILL.md (7771b), skills/automation.md (2500b), skills/ewelink.md (3100b), skills/extension.md (2109b), skills/midea.md (3012b), skills/tuya.md (3015b), skills/xiaomi.md (4043b), tests/__init__.py (16b), tests/conftest.py (16b), tests/test_auth.py (3353b), tests/test_cli.py (12466b), tests/test_config.py (2841b), tests/test_init.py (1142b), tests/test_installer.py (11540b), tests/test_mcp.py (8978b), tests/test_scheduled.py (5984b), tests/test_service.py (9723b), tests/test_snapshot.py (5763b), _meta.json (127b)\n\nArchive v1.0.6: 39 files, 76931 bytes\n\nFiles: config/camera_extra_info.yaml (1383b), FeyaGate_HTTP_API.md (11529b), FeyaGate_MCP_API.md (14556b), QUICKSTART.md (10057b), README.md (9781b), reference.md (10243b), scripts/auth.py (8008b), scripts/build.sh (392b), scripts/health_check.sh (1593b), scripts/install.ps1 (7378b), scripts/install.sh (7697b), scripts/publish.sh (1419b), scripts/scheduled_analysis.py (7126b), scripts/setup.sh (8519b), scripts/snapshot.py (5279b), scripts/start.sh (2447b), scripts/stop.sh (666b), scripts/upgrade.ps1 (17473b), scripts/upgrade.sh (18720b), scripts/verify.sh (2269b), SKILL.md (7771b), skills/automation.md (2500b), skills/ewelink.md (3100b), skills/extension.md (2109b), skills/midea.md (3012b), skills/tuya.md (3015b), skills/xiaomi.md (4043b), tests/__init__.py (16b), tests/conftest.py (16b), tests/test_auth.py (3353b), tests/test_cli.py (12430b), tests/test_config.py (2841b), tests/test_init.py (1106b), tests/test_installer.py (11540b), tests/test_mcp.py (8978b), tests/test_scheduled.py (5984b), tests/test_service.py (9723b), tests/test_snapshot.py (5763b), _meta.json (127b)","readmeExcerpt":"Skill: Feyagate Owner: toddpan Summary: MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol. Tags: latest:1.0.9 Version history: v1.0.9 | 2026-06-05T23:45:13.858Z | auto - Major refactor: skill was simplified with most Python code and scripts removed. - SKILL.md restructured and updated for clarity, with enhanced metadata and improved platform summ","codeSnippets":[],"executableExamples":[{"language":"bash","snippet":"feyagate status"},{"language":"bash","snippet":"pip install feyagate-skill       # Install Python package\nfeyagate setup                   # Download MCP server binary (~30MB)\nfeyagate start                   # Start service on localhost:38080\nfeyagate install-claude          # Register with your AI agent\nfeyagate auth                    # Authorize smart home platform"},{"language":"yaml","snippet":"server:\n  http_port: 38080\n  ws_port: 8765\n  bind_address: \"0.0.0.0\"\nauth:\n  cloud_server: \"cn\"      # cn / de / sg / us / ru / i2\ncamera:\n  frame_interval: 500\n  jpeg_quality: 90\nxiaozhi:\n  endpoint: \"\"            # ws:// or wss:// (empty = disabled)"},{"language":"text","snippet":"GET /health"},{"language":"json","snippet":"{\"status\": \"ok\"}"},{"language":"text","snippet":"GET /auth/callback?code=xxx&source=browser"}],"parameters":null,"dependencies":[],"permissions":[],"extractedFiles":[{"path":"SKILL.md","content":"---\nname: feyagate\ndescription: MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol.\nversion: 1.2.31\nemoji: \"🏠\"\nhomepage: https://www.feyagate.com\nmetadata:\n  openclaw:\n    requires:\n      bins:\n        - curl\n      config:\n        - ~/.feyagate/config/config.yaml\n    envVars:\n      - name: FEyagate_INSTALL_DIR\n        required: false\n        description: Override installation directory (default ~/.feyagate)\n      - name: FEyagate_PORT\n        required: false\n        description: HTTP port for the MCP proxy server (default 38080)\nsub_skills:\n  - name: feyagate-xiaomi\n    file: skills/xiaomi.md\n    trigger: Xiaomi, Mi Home, MIOT, 小米, camera, P2P, XiaoAI, 小爱, TTS, speaker, 摄像头\n  - name: feyagate-tuya\n    file: skills/tuya.md\n    trigger: Tuya, Smart Life, 涂鸦, DP code, QR auth\n  - name: feyagate-midea\n    file: skills/midea.md\n    trigger: Midea, 美居, 美的, AC, air conditioner, 空调\n  - name: feyagate-ewelink\n    file: skills/ewelink.md\n    trigger: eWeLink, Sonoff, iTEAD, switch, relay\n  - name: feyagate-automation\n    file: skills/automation.md\n    trigger: schedule, timer, trigger, automation, room, memory, note, 定时, 自动化, 房间, 记忆\n  - name: feyagate-extension\n    file: skills/extension.md\n    trigger: serial, RS485, UART, GPIO, Xiaozhi, 小智, license, config, stats, 统计\n---\n\n# FeyaGate Skill — MCP Smart Home Gateway\n\nControl smart home devices (lights, cameras, AC, speakers) from any AI agent via MCP protocol. Supports **Xiaomi · Tuya · Midea · eWeLink · Serial · GPIO**.\n\n## Prerequisites\n\n- Python 3.9+\n- macOS / Linux / Windows\n- `curl` (for installation)\n\n## Before Using Any Tool\n\nRun this check **before** calling any FeyaGate MCP tool:\n\n```bash\nfeyagate status\n```\n\n- **RUNNING** → proceed with tool calls\n- **STOPPED** or command not found → run `feyagate start` first\n- Not installed → `pip install feyagate-skill && feyagate setup && feyagate start`\n\n## Quick Start\n\n```bash\npip install feyagate-skill       # Install Python package\nfeyagate setup                   # Download MCP server binary (~30MB)\nfeyagate start                   # Start service on localhost:38080\nfeyagate install-claude          # Register with your AI agent\nfeyagate auth                    # Authorize smart home platform\n```\n\nOther agents: `install-cursor`, `install-openclaw`, `install-hermes`, `install-codex`, `install-windsurf`, `install-copilot`\n\nFull guide: [QUICKSTART.md](QUICKSTART.md)\n\n## Server Lifecycle\n\n| Action | Command |\n|--------|---------|\n| Install binary | `feyagate setup [--dir PATH]` |\n| Start | `feyagate start [--port PORT]` |\n| Stop | `feyagate stop` |\n| Restart | `feyagate restart [--port PORT]` |\n| Status | `feyagate status` |\n| Logs | `feyagate log [-n 50]` |\n| Update | `feyagate update` |\n| Auth | `feyagate auth [--status] [--code CODE]` |\n\n## Cross-Platform Tools\n\nThese tools work across all platforms (system auto-detects device platform):\n\n| Tool | Arguments | Returns |\n|------|---------"},{"path":"_meta.json","content":"{\n  \"ownerId\": \"kn70xdk1j9emqkf281q83fvzb1858rny\",\n  \"slug\": \"feyagate\",\n  \"version\": \"1.0.9\",\n  \"publishedAt\": 1780703113858\n}"},{"path":"FeyaGate_HTTP_API.md","content":"# FeyaGate HTTP API 文档\n\n> **适用产品**: miloco-mcp-server (桌面版虚拟网关 / ESP32 物理网关)\n> **基础 URL**: `http://<网关IP>:<port>` (桌面版默认 `38080`)\n> **协议**: HTTP REST + MCP JSON-RPC 2.0\n> **CORS**: 全局开放 `Access-Control-Allow-Origin: *`\n\n---\n\n## 目录\n\n- [1. 概述](#1-概述)\n- [2. HTTP REST 接口](#2-http-rest-接口)\n  - [2.1 健康检查](#21-健康检查)\n  - [2.2 OAuth 授权回调](#22-oauth-授权回调)\n  - [2.3 网关信息](#23-网关信息)\n  - [2.4 授权管理](#24-授权管理)\n- [3. MCP JSON-RPC 接口](#3-mcp-json-rpc-接口)\n  - [3.1 协议说明](#31-协议说明)\n  - [3.2 协议方法](#32-协议方法)\n- [4. 米家平台](#4-米家平台)\n- [5. 小爱音箱](#5-小爱音箱)\n- [6. 小智平台](#6-小智平台)\n- [7. 授权与网关](#7-授权与网关)\n- [8. Vision AI](#8-vision-ai)\n- [9. 触发规则](#9-触发规则)\n- [10. 配置管理](#10-配置管理)\n- [11. 统计数据](#11-统计数据)\n- [12. 多平台设备](#12-多平台设备)\n- [13. 定时任务](#13-定时任务)\n- [14. 技能管理](#14-技能管理)\n\n---\n\n## 1. 概述\n\nFeyaGate 网关提供两类 HTTP 接口：\n\n1. **HTTP REST 接口** — 标准 GET/POST/DELETE 端点，主要用于健康检查、OAuth 授权回调、网关信息和授权管理。\n2. **MCP JSON-RPC 接口** — 所有智能家居控制、设备管理等核心功能通过 `POST /mcp/http` 以 JSON-RPC 2.0 协议调用。\n\n---\n\n## 2. HTTP REST 接口\n\n### 2.1 健康检查\n\n```\nGET /health\n```\n\n**响应示例**:\n```json\n{\"status\": \"ok\"}\n```\n\n### 2.2 OAuth 授权回调\n\n#### 2.2.1 OAuth 回调\n\n```\nGET /auth/callback?code=xxx&source=browser\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | string | 是 | OAuth 授权码 |\n| `source` | string | 否 | 来源标识，`browser` 时触发页面重定向 |\n\n**响应**: 成功时返回 HTML 页面显示授权结果；失败时返回错误提示。\n\n#### 2.2.2 浏览器 OAuth 回调\n\n```\nGET /auth/browser-callback?code=xxx\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `code` | string | 是 | OAuth 授权码 |\n\n**响应**: 重定向到 `/#/?auth=success` 或 `/#/?auth=failed`。\n\n#### 2.2.3 浏览器 OAuth 启动页\n\n```\nGET /auth/browser-start?oauth_url=xxx&callback=xxx\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `oauth_url` | string | 是 | OAuth 授权 URL |\n| `callback` | string | 是 | 回调地址 |\n\n**响应**: 返回 HTML 页面，含小米登录按钮，500ms 后自动跳转授权。\n\n### 2.3 网关信息\n\n```\nGET /api/v1/gateway/info\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"version\": \"v1.2.14\",\n    \"platform\": \"linux\",\n    \"device_id\": \"xxx\",\n    \"edition\": \"pro\",\n    \"licensed\": true\n  }\n}\n```\n\n### 2.4 授权管理\n\n#### 获取授权状态\n\n```\nGET /api/v1/gateway/license\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"edition\": \"pro\",\n    \"status\": \"active\",\n    \"product\": \"feyagate-linux\",\n    \"license_key\": \"FG-xxxx-****-xxxx\"\n  }\n}\n```\n\n#### 写入授权码\n\n```\nPOST /api/v1/gateway/license\nContent-Type: application/json\n```\n\n**请求体**:\n```json\n{\n  \"license_key\": \"FG-XXXX-XXXX-XXXX\",\n  \"product\": \"feyagate-linux\"\n}\n```\n\n| 参数 | 类型 | 必填 | 说明 |\n|------|------|------|------|\n| `license_key` | string | 是 | 授权码，格式 `FG-XXXX-XXXX-XXXX` |\n| `product` | string | 否 | 产品标识，默认使用配置文件中的值 |\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": {\n    \"edition\": \"pro\",\n    \"status\": \"active\",\n    \"activated\": true\n  }\n}\n```\n\n#### 清除授权\n\n```\nDELETE /api/v1/gateway/license\n```\n\n**响应示例**:\n```json\n{\n  \"code\": 0,\n  \"data\": { \"edition\": \"free\", \"status\": \"inactive\" },\n  \"message\": \"授权已清除, 恢复免费版\"\n}\n```\n\n---\n\n## 3. MCP JSON-RPC 接口\n\n### 3.1 协议说明\n\n所有 MCP 工具通过单一端点调用：\n\n```\nPOST /mcp/http\nContent-Type: application/json\n"},{"path":"FeyaGate_MCP_API.md","content":"# FeyaGate MCP API 文档\n\n> **适用产品**: miloco-mcp-server (桌面版虚拟网关)\n> **协议**: MCP (Model Context Protocol) JSON-RPC 2.0\n> **MCP 端点**: `POST http://<网关IP>:38080/mcp/http`\n> **协议版本**: `2025-03-26`\n\n---\n\n## 目录\n\n- [1. 连接指南](#1-连接指南)\n- [2. JSON-RPC 2.0 规范](#2-json-rpc-20-规范)\n- [3. 协议方法](#3-协议方法)\n- [4. MCP Tools 总览 (76 个)](#4-mcp-tools-总览-76-个)\n- [5. 通用设备工具](#5-通用设备工具)\n- [6. 小米 (Xiaomi) 平台](#6-小米-xiaomi-平台)\n- [7. 涂鸦 (Tuya) 平台](#7-涂鸦-tuya-平台)\n- [8. 美的 (Midea) 平台](#8-美的-midea-平台)\n- [9. 易微联 (eWeLink) 平台](#9-易微联-ewelink-平台)\n- [10. 小爱音箱控制](#10-小爱音箱控制)\n- [11. 小智平台](#11-小智平台)\n- [12. 认证与平台管理](#12-认证与平台管理)\n- [13. Vision AI](#13-vision-ai)\n- [14. 触发规则](#14-触发规则)\n- [15. 定时任务](#15-定时任务)\n- [16. 技能系统](#16-技能系统)\n- [17. 配置管理](#17-配置管理)\n- [18. 统计数据](#18-统计数据)\n- [19. 授权码管理](#19-授权码管理)\n- [20. 网关信息](#20-网关信息)\n- [21. 错误码](#21-错误码)\n- [附录: 快速示例](#附录-快速示例)\n\n---\n\n## 1. 连接指南\n\n所有 MCP 调用均通过 `POST /mcp/http` 以 JSON-RPC 2.0 格式发送，无需事先握手。\n\n```bash\n# 初始化\ncurl -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-03-26\",\"capabilities\":{},\"clientInfo\":{\"name\":\"MyClient\",\"version\":\"1.0.0\"}}}'\n\n# 列出所有工具\ncurl -s -X POST http://localhost:38080/mcp/http \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/list\",\"params\":{}}'\n```\n\n> **无状态**: 服务器不维持 HTTP 会话状态，不返回 `Mcp-Session-Id` header，每次请求均为无状态调用。\n>\n> **无 WebSocket**: 服务器不提供 inbound WebSocket 端点。`/mcp` WebSocket 路径不存在。服务器作为 WebSocket **客户端**主动连接小智平台，由 `xiaozhi/*` 工具管理。\n\n---\n\n## 2. JSON-RPC 2.0 规范\n\n### 请求结构\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"<工具名>\",\n    \"arguments\": { ... }\n  }\n}\n```\n\n### 成功响应\n\n工具返回值被包装为 MCP content 格式：\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"result\": {\n    \"content\": [\n      { \"type\": \"text\", \"text\": \"{\\\"success\\\":true,...}\" }\n    ]\n  }\n}\n```\n\n> 工具返回的 JSON 对象会被序列化为字符串放在 `content[0].text` 中。\n\n### 图片响应\n\n当工具返回含 `images` 数组（含 `data_url` 字段）的结果时，服务器会自动提取图片为独立的 MCP image content：\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"result\": {\n    \"content\": [\n      { \"type\": \"text\", \"text\": \"{\\\"camera_id\\\":\\\"xxx\\\",\\\"images\\\":[...]}\" },\n      { \"type\": \"image\", \"data\": \"<base64>\", \"mimeType\": \"image/jpeg\" }\n    ]\n  }\n}\n```\n\n### 错误响应\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"error\": { \"code\": -32601, \"message\": \"Tool not found: unknown/tool\" }\n}\n```\n\n### 工具执行异常\n\n当工具 handler 抛出异常时，返回 `isError: true`：\n\n```json\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"result\": {\n    \"content\": [\n      { \"type\": \"text\", \"text\": \"{\\\"error\\\":\\\"exception message\\\"}\" }\n    ],\n    \"isError\": true\n  }\n}\n```\n\n---\n\n## 3. 协议方法\n\n| 方法 | 说明 |\n|------|------|\n| `initialize` | MCP 协议握手 |\n| `ping` | 保活心跳 |\n| `tools/list` | 列出所有已注册工具 |\n| `tools/call` | 调用指定工具 |\n| `notifications/initialized` | 初始化完成通知（无响应） |\n\n### initialize\n\n```json\n{\n  \"jsonrpc\": \"2.0\", \"id\": 1,\n  \"method\": \"initialize\",\n  \"params\": {\n    \"protocolVersion\": \"2025-03-26\",\n    \"capabilities\": {},\n    \"clientI"},{"path":"QUICKSTART.md","content":"# FeyaGate Skill — Quick Start Guide\n\n```\n  _____                 ____       _\n |  ___|__ _   _  __ _ / ___| __ _| |_ ___\n | |_ / _ \\ | | |/ _` | |  _ / _` | __/ _ \\\n |  _|  __/ |_| | (_| | |_| | (_| | ||  __/\n |_|  \\___|\\__, |\\__,_|\\____|\\__,_|\\__\\___|\n           |___/\n```\n\n> **For AI Assistants (OpenClaw, Claude Code, Hermes, Codex, Windsurf, Copilot, 小智AI, Cursor):**\n> Follow Steps 1-4 sequentially. Report progress at each step. Do NOT skip steps.\n> Steps marked with **[AUTO]** can be executed without asking the user.\n> Steps marked with **[ASK]** require user input before proceeding.\n\n## Prerequisites\n\n- Python 3.9+\n- Internet access (for downloading MCP server binary ~30MB)\n\n## One-Line Install [AUTO]\n\n**macOS / Linux** — installs the Python package and MCP server binary in one step:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.sh | bash\n```\n\n**Windows (PowerShell):**\n\n```powershell\niwr -useb https://raw.githubusercontent.com/toddpan/feyagate-skill/main/scripts/install.ps1 | iex\n```\n\nAfter one-line install, skip to **Step 3** (install agent skill). If you prefer manual steps, continue below.\n\n> **For developers:** Clone the repo and use `pip install -e .` instead of the one-line script — see Step 1 Option B.\n\n## Step 1: Install [AUTO]\n\n**Option A — from PyPI (standard online install):**\n\n```bash\npip install feyagate-skill\n```\n\n**Option B — from source (developers / contributors):**\n\n```bash\ngit clone https://github.com/toddpan/feyagate-skill.git\ncd feyagate-skill\npip install -e \".[dev]\"     # includes pytest and other dev dependencies\n```\n\nVerify:\n\n```bash\nfeyagate --version\n```\n\n## Step 2: Setup & Start [AUTO]\n\nDownload and install the MCP server binary (may take 1-2 minutes):\n\n```bash\nfeyagate setup\n```\n\nDefault directory: `~/.feyagate`. Customize with `feyagate setup --dir ~/my-feyagate`.\n\nStart the service:\n\n```bash\nfeyagate start\n```\n\nVerify:\n\n```bash\nfeyagate status\n```\n\nService URL: `http://localhost:38080/mcp/http`. Custom port: `feyagate start --port 9090`.\n\n## Step 3: Install as AI Agent Skill [ASK]\n\n> **IMPORTANT:** This step installs the FeyaGate skill (SKILL.md + sub-skills) for the AI agent you are currently running in.\n> Ask the user: \"Which AI agent should I install for?\" or detect from the environment.\n\n```bash\nfeyagate install-claude     # Claude Code\nfeyagate install-cursor     # Cursor\nfeyagate install-openclaw   # OpenClaw\nfeyagate install-hermes     # Hermes Agent\nfeyagate install-windsurf   # Windsurf\nfeyagate install-copilot    # GitHub Copilot (VS Code)\nfeyagate install-codex      # OpenAI Codex CLI\n```\n\nAfter install, **restart the AI agent** to load the skill.\n\n## Step 4: Authorize Smart Home Platform [ASK]\n\n> Ask the user which platform(s) they want to authorize.\n\n### Xiaomi / Mi Home (OAuth)\n\n```bash\nfeyagate auth --status    # Check current status\nfeyagate auth             # Interactive OAuth authorization\n```\n\nThe interactive flow will output a URL → user ope"}],"languages":[],"docsSourceLabel":"CLAWHUB","editorialOverview":"MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol. Skill: Feyagate Owner: toddpan Summary: MCP smart home gateway for AI agents. Control Xiaomi, Tuya, Midea, eWeLink, cameras, and XiaoAI speakers via MCP protocol. Tags: latest:1.0.9 Version history: v1.0.9 | 2026-06-05T23:45:13.858Z | auto - Major refactor: skill was simplified with most Python code and scripts removed. - SKILL.md restructured and updated for clarity, with enhanced metadata and improved platform summ","editorialQuality":{"score":100,"threshold":65,"status":"ready","wordCount":1423,"uniquenessScore":46,"reasons":[]}},"media":{"evidence":{"source":"no-media","verified":false,"confidence":"low","updatedAt":"2026-10-11T23:08:24.753Z","emptyReason":"No screenshots, media assets, or demo links are available."},"primaryImageUrl":null,"mediaAssetCount":0,"assets":[],"demoUrl":null},"ownerResources":{"evidence":{"source":"unclaimed","verified":false,"confidence":"low","updatedAt":"2026-10-11T23:08:24.753Z","emptyReason":"This page has not been claimed by the agent owner."},"hasCustomPage":false,"customPageUpdatedAt":null,"customLinks":[],"structuredLinks":{"docsUrl":null,"demoUrl":null,"supportUrl":null,"pricingUrl":null,"statusUrl":null},"customPage":null},"relatedAgents":{"evidence":{"source":"protocol-neighbors","verified":false,"confidence":"medium","updatedAt":"2026-10-12T12:05:45.577Z","emptyReason":null},"items":[{"id":"8ebccd8e-3863-4187-8355-c3f14e1f9edf","entityType":"agent","canonicalPath":"/agent/iofficeai-aionui","slug":"iofficeai-aionui","name":"AionUi","description":"Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!","url":"https://github.com/iOfficeAI/AionUi","homepage":"https://www.aionui.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-10-09T19:11:12.944Z","createdAt":"2026-02-25T03:38:16.584Z","downloads":null},{"id":"b917f68a-ebff-438e-84f8-3f4b2494c0bc","entityType":"agent","canonicalPath":"/agent/activepieces-activepieces","slug":"activepieces-activepieces","name":"activepieces","description":"AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents","url":"https://github.com/activepieces/activepieces","homepage":"https://www.activepieces.com","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-15T02:22:12.426Z","createdAt":"2026-02-25T03:38:12.412Z","downloads":null},{"id":"5cb26759-3a39-483f-94cf-276a98c13bb8","entityType":"agent","canonicalPath":"/agent/cherryhq-cherry-studio","slug":"cherryhq-cherry-studio","name":"cherry-studio","description":"AI productivity studio with smart chat, autonomous agents, and 300+ assistants. Unified access to frontier LLMs","url":"https://github.com/CherryHQ/cherry-studio","homepage":"https://cherry-ai.com","source":"GITHUB_REPOS","protocols":["MCP","OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-04-11T14:38:40.986Z","createdAt":"2026-02-25T03:38:19.379Z","downloads":null},{"id":"6f6582d0-5d76-4f0f-b81d-86520247950b","entityType":"agent","canonicalPath":"/agent/copilotkit-copilotkit","slug":"copilotkit-copilotkit","name":"CopilotKit","description":"The Frontend for Agents & Generative UI. React + Angular","url":"https://github.com/CopilotKit/CopilotKit","homepage":"https://docs.copilotkit.ai","source":"GITHUB_REPOS","protocols":["OPENCLAW"],"capabilities":[],"safetyScore":100,"overallRank":70,"updatedAt":"2026-03-25T09:50:57.846Z","createdAt":"2026-02-25T03:39:14.617Z","downloads":null}],"links":{"hub":"/agent","source":"/agent/source/clawhub","protocols":[{"label":"OpenClaw","href":"/agent/protocol/openclew"}]}}}