# oh-my-sage-mcp [Health: Active]

**Category:** 🏠 Home Automation  
**Repository:** https://github.com/allocnode/oh-my-sage  
**GitHub Stars:** 159  
**npm Downloads (last month):** 1656  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/oh-my-sage-mcp

## Description
米家自动化极客版 MCP Server：在任意 AI Agent 里用说话的方式创建和修改米家中枢网关的自动化规则

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "oh-my-sage-mcp": {
    "command": "npx",
    "args": ["-y","oh-my-sage-mcp"],
    "env": {
      "GATEWAY_URL": ""
    }
  }
}
```

**Requires environment variables:** `GATEWAY_URL` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What oh-my-sage-mcp does

oh-my-sage-mcp gives an MCP-compatible AI agent access to automation data and rule management for a Mi Home central gateway on the local network. It can retrieve the gateway's devices, device details, MIOT Spec capabilities, automation graphs, variables, and execution logs. It can also create new rules, apply targeted edits, replace complete rule definitions, toggle rules, remove rules, and manage graph variables.

The server supports tasks such as finding every rule that references a device, locating a node across rules, investigating execution history, checking graph layout problems, and removing unused variables. Rule creation and modification are intended to be used with the `mijia-automation` Skill, which provides the rule-writing guidance.

## How it works

The agent first authenticates against the gateway with a six-digit, one-time login code obtained from the Mi Home app. Once connected, it can inspect the available devices and their supported MIOT properties before proposing an automation change.

Writes go through two validation stages. Structural validation checks graph connections and ports; capability validation compares device operations and values with the devices' actual MIOT Specs and verifies variable references. A failed check prevents the write and returns the reason for correction.

Rule data can be handled as compact, one-node-per-line text. Incremental patching is preferred for focused changes, while full-text replacement supports synchronization workflows. Read operations return a hash, allowing an update to be rejected if the rule changed after it was read. Larger graphs can be uploaded through temporary drafts in batches.

## Setup and configuration

The runtime requires Node.js 20 or newer, a Mi Home central gateway with Automation Geek Edition enabled, and the gateway's LAN address. An on-demand setup can be added to an MCP client with `npx`, using `GATEWAY_URL` such as `http://192.168.1.10`. After restarting the client, provide a fresh login code in the conversation.

For persistent use, install the npm package globally and run the supplied local installation script on Windows, macOS, or Linux. The local service listens on `127.0.0.1:3790/mcp`, so multiple agents on the same computer can share the connection. A Docker deployment is also available for a private server or NAS; clients connect to its `/mcp` endpoint with a bearer access password.

The repository also includes a browser interface. It requires the repository checkout, an OpenAI-compatible model API, `LLM_BASE_URL`, `LLM_MODEL`, `LLM_API_KEY`, and `GATEWAY_URL`. The web interface should not be exposed publicly because it has no account system.

## Tools and capabilities

The MCP tool set covers:

- Gateway authentication, disconnection, and connection-status checks.
- Device listing, detailed device and MIOT Spec inspection, and device-usage searches.
- Rule retrieval, creation, incremental patching, full-text replacement, querying, deletion, and enable/disable controls.
- Execution-log filtering by rule, node, and time.
- Structural validation, device-capability validation, and graph-layout inspection.
- Draft creation, batched node uploads, draft edits, status checks, commits, and discards.
- Variable listing, value and configuration reads, creation, updates, and deletion.

Drafts expire after 30 minutes, and each append operation accepts up to 25 nodes. Disconnecting a shared connection disconnects all clients using it. The one-time login code must be obtained again when a new connection is required.

_Full upstream README: https://allmcps.com/mcp/oh-my-sage-mcp/readme_

