Skip to main content
Glama
PlugPence

PlugPence

by mynk4121
README.md
# PlugPence πŸ”ŒπŸ’·

**What does it cost to run? Exact running costs for UK household appliances, from kettles to tumble dryers, for people on the web and for AI assistants via MCP.**

[![Tests](https://github.com/mynk4121/PlugPence/actions/workflows/test.yml/badge.svg)](https://github.com/mynk4121/PlugPence/actions/workflows/test.yml)
[![Live site](https://img.shields.io/badge/live-plugpence.netlify.app-00C7B7?logo=netlify&logoColor=white)](https://plugpence.netlify.app)

### πŸ”— Live: [plugpence.netlify.app](https://plugpence.netlify.app) Β· MCP server: `https://plugpence.netlify.app/mcp`

<!-- mcp-name: io.github.mynk4121/plugpence -->

<p align="center">
  <a href="https://plugpence.netlify.app">
    <img src="docs/demo.gif" alt="PlugPence demo: costing a tumble dryer, using your own electricity price, comparing an air fryer with an oven, a household breakdown, and the Use with AI section" width="900" />
  </a>
</p>

---

## Why

With high energy bills, people constantly wonder *"What does my tumble dryer cost per load?"* or *"Is the air fryer cheaper than the oven?"*. The maths is simple, but people (and AI chatbots) often get it wrong. PlugPence gives the exact answer, in pence and pounds, using the current UK price cap or the unit rate from your own bill.

## Features

- **One appliance:** cost per use, week, month and year, plus *"Β£1 runs it for…"*
- **Compare:** air fryer vs oven, tumble dryer vs heated airer… ranked, with the saving per use and per year
- **My home:** the yearly cost of all your appliances, biggest first, with each one's share
- **Your own numbers:** enter your appliance's watts (from its label) and your price per kWh (from your bill)
- **35 typical UK appliances** across kitchen, laundry, heating, entertainment, lighting and more
- **Up-to-date prices:** the built-in Ofgem price cap table switches automatically on the date the cap changes
- **Use with AI:** a built-in MCP server, so Claude, Cursor and other assistants can call the same calculators

**No API keys, no database, no AI service, no tracking.** Everything is calculated in code.

## Use with AI (MCP)

PlugPence is a remote **MCP server** at:

```
https://plugpence.netlify.app/mcp
```

**Claude Code**

```bash
claude mcp add --transport http plugpence https://plugpence.netlify.app/mcp
```

**Cursor** (`.cursor/mcp.json`)

```json
{ "mcpServers": { "plugpence": { "url": "https://plugpence.netlify.app/mcp" } } }
```

**Other apps:** add the URL above wherever the app lets you add a remote MCP server (for example as a custom connector).

Then ask things like:
- *"Is it cheaper to cook chips in my air fryer or the oven?"*
- *"How much does my tumble dryer cost a year if I use it 4 times a week?"*
- *"How long can I run my oil heater for Β£1?"*
- *"I pay 24.5p per kWh. What does a 10-minute electric shower cost?"*

### Tools

| Tool | What it does |
| --- | --- |
| `running_cost` | Cost of running one appliance for a time or number of uses, with optional weekly, monthly and yearly totals |
| `compare_costs` | Compares 2–4 appliances, cheapest first, with the saving per use and per year |
| `time_for_budget` | How long Β£X runs an appliance, or how many loads it pays for |
| `household_breakdown` | Yearly cost of several appliances, biggest first, with each one's share |
| `list_appliances` | Every appliance PlugPence knows, optionally by category |
| `appliance_info` | Typical power, typical use, cost per use and a money-saving tip |
| `energy_price` | The price per kWh being used, its dates, and the next known change |

All tools are **read-only** and optionally take `watts` (your appliance's power) and `price_per_kwh` (your unit rate in pence). Each returns both a plain-text answer and structured JSON (`structuredContent`).

## How it works

```mermaid
flowchart LR
    U[Browser<br/>React + Vite] --> C[src/core<br/>appliances Β· prices Β· calc]
    A[AI assistant<br/>Claude Β· Cursor] -->|POST /mcp<br/>JSON-RPC| F[Netlify Function<br/>MCP server]
    F --> C
```

The website and the MCP server share the **same calculation code** (`src/core`), so they always give identical answers.

**The maths:** cost = power (kW) Γ— hours Γ— price per kWh. A 3,000 W kettle running for 3 minutes uses 0.15 kWh, which at 26.32p per kWh is about 3.9p. Washing machines, dishwashers and dryers are worked out per load instead.

**The MCP server** is written from the [MCP specification](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports) with **no dependencies**. It is a stateless Streamable HTTP endpoint that:
- answers JSON-RPC requests (`initialize`, `ping`, `tools/list`, `tools/call`) with a single JSON response
- returns `202 Accepted` for notifications and `405` for `GET` (no server-sent event stream)
- negotiates protocol versions `2025-11-25`, `2025-06-18` and `2025-03-26`, and rejects unsupported `MCP-Protocol-Version` headers
- validates the `Origin` header (DNS-rebinding protection) and limits request size
- returns bad input as a tool error (`isError: true`) so the AI can correct itself and retry

## Prices

By default PlugPence uses the [Ofgem energy price cap](https://www.ofgem.gov.uk/information-consumers/energy-advice-households/energy-price-cap): the GB average electricity unit rate for Direct Debit customers on a standard variable tariff.

| Period | Unit rate | Standing charge |
| --- | --- | --- |
| 1 Oct – 31 Dec 2026 | 26.32p per kWh | 54.83p per day |
| 1 Jan – 31 Mar 2027 | 32.69p per kWh | 54.77p per day |

The standing charge is paid daily whatever you use, so it isn't part of an appliance's running cost. To add a new quarter, add a row to [`src/core/prices.js`](src/core/prices.js).

**Typical, not exact:** appliance figures are typical values. Real appliances vary, so enter your own watts and unit rate for exact costs.

## Project structure

```
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/              # Shared, pure logic: appliances, prices, calculations
β”‚   β”œβ”€β”€ components/        # React UI: calculators, price bar, Use with AI
β”‚   └── App.jsx
β”œβ”€β”€ netlify/
β”‚   β”œβ”€β”€ functions/mcp.mjs  # MCP endpoint at /mcp
β”‚   └── lib/               # MCP protocol handling and tool definitions
β”œβ”€β”€ tests/                 # node:test suites (calculations + MCP protocol)
└── netlify.toml
```

## Run locally

Requires Node 20+ (22 recommended).

```bash
git clone https://github.com/mynk4121/PlugPence.git
cd PlugPence
npm install
npm run dev            # website only, at http://localhost:5173
npx netlify dev        # website + MCP server, at http://localhost:8888 (MCP: /mcp)
npm test               # 27 tests
```

Try the local MCP server with the MCP Inspector (`npx @modelcontextprotocol/inspector`), using the Streamable HTTP transport and the URL `http://localhost:8888/mcp`.

## Deploy

Import this repository in Netlify and click Deploy. `netlify.toml` sets the build, the functions folder and security headers. There are no environment variables to set (optionally, `MCP_ALLOWED_ORIGINS` adds extra browser origins allowed to call `/mcp`).

## Contributing

Contributions are welcome, especially new appliances. See [CONTRIBUTING.md](CONTRIBUTING.md) for a 3-line guide, and the
[good first issues](https://github.com/mynk4121/PlugPence/labels/good%20first%20issue) to get started.

## License

[MIT](LICENSE). Price data: Ofgem energy price cap.

---

<p align="center"><strong>If PlugPence saved you money, a ⭐ helps others find it.</strong></p>