# Oh My Sage MCP server

> Lets an AI client create, edit, validate, and troubleshoot Mijia smart-home automation rules on a local Mijia hub gateway.

- Repository: https://github.com/allocnode/oh-my-sage
- Page: https://hostedmcp.org/servers/allocnode/oh-my-sage
- Transport: stdio
- Stars: 135
- License: MIT

## Install

### Claude Code

```sh
claude mcp add oh-my-sage -- npx -y oh-my-sage-mcp
```

### Cursor (`~/.cursor/mcp.json`)

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

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "oh-my-sage": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "oh-my-sage-mcp"
      ]
    }
  }
}
```

### Claude Desktop (`claude_desktop_config.json`)

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

### Codex (`~/.codex/config.toml`)

```toml
[mcp_servers.oh-my-sage]
command = "npx"
args = ["-y", "oh-my-sage-mcp"]
```

### Gemini CLI (`~/.gemini/settings.json`)

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

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `GATEWAY_URL` | no | no |  |
| `LLM_API_KEY` | no | no |  |
| `LLM_BASE_URL` | no | no |  |
| `LLM_MODEL` | no | no |  |

## FAQ

### How do I connect Oh My Sage to my Mijia gateway?

Give the AI your gateway's LAN IP via GATEWAY_URL and a 6-digit one-time login code from the Mijia App, then ask the agent to connect with that code.

### Can Oh My Sage modify an existing automation rule without rewriting it?

Yes, it makes incremental patches that only change the affected nodes and preserves the rest, rejecting the write if the rule changed meanwhile.

### Does Oh My Sage validate rules before writing them to the gateway?

Yes, it checks node connections and port wiring, then verifies device properties against the real MIOT Spec and refuses to write if either check fails.

### Why does my Mijia login code get rejected?

The login code is single-use; it expires whether the attempt succeeds or fails, so fetch a new one from the Mijia App and retry.

### Can I use Oh My Sage over the network or share it across computers?

Yes, you can run it as a background service locally or deploy it via Docker on a private server or NAS; non-local listeners require an access token.
