Skip to main content
Glama
Battery Health MCP

Battery Health MCP

by Ahmad-1276
README.md
# Battery Health MCP

Monitor battery charge, power source, health, and charging behavior.

![Python](https://img.shields.io/badge/Python-3.10%2B-3776AB?logo=python&logoColor=white)
![MCP](https://img.shields.io/badge/MCP-Model%20Context%20Protocol-000000)
![License](https://img.shields.io/badge/license-MIT-green)

## Tools

| Tool | Description |
| --- | --- |
| `get_battery_status` | Charge percentage, plugged state, and estimated time left |
| `get_battery_health` | Design capacity, current capacity, health percentage, and cycle count |
| `get_power_source` | Whether the machine is running on AC or battery |
| `get_power_profile` | Active power/performance profile or CPU governor |
| `get_battery_summary` | Combined battery, health, source, and profile report |

## Requirements

- Python 3.10+
- `pip install -e .`

## Install

```bash
git clone https://github.com/Ahmad-1276/battery-health-mcp.git
cd battery-health-mcp

python3 -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

pip install -e .
```

## Run

```bash
battery-health-mcp
# or
python -m battery_health_mcp.server
```

The server speaks the MCP stdio protocol and waits for a client.

## Connect an MCP client

Add this to your client's MCP config (Claude Desktop, Cursor, VS Code, etc.):

```json
{
  "mcpServers": {
    "battery-health": {
      "command": "/absolute/path/to/.venv/bin/battery-health-mcp",
      "args": []
    }
  }
}
```

Use the absolute path to the executable inside your virtual environment. On Windows the path is `.venv\Scripts\battery-health-mcp.exe`.

## Example prompts

- How much battery is left?
- Is the laptop plugged in?
- What is the battery health and cycle count?
- Which power profile is active?

## Notes

Desktops and servers return `available: false`. Detailed health data is read from Linux sysfs or macOS `system_profiler`; Windows may only expose charge state.

## Development

```bash
pip install -e ".[dev]"
pytest -q
```

## License

MIT — see [LICENSE](LICENSE).