shelly-api-mcp
Provides read-only tools for accessing Shelly Cloud energy data, including live power, lifetime energy, and historical consumption with cost, from Shelly devices.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@shelly-api-mcpWhat's the current power usage of my Shelly Pro 3EM?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Why this exists
There is no official MCP for reading your own Shelly device data. The official Shelly MCP
(shelly-api-docs.mcp.shelly.link) is documentation-only and never touches your account, and the
community servers are either DeskAgent plugins or control-focused with no real consumption tooling.
Shelly MCP talks to the Shelly Cloud Control API directly — the same cloud your devices already report to — and exposes read-only consumption tools. No control endpoints are wrapped: it can read your meters, never switch anything.
Related MCP server: Datadis MCP Server
Features
Generic across device families — Gen2 energy meters (
em:N/emdata:N), Gen2 switches & plugs (switch:N/pm1:N), and best-effort Gen1 (meters[]/emeters[]).Never fakes a zero — missing or unparseable readings are flagged as
partialwith warnings instead of being silently summed as0, so a total is never quietly too low.Historical buckets with cost — hourly/daily/monthly consumption and net-energy series, summed across all three phases, with range totals.
Honest about gaps — incomplete ranges report
gaps/partial_bucketsrather than presenting a partial range as whole.Brief response cache to soften the Cloud's ~1 req/s rate limit.
Tools
Tool | What it answers |
| Inventory: id, name, model, generation, mode, online state, local IP. |
| Live electricity draw now (W) — total + per-phase / per-channel. |
| Lifetime energy counters (kWh) — consumed, returned, per-phase. |
| One-shot per-device summary: name, model, live W, lifetime kWh, meter temp. |
| Historical grid consumption over time with cost. |
| Historical net energy (import − export); |
| Raw, complete |
device_id is optional on most tools (omit to cover all devices); it is required on
get_device_status. History tools require an explicit id when the account has more than one device.
For date_range use day | week | month | year | custom (custom requires both
date_from and date_to as YYYY-MM-DD HH:MM:SS). Only 3-phase meters (em-3p, e.g. Shelly Pro
3EM) are supported by the history tools.
Prerequisites
A Shelly Cloud account with at least one device.
Your Cloud Control API auth key and server host, both from the Shelly app/web: Settings → Authorization Cloud Key (the key, e.g.
MWE...) and the server it lists (e.g.shelly-NN-eu.shelly.cloud).Docker (recommended) or Python 3.10+.
Configuration
Configuration is entirely via environment variables:
Variable | Required | Default | Description |
| ✅ | — | Cloud server host or URL (bare host is fine; |
| ✅ | — | Cloud Control API auth key. |
|
| HTTP timeout, seconds. | |
|
| Response cache TTL, seconds. | |
|
| Port the server listens on. | |
| (UTC) | Timezone for named date ranges — see the note below. |
Put the secrets in a secret.env file (git-ignored) for Docker Compose:
SHELLY_SERVER=shelly-NN-eu.shelly.cloud
SHELLY_AUTH_KEY=your-cloud-control-api-keyNamed date ranges (day/week/…) are computed in local time, then read by the cloud in the
device's timezone. Set TZ to your device's zone (e.g. TZ=Europe/Paris) or ranges shift by
the UTC offset. With Docker Compose, TZ defaults to Europe/Paris and is overridable.
Running
Docker Compose (recommended)
docker compose up -d --buildThe MCP endpoint is then available at http://localhost:3000/mcp. Override the host port with
HOST_PORT and the timezone with TZ:
HOST_PORT=8080 TZ=Europe/Berlin docker compose up -d --buildDocker
docker build -t shelly-api-mcp .
docker run --rm -p 3000:3000 --env-file secret.env -e TZ=Europe/Paris shelly-api-mcpLocal (Python)
pip install -r requirements.txt
export SHELLY_SERVER=shelly-NN-eu.shelly.cloud
export SHELLY_AUTH_KEY=your-cloud-control-api-key
python server.pyConnecting an MCP client
The server speaks streamable HTTP. Point any MCP client at the /mcp endpoint:
{
"mcpServers": {
"shelly": {
"url": "http://localhost:3000/mcp"
}
}
}How it works
MCP client ──HTTP /mcp──> Shelly MCP (FastMCP) ──> Shelly Cloud Control API
POST /interface/device/list
POST /device/all_status
POST /device/status
GET /v2/statistics/{power-consumption,net-energy}/em-3pEnergy counters arrive in Wh on the wire and are surfaced in kWh. The Cloud Control API is rate-limited (~1 req/s); the short response cache is the only client-side mitigation. The server is strictly read-only — no control endpoints are wrapped.
Development
pip install -r requirements.txt pytest
pytest -q # 59 network-free unit tests over the parsing internals
python live_smoke.py # paced end-to-end smoke test against the real cloud (needs creds)live_smoke.py exercises every tool and underlying endpoint against the live API, paced to respect
the rate limit, and exits non-zero if any call fails.
Related
euenergy-mcp — an MCP server exposing European day-ahead electricity prices (ENTSO-E, ~41 bidding zones). Pairs well with this server: your own consumption here, market prices there.
Notes & limitations
Read-only by design — no switching, no configuration writes.
History tools cover 3-phase meters (
em-3p) only; other families return a structured error.Cost is reported in the account's tariff currency.
Not affiliated with Allterco / Shelly.
This server cannot be deployed
Maintenance
Related MCP Connectors
Real-time electricity prices for AI agents. 40+ countries, 100+ zones. No auth required.
Real-time electricity price signals for AI agents. Spot prices, cheapest hours, and contract recommendations. 31 countries across Europe and Oceania. No authentication required.
Read-only electricity, gas, and weather data with structured provenance and units.
Protocol-native energy infrastructure orchestration for AI data centers. Provides 46 MCP tools across 8 grid protocols (IEC-61850, DNP3, Modbus, OCPP, OpenADR, IEEE 2030.5, IEC 60870-5-104, ICCP) with 5 core API primitives: connect, dispatch, settle, comply, and intel. Enables AI agents to programmatically interact with substations, grid interfaces, and energy assets for real-time workload-grid coordination.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI-powered analysis and prediction of household energy consumption through machine learning models, providing historical consumption breakdowns, price queries from Spanish electricity markets, and personalized energy optimization recommendations.-
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to access and analyze Spanish electricity consumption data via the Datadis API, providing tools for supply management, consumption analysis, anomaly detection, and executive reporting.MIT
- AlicenseAqualityBmaintenanceEnables LLM agents to query live data from Anker Solix solar systems (Solarbank, expansion batteries, Smartmeter) via natural language, such as current solar production or battery state of charge.121MIT
- FlicenseNot gradedqualityBmaintenanceProvides real-time electricity prices, cheapest hours, and contract comparison for 40+ countries, enabling AI agents to make energy-aware decisions.4-