ratio-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
ratio-mcp
An MCP server that lets an AI assistant check on a Ratio EV charger and start or stop a charge session. It talks to the same cloud API as the Ratio mobile app, through the aioratio library. It's built for one person with one Ratio account.
Unofficial. Not affiliated with or endorsed by Ratio. The cloud API is reverse-engineered from the mobile app and can change or break without notice.
Start and stop control a real charger connected to your car and your mains supply. Anyone who can call this server can do that, so keep the secret private and think about which assistants you connect.
Writes are limited to start and stop. There are no tools for changing settings, firmware, vehicles or OCPP.
Requirements
Python 3.11+
A Ratio account (email and password)
For remote use: an HTTPS reverse proxy or tunnel in front of the server
Related MCP server: homey-mcp
Install
ratio-mcp is not on PyPI yet. Install from git:
pip install git+https://github.com/aaearon/ratio-mcp
# or run without installing:
uvx --from git+https://github.com/aaearon/ratio-mcp ratio-mcpQuick start: stdio (Claude Desktop, Claude Code)
The client starts the server itself, so no secret or port is needed. For Claude Desktop, add this to claude_desktop_config.json:
{
"mcpServers": {
"ratio": {
"command": "uvx",
"args": ["--from", "git+https://github.com/aaearon/ratio-mcp", "ratio-mcp"],
"env": {
"RATIO_EMAIL": "you@example.com",
"RATIO_PASSWORD": "your-ratio-password"
}
}
}
}If you installed with pip, use "command": "ratio-mcp" and drop args. For Claude Code:
claude mcp add ratio -e RATIO_EMAIL=you@example.com -e RATIO_PASSWORD=your-ratio-password -- ratio-mcpQuick start: HTTP
Use this for claude.ai, ChatGPT and other remote clients.
export RATIO_EMAIL=you@example.com
export RATIO_PASSWORD=your-ratio-password
export RATIO_MCP_SECRET=$(openssl rand -hex 32)
export RATIO_MCP_ALLOWED_HOSTS=ratio.example.com # the hostname clients use
ratio-mcp streamable-httpThis serves /mcp on 127.0.0.1:8000. Put an HTTPS reverse proxy in front and forward ratio.example.com to it.
With Docker (the image listens on 0.0.0.0:8000 and keeps tokens in /data):
docker build -t ratio-mcp .
docker run -d -p 127.0.0.1:8000:8000 -v ratio-data:/data \
-e RATIO_EMAIL -e RATIO_PASSWORD -e RATIO_MCP_SECRET -e RATIO_MCP_ALLOWED_HOSTS \
ratio-mcpIn a Docker --env-file, don't quote values. The quotes become part of the secret.
Configuration
All settings are environment variables. .env.example has the full list.
Variable | Required | Default | Meaning |
| yes | Ratio account credentials | |
| no |
| Where refreshed tokens are cached (file mode 0600) |
| HTTP only | Bearer secret. At least 32 characters from | |
| no |
| HTTP bind address. Anything else exposes the server to the network |
| no |
| HTTP port |
| behind a proxy | loopback only | Comma-separated |
| no | off |
|
| no | Free text added to the server instructions and to the start/stop tool descriptions. Use it to tell the assistant that something else (Home Assistant, an OCPP backend) also controls the charger |
ratio-mcp [stdio | streamable-http] selects the transport (default stdio); --help prints usage. python -m ratio_mcp works too.
Connecting clients
All of these need the HTTP setup above, reachable over HTTPS.
claude.ai. Add a custom connector with URL https://<host>/mcp, authentication set to "No sign-in", and the request header Authorization: Bearer <secret>.
Codex and ChatGPT desktop. Add a custom MCP server with URL https://<host>/mcp and a bearer token read from an environment variable holding the secret. In Codex that is bearer_token_env_var in the server's entry in config.toml. Don't commit the secret.
ChatGPT web and mobile. These can't send a custom Authorization header to an arbitrary URL. OpenAI's Secure MCP Tunnel works around that: run its tunnel-client next to the server (same Docker network, pointing at http://ratio-mcp:8000/mcp) and configure it to add Authorization: Bearer <secret> to forwarded requests. Add ratio-mcp:8000 to RATIO_MCP_ALLOWED_HOSTS. An example docker-compose.yml:
services:
ratio-mcp:
build: .
command: ["python", "-m", "ratio_mcp", "streamable-http"]
env_file: .env # RATIO_EMAIL, RATIO_PASSWORD, RATIO_MCP_SECRET (unquoted)
environment:
RATIO_MCP_ALLOWED_HOSTS: "ratio-mcp:8000"
volumes:
- ratio-data:/data
tunnel:
image: ghcr.io/openai/tunnel-client
depends_on: [ratio-mcp]
environment:
MCP_SERVER_URL: http://ratio-mcp:8000/mcp
MCP_EXTRA_HEADERS: "Authorization: file:/run/secrets/ratio_mcp_bearer"
MCP_OAUTH_DISCOVERY: disabled
command: ["--control-plane.api-key=file:/run/secrets/openai_tunnel_api_key"]
secrets:
- ratio_mcp_bearer
- openai_tunnel_api_key
secrets:
ratio_mcp_bearer:
file: ./secrets/ratio_mcp_bearer # one line: Bearer <secret>
openai_tunnel_api_key:
file: ./secrets/openai_tunnel_api_key
volumes:
ratio-data:The server reads its secret from RATIO_MCP_SECRET, not from a file. The ratio_mcp_bearer file holds the full header value, Bearer <secret>. The tunnel-client options are OpenAI's and may change, so check their current documentation. In ChatGPT, set the connector's connection to Tunnel and authentication to none.
Tools
serial is optional when your account has one charger. With more than one, the tool returns an error listing the serials.
Tool | Type | What it does |
| read | Serial numbers and cloud connection state |
| read | Charging state, power in watts, connected vehicle, whether start/stop is allowed, firmware update status |
| read | Vehicles on the account (IDs usable with |
| read | User, solar and schedule settings. A section that fails is omitted and listed under |
| read | Firmware versions, connection and backend state. SSID, IP addresses, server URLs and controller serials are left out |
| read | One page of past sessions, newest first. Optional |
| write | Starts a session; optional |
| write | Stops the active session |
A write sends the command once, never retries it, then polls for up to 10 seconds. The result's outcome is one of:
confirmed: the new state was seen. Something else can still change it afterwards.unconfirmed: the command may have been sent but the change wasn't seen. Checkget_charger_statusbefore trying again.already_stopped:stop_chargingfound no active session and sent nothing.refused:start_chargingwasn't allowed by the charger and sent nothing.
If Home Assistant, an OCPP backend or an automation also drives the charger, it can undo a command right after confirmed. Set RATIO_MCP_CONTROL_WARNING so the assistant knows.
Security
In HTTP mode every request to /mcp needs Authorization: Bearer <secret>. Anything else, including a wrong secret, another path or another auth scheme, gets a bare 404 with no WWW-Authenticate header, so clients don't start OAuth discovery. The server binds to loopback by default, validates Host and Origin headers, and has no TLS of its own, so serve it only behind an HTTPS proxy.
There are no per-user permissions: whoever has the secret controls the charger. To rotate it, change RATIO_MCP_SECRET, restart, and update every client. Your Ratio password sits in the server's environment and tokens in RATIO_TOKEN_PATH, so protect both.
Outbound traffic is limited to the Ratio API and AWS Cognito over HTTPS, without following redirects. Errors returned to the client are generic (retry later, re-auth needed, unreachable, internal error, an HTTP status, or a validation message such as unknown charger serial); tokens, URLs and response bodies are never included. Known gaps: DNS rebinding and IP-literal hosts on the outbound allow-list.
Run a single worker; the client, token file and cache are per process. To report a vulnerability, see SECURITY.md.
Development
python3 -m venv .venv
.venv/bin/pip install -e . --group dev # needs pip 25.1+, or: uv pip install -e . --group dev
.venv/bin/pytest -q
.venv/bin/ruff check . && .venv/bin/ruff format --check . && .venv/bin/mypyRATIO_LIVE=1 RATIO_EMAIL=... RATIO_PASSWORD=... PYTHONPATH=src .venv/bin/python3 scripts/live_verify.py runs a read-only check against a real account and prints key names and shapes only. Contributor conventions are in CLAUDE.md.
License
MIT. See LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Control your Tesla from your AI assistant - climate, charging, access, and security.
AI for your car: check charge, start climate, lock/unlock, open trunk via Tesla Fleet API. OAuth.
Home energy for AI assistants: live Power flow, Energy history, solar forecast, and device control.
Unofficial integration! ## ✨ Key Features ### 💰 Financial Intelligence - **Smart Charging Cost An…
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceEnables AI assistants to interact with EV charging infrastructure through OCHP (Open Clearing House Protocol) services.Apache 2.0
- AlicenseAqualityCmaintenanceEnables AI assistants to control a Homey Pro smart home hub, create automation flows from natural language, and query device and energy history.3610 npmMIT
- AlicenseAqualityDmaintenanceEnables AI agents to monitor and control Orbis Viaris EV chargers over the local network, including live power status, charging schedules, history, and power limits, with no cloud dependency.129 npmMIT
- AlicenseAqualityBmaintenanceEnables controlling Zaptec EV chargers through natural language, including checking charging status, viewing charge history with cost, pausing and resuming sessions, and setting available current.62MIT