Skip to main content
Glama
HyperOS Doctor MCP

HyperOS Doctor MCP

by leaves-body
README.md
# HyperOS Doctor MCP

Read-only HyperOS / MIUI diagnostics over ADB, with a local CLI, privacy-minimised JSON/HTML reports, and a Model Context Protocol (MCP) server for AI agents.

**中文使用指南:[docs/usage-zh.md](docs/usage-zh.md)** · [Compatibility](docs/compatibility.md) · [Security](SECURITY.md)

> **Status: alpha.** The parsers, rules, CLI and MCP tool registration are covered by automated tests. Physical-device compatibility and end-to-end MCP-host testing are still pending. Do not interpret a finding as proof of a hardware fault.

## What it does

HyperOS Doctor turns a small set of fixed, read-only ADB queries into evidence that an AI agent or a person can inspect:

- Device manufacturer, model, Android and HyperOS/MIUI version fields.
- NFC setting and service state.
- Battery level, reported health, charging state and snapshot temperature.
- `/data` storage usage.
- An optional one-shot `top` process snapshot.
- Transparent findings with severity, evidence, safe next steps and limitations.

It is designed for Xiaomi, Redmi and POCO troubleshooting workflows, not as another general-purpose Android remote-control server.

## Safety and privacy

- **No Root required. No writes.** No settings changes, package operations, process killing, reboot, flashing or arbitrary shell tool.
- Only allow-listed build properties and the `battery` / `nfc` dumpsys services are exposed.
- Report serial numbers are masked, including partial-read failure warnings.
- HTML reports are self-contained: no external scripts, fonts, trackers or network requests.
- Output files are not overwritten unless `--force` is explicit.
- `hyperos_list_devices` returns unmasked serials for device selection; do not publish that result.

See [SECURITY.md](SECURITY.md) before sharing a report.

## Install

Requirements: Python 3.10+ and [Android Platform Tools](https://developer.android.com/tools/releases/platform-tools). The base CLI has no third-party Python runtime dependencies.

From a source checkout:

```bash
python -m pip install -e .
# Add MCP support:
python -m pip install -e ".[mcp]"
```

Enable USB debugging on your phone, connect it, unlock it and accept the USB-debugging authorization prompt. Verify the local connection:

```bash
adb devices
hyperos-doctor devices
```

If `adb` is not on `PATH`, pass its full path before the subcommand:

```bash
hyperos-doctor --adb "C:\platform-tools\adb.exe" devices
```

## CLI usage

```bash
# Human-readable summary in the terminal
hyperos-doctor scan

# Save shareable reports; existing files are protected
hyperos-doctor scan --output report.html --json-output report.json

# Select one of several devices
hyperos-doctor scan --serial DEVICE_SERIAL --output report.html

# Skip the one-shot process list
hyperos-doctor scan --no-processes --json

# Explicitly replace existing report files
hyperos-doctor scan --output report.html --force
```

A synthetic, phone-free example is included at [`examples/sample-report.html`](examples/sample-report.html). Regenerate it with:

```bash
python examples/offline_demo.py
```

## MCP server

Install the `mcp` extra, then register the stdio server in an MCP-compatible host:

```json
{
  "mcpServers": {
    "hyperos-doctor": {
      "command": "hyperos-doctor",
      "args": ["mcp"]
    }
  }
}
```

Use the absolute path to the installed `hyperos-doctor` executable if the host does not inherit your shell's `PATH`. A custom ADB path goes before `mcp`:

```json
{
  "mcpServers": {
    "hyperos-doctor": {
      "command": "hyperos-doctor",
      "args": ["--adb", "C:\\platform-tools\\adb.exe", "mcp"]
    }
  }
}
```

The server deliberately exposes only three tools:

| Tool | Purpose |
| --- | --- |
| `hyperos_list_devices` | List ADB devices and authorization states; unmasked serials for local selection. |
| `hyperos_get_snapshot` | Return a read-only, serial-masked evidence snapshot. |
| `hyperos_run_diagnostics` | Return evidence, transparent findings, safe next steps and limitations. |

The agent cannot supply an ADB command. The SDK adapter supports MCP Python SDK 1.x and 2.x. See [compatibility](docs/compatibility.md) for the exact validation boundary.

## Diagnostic rules

Rules are intentionally visible in [`src/hyperos_doctor/diagnostics.py`](src/hyperos_doctor/diagnostics.py), rather than hidden in a prompt.

| Signal | Rule outcome |
| --- | --- |
| NFC setting off or service not on | Warning with safe user checks |
| `/data` usage ≥ 85% / ≥ 95% | Warning / critical |
| Snapshot battery temperature ≥ 45°C / ≥ 50°C | Warning / critical |
| Battery health other than `good` / `unknown` | Warning to investigate the reported field |
| One process at ≥ 80% instantaneous CPU | Info only; not a sustained-load claim |
| Non-Xiaomi-family manufacturer | Scope note, not an error |

A single snapshot cannot diagnose intermittent failures, battery capacity, motherboard faults or persistent CPU abuse. Missing fields are reported as limitations rather than silently converted into “healthy” results.

## Development

```bash
python -m pip install -e ".[mcp]"
python -m unittest discover -s tests -v
```

Contributions are welcome, especially anonymized parser fixtures from real HyperOS/MIUI versions. Never attach full serial numbers, account identifiers, private logs or authorization tokens. See [CONTRIBUTING.md](CONTRIBUTING.md).

## Machine discovery

- [`llms.txt`](llms.txt) gives AI tools a concise, factual project summary and validation limits.
- [`server.example.json`](server.example.json) is a template for a future MCP Registry submission; replace placeholders only after the package and repository are actually published.
- Suggested GitHub topics: `mcp`, `mcp-server`, `hyperos`, `miui`, `xiaomi`, `redmi`, `poco`, `adb`, `android-diagnostics`, `python`.

These files improve machine readability; they do not guarantee search ranking, adoption or eligibility for any third-party program.

## License

MIT. Xiaomi, Redmi, POCO, HyperOS and MIUI are trademarks of their respective owners. This is an independent project and is not affiliated with or endorsed by Xiaomi.