Oh My Sage — MCP server for Claude Code and Codex

MCP server for the Mijia hub: an agent reads devices and rules, proposes an automation and writes it after validation.

Install in Claude Code, Codex and Cursor

Other ways to install

Access and checks

How we review

Extended access. The tool runs code or makes network calls and only reads external data.

  • Creates, changes and deletes automation rules and switches home devices
  • The `mijia_call_api` tool talks to the hub directly
  • The web version must not be exposed to the internet

This is third-party code. Review the repository files before installing.

What it does

Oh My Sage connects an AI agent to a Mijia (Xiaomi) central hub on the local network and to the Geek Edition automation mode in the app. The user describes what they want in words: the agent reads devices and existing rules, proposes two or three options and, after confirmation, creates the rule on the hub. Two checks run before writing: rule graph integrity and device conformance against its MIOT spec, covering whether a property exists, is writable and stays within range. The server exposes 32 tools: finding rules by device, reading execution logs, editing individual nodes, variables and card layout checks. Edits carry the hash of the version that was read, and a write is rejected if the rule has changed.

Who it is for. Owners of a Xiaomi smart home with a central hub who build complex scenarios by talking to an agent instead of by hand in the app.

Good fit when

  • A light should turn on when someone is in the living room and dim in the evening.
  • Among dozens of rules you need all that use the hallway lamp.
  • The arriving-home rule did not fire yesterday and you want to see which node it stopped at.
  • The fridge reminder volume is lowered in one node while everything else stays.
  • A variable is no longer needed and you want to know before deleting it whether any rule still references it.

Not a fit when

  • The home has no Mijia central hub or Geek Edition automation is not enabled.
  • Devices run on another platform such as Home Assistant.
  • You want to expose the server to the internet: the web version has no accounts.

Example request

Connect to the hub, review rules and sensors in the living room and propose a scenario: light on at motion and dimmer in the evening.

MCP

Transport
stdio, http
Authentication
not required

Keys and settings

GATEWAY_URL required
Address of the Mijia central hub on the local network, for example `http://192.168.1.10`.

Limitations

A Mijia central hub on the same local network is required, plus a one-time six-digit login code taken from the app at each connection. The agent creates, changes and deletes automation rules and can switch devices, so review changes before confirming. The `mijia_call_api` tool talks to the hub directly. The web version runs only with your own model key and has no accounts, so do not publish it to the internet. Documentation and interface are in Chinese.

How to disable. Remove the `oh-my-sage` entry from the agent's MCP settings and drop the skill with `npx -y skills remove mijia-automation -g`. Stop a persistent service with the install script's `-u` flag and run `npm uninstall -g oh-my-sage-mcp`.

FAQ

What do I prepare before installing?

A Mijia hub with Geek Edition automation enabled, its IP on the local network and Node.js 20 or newer. The six-digit login code comes from the app during connection.

Why two packages, a server and a skill?

The server provides hub tools and the `mijia-automation` skill teaches the agent how to create and change rules. Both are needed for creating and editing.

How do I avoid entering the code each time?

Run the server permanently as a local service, installed with `install-local.sh` or `install-local.ps1`, or in Docker on your own server. The hub then authenticates once for all agents.

What is checked before a rule is written?

Graph integrity and device conformance against the MIOT spec. On failure nothing is written and the agent receives the reason.

Does it work without an agent?

Yes, there is a web version with a chat. It needs a key for any OpenAI-compatible model in the `.env` file.

Does Oh My Sage need an API key?

Yes, it needs the environment variables GATEWAY_URL.

Discussion

No questions or reviews yet.

Comparison with similar tools

Cards that share the main search query, and how they differ.

ToolOfficialAuthenticationRepository starsMain difference
Oh My Sage (this card)nonot required157
Home Assistant best practicesno1,021home-assistant-agent-skills targets Home Assistant; Oh My Sage manages rules of the Mijia hub in its geek mode
homeassistant-mcpnoAPI key573homeassistant-mcp connects Home Assistant over MCP; Oh My Sage validates rules against the MIOT spec and reads Mijia execution logs

README in short

Rules are read and edited as compact text where each line is a node. A change is sent with the hash of the version that was read, so a concurrent edit is not overwritten.

README badge

Report a problem