subaru-mcp
# subaru-mcp
An [MCP](https://modelcontextprotocol.io) server that lets an AI assistant read,
and carefully control, one Subaru through MySubaru Connected Services. It is
built on [`subarulink`](https://github.com/G-Two/subarulink) and
[FastMCP](https://gofastmcp.com).
- **Reads by default.** Fuel, odometer, tires, doors, locks, location,
maintenance and more, from the copy cached on Subaru's servers. The car is
not woken.
- **Wakes are rationed.** Asking the car for fresh data drains its 12V battery,
so it sits behind a budget.
- **Controls are opt-in.** Lock, unlock, remote start and the rest do not exist
until you turn them on, and unlock needs a second flag.
- **Never open to the internet without sign-in.** Over HTTP, one GitHub account
is allowed and nothing else.
> **Unofficial, and it acts on a real car.** This project is not affiliated
> with or endorsed by Subaru. Subaru publishes no API, so it can break without
> notice, and using it may be against the MySubaru terms. It can unlock doors
> and start an engine: read [Controls](#controls-off-by-default) before
> enabling them. You use it at your own risk.
## Status
Built for and run against one car: a 2026 Outback (g4 telematics, USA,
Companion+ plan).
| | |
|---|---|
| Run live | Every read tool, `refresh_status`, `remote_start` and `remote_stop` (both confirmed by the car). HTTP mode through Tailscale Funnel, from the Claude apps and from Grok Bot. |
| Mocks only so far | `lock`, `unlock`, `horn`, `lights`, `save_climate_preset`, `delete_climate_preset`. `locate` uses the same wake as `refresh_status` but has not been called live. |
| Untested | Any other model, year or country. Other cars `subarulink` supports should work for reads. Electric-vehicle charging is not exposed. |
An account with more than one vehicle is refused: no tool takes or returns a VIN.
## Requirements
- Linux (or WSL) with Python 3.14 and [`uv`](https://docs.astral.sh/uv/).
- A MySubaru account with one vehicle. Remote commands and waking the car need
a plan with remote services (Companion+) and the account PIN.
- Optional: the [1Password CLI](https://developer.1password.com/docs/cli/) for
secrets. For HTTP mode: a GitHub account and a tunnel that provides public
HTTPS, such as Tailscale Funnel.
## Setup
```sh
git clone https://github.com/thatapplefreak/subaru-mcp
cd subaru-mcp
uv sync
```
### 1. Secrets
The server needs `SUBARU_USERNAME`, `SUBARU_PASSWORD` and `SUBARU_PIN` when it
first connects. The recommended home for them is 1Password, fetched with
`op read` through a **service account** so the server can start unattended.
Copy [`deploy/secrets.env.example`](deploy/secrets.env.example) to
`~/.config/subaru-mcp/secrets.env` (or the path in `SUBARU_MCP_ENV_FILE`). It
holds the service account token and references, never the MySubaru values:
```sh
OP_SERVICE_ACCOUNT_TOKEN=ops_...
SUBARU_USERNAME=op://Automation/MySubaru/username
SUBARU_PASSWORD=op://Automation/MySubaru/password
SUBARU_PIN=op://Automation/MySubaru/pin
```
The file must be mode `0600`, owned by you, and outside any git repository, or
the server refuses to read it. The token is passed to `op` through its
environment, never on the command line.
One-time 1Password setup:
1. Put the MySubaru login in a vault a service account can read. Service
accounts cannot read Private/Personal vaults, so use a dedicated one.
2. Create a service account at 1password.com (Developer > Service Accounts)
with **read-only** access to that vault only.
3. Paste its token into `secrets.env` and fix the references if your names differ.
Other ways to supply the values:
- Variables already in the process environment win over the file, so
`op run --env-file <refs> -- uv run subaru-mcp` also works.
- Plain values instead of `op://` references work too, without 1Password.
`SUBARU_PIN` is optional. Without it cached reads work; waking the car and
commands do not.
### 2. Log in once (2FA)
```sh
uv run subaru-mcp-login
```
Interactive. It creates a device ID in `~/.local/state/subaru-mcp/device_id`
(mode `0600`), logs in, walks through MySubaru's emailed or texted code, and
prints what the account supports (telematics generation, remote services,
remote engine start). It sends nothing to the car and does not test the PIN,
because Subaru's PIN check is a locate command that wakes the car.
Keep the device ID file. A new one forces 2FA again.
### 3. Use it locally (stdio)
`.mcp.json` registers the stdio server as `subaru` for Claude Code: start
Claude Code in this directory and approve the server. Any other MCP client
that launches a command can run `uv run subaru-mcp` the same way.
### 4. Use it remotely (HTTP mode)
```
MCP client ──https──> tunnel (Tailscale Funnel) ──http──> 127.0.0.1:8765 (this server)
└─ sign-in ──> GitHub OAuth app
```
The server always listens on `127.0.0.1`; that is not configurable. It refuses
to start in HTTP mode unless the public URL, the allowed GitHub account and the
OAuth app secrets are all present.
**Who gets in.** One GitHub account, matched by numeric ID *and* login, checked
at sign-in and again on every request. A signed-in client can only be sent back
to an address on a fixed list (Claude's callback URLs and loopback ports by
default), so a crafted sign-in link cannot deliver a token elsewhere.
Settings go in `~/.config/subaru-mcp/server.env`, copied from
[`deploy/server.env.example`](deploy/server.env.example). No secrets belong there.
| Variable | |
|---|---|
| `SUBARU_MCP_BASE_URL` | The tunnel's public URL, `https://<machine>.<tailnet>.ts.net`. No path. |
| `SUBARU_MCP_PORT` | Loopback port. Default `8765`. |
| `SUBARU_MCP_GITHUB_LOGIN`, `SUBARU_MCP_GITHUB_USER_ID` | The allowed account. `gh api user --jq .id` prints the ID. |
Secrets (in `secrets.env`, as `op://` references or plain values):
`SUBARU_MCP_GITHUB_CLIENT_ID`, `SUBARU_MCP_GITHUB_CLIENT_SECRET`. The key that
signs this server's own tokens is generated on first start in
`~/.local/state/subaru-mcp/oauth_signing_key`.
Steps:
1. **GitHub OAuth app.** github.com > Settings > Developer settings > OAuth Apps >
New. Homepage URL: the base URL. Authorization callback URL:
`<base URL>/auth/callback`. Store the client ID and a new client secret
where the two references point.
2. **Service.** [`deploy/subaru-mcp.service`](deploy/subaru-mcp.service) is a
systemd user unit. It assumes the repository is at `~/code/subaru-mcp` and
that `op` is on the `PATH` it sets; edit both if yours differ. Link it, so
the copy in the repository stays the one in use, and start it:
```sh
systemctl --user link ~/code/subaru-mcp/deploy/subaru-mcp.service
systemctl --user enable --now subaru-mcp
curl -i -X POST http://127.0.0.1:8765/mcp # must answer 401
```
After editing the unit file: `systemctl --user daemon-reload && systemctl --user restart subaru-mcp`.
After changing the code or `server.env`: `systemctl --user restart subaru-mcp`.
Logs: `journalctl --user -u subaru-mcp -f`.
3. **Tunnel.** With Tailscale: enable HTTPS certificates and Funnel for the
machine in the admin console, then run `tailscale funnel --bg 8765` (on
Windows itself if the server runs in WSL with mirrored networking).
Do this last: it is the step that makes the server reachable from the internet.
4. **Client.** In Claude: Settings > Connectors > Add custom connector, URL
`<base URL>/mcp`. Sign in with GitHub when prompted.
To cut off access at once: `tailscale funnel reset`, or stop the service.
Expect internet scanners to probe the public URL within hours. They get `401`
or `404`.
#### Other clients (Grok Bot and others)
Who may sign in never changes: the one GitHub account. What differs per client
is the address sign-in returns to, and only listed addresses are accepted.
| Setting (in `server.env`) | Effect |
|---|---|
| `SUBARU_MCP_ALLOW_GROKBOT=true` | Accepts Grok Bot's two callback addresses. |
| `SUBARU_MCP_EXTRA_REDIRECT_URIS=` | Exact callback URLs for any other client, comma-separated. Wildcards, credentials and non-local `http` are refused at start. |
Restart the service after changing either.
Grok Bot: add a custom MCP server with the same URL, `<base URL>/mcp`, then sign
in with GitHub when it asks. Three things to know:
- xAI publishes no list of Grok Bot's callback addresses. The two used here come
from Grok Bot forum threads. If sign-in is refused with a "redirect URI is not
allowed" message, put the address from that message in
`SUBARU_MCP_EXTRA_REDIRECT_URIS`.
- Finish the sign-in within about 15 minutes of starting it, or Grok Bot rejects
the result as expired.
- Whether Grok Bot asks for confirmation before running a tool marked
destructive has not been checked. Find out before enabling controls on a
server Grok Bot can reach; the flags apply to every connected client.
## Tools
| Tool | Wakes the car? | Notes |
|---|---|---|
| `status` | No | Full cached snapshot. The default for every question. |
| `fuel`, `tire_pressure`, `odometer`, `lock_status` | No | Slices of the same snapshot. |
| `list_climate_presets` | No | `UNSUPPORTED` without remote engine start. |
| `capabilities` | No | What the car and plan support. |
| `maintenance` | No | Next services with miles remaining, and dealer service history. |
| `software_updates` | No | Over-the-air update campaigns and install status. |
| `remote_activity` | No | This month's remote actions on the car, from any device. |
| `valet_and_alerts` | No | Valet mode, boundary, speed and curfew alert settings. |
| `refresh_status`, `locate` | **Yes** | Drain the 12V battery. Share one wake budget. |
Every snapshot carries `data_freshness`: when the car last reported and how old
that is. Errors are `[CODE] message`, for example `[UNSUPPORTED]`,
`[WAKE_BUDGET]`, `[DEVICE_2FA_REQUIRED]`, `[AUTH_FAILURE]`.
No tool takes or returns a VIN.
### Controls (off by default)
| Flag | Effect |
|---|---|
| `SUBARU_ENABLE_CONTROLS=true` | Adds `lock`, `remote_start`, `remote_stop`, `horn`, `lights`, `save_climate_preset`, `delete_climate_preset`. |
| `SUBARU_ENABLE_UNLOCK=true` | With the flag above, also adds `unlock` (all doors, driver's door, or tailgate). Does nothing alone. |
Only the literal word `true` enables a flag. Without it the tools are not
registered at all, so clients cannot see or call them. The flags apply to every
client connected to the server.
- Every control is marked destructive, which asks clients to confirm before
running it. Whether a client does is up to that client: check yours.
- Success is reported only when the car confirms. Otherwise the result is
`[UNCONFIRMED]` and the command is never retried.
- `remote_start(preset_name)` needs an exact preset name (case ignored). On a
mismatch nothing is sent and the real names are listed.
- **2026 Outback quirk:** remote start can start the engine while MySubaru
reports failure. The error says so and tells the client not to resend. Treat
`[UNCONFIRMED]` as "the engine may be running".
- **Never remote start in an enclosed space.** If you automate it, do not let
the automation close a garage door after a start it could not confirm.
- Commands have their own budget: `SUBARU_COMMAND_COOLDOWN_SECONDS` (default 30,
minimum 10) and `SUBARU_COMMAND_DAILY_CAP` (default 20), logged in
`~/.local/state/subaru-mcp/command_log.json`.
- Preset edits change the MySubaru account only. They do not wake the car. Seat
cooling can only be set in the MySubaru app.
- Not implemented: valet mode, boundary/speed/curfew alerts, send-destination and
trip logging. `subarulink` has no code for them and their request formats are
unverified. See [`docs/mysubaru-api.md`](docs/mysubaru-api.md).
### Wake budget
Defaults: at most one wake every 2 hours and 3 per rolling 24 hours, stored in
`~/.local/state/subaru-mcp/wake_log.json` so restarts do not reset it. An attempt
is charged when it is sent, even if the car never answers.
| Variable | Default | |
|---|---|---|
| `SUBARU_WAKE_COOLDOWN_MINUTES` | `120` | Minimum 5. |
| `SUBARU_WAKE_DAILY_CAP` | `3` | `0` disables waking. |
## Safety properties
- Exception text from `subarulink` is never forwarded: it can contain raw API
responses, the VIN and the PIN. Clients get a fixed message per error code.
- Every log record is scrubbed (VIN, PIN, credentials, tokens, cookies), and
`subarulink` logging is held at WARNING because its DEBUG output prints the PIN.
- Each tool call and its outcome is logged, without arguments, as an audit trail.
- A rejected password is not retried until restart, to avoid locking the account.
- 2FA only happens in `subaru-mcp-login`, never inside a tool call.
- There is no generic "send this request" tool, and extra reads go through a
fixed allowlist of GET paths.
To report a security problem, see [`SECURITY.md`](SECURITY.md).
## Development
```sh
uv run subaru-mcp # stdio
uv run subaru-mcp --transport http # loopback HTTP; needs the settings above
uv run pytest # mocks only; a fixture blocks real network connections
uv run ruff check . && uv run ruff format --check .
```
`tests/test_subarulink_contract.py` runs the real `subarulink` package against
canned JSON and asserts that a cached `status` read requests read endpoints only.
`subarulink` is pinned below 0.8 because the extra reads use its private
connection object; that test fails if an upgrade changes it.
Never run live lock, unlock, remote start, horn or lights from tests or
automation. Live smoke tests are cached `status` only. In tests the fake
controller fails any test that reaches a command without opting in.
Never put a VIN, a login, a PIN, a token or a cookie in an issue, a pull
request or a test. Test data uses made-up values.
## API notes
[`docs/mysubaru-api.md`](docs/mysubaru-api.md) records what the MySubaru API
returns for a 2026 Outback: feature codes, every endpoint checked, what is not
available, and the command paths.
## g4 caveats
`subarulink` 0.7.21 is the first release with g4 support and upstream says some
g4 behaviour is still being characterized. If Subaru's reply is missing a field
`subarulink` expects, `status` returns what it could read and sets
`data_freshness.partial`.
## Acknowledgements
- [`G-Two/subarulink`](https://github.com/G-Two/subarulink), which does the
real work of talking to MySubaru, and the
[Home Assistant Subaru integration](https://github.com/G-Two/homeassistant-subaru)
issue tracker for 2026 Outback reports.
- [`alex-savin/go-mysubaru`](https://github.com/alex-savin/go-mysubaru) for
endpoint paths.
- [`elderibeiro/subaru-starlink-mcp-grokbot`](https://github.com/elderibeiro/subaru-starlink-mcp-grokbot)
for safety patterns.
Subaru, MySubaru and STARLINK are trademarks of Subaru Corporation.
## License
[MIT](LICENSE).
TDQS
Scored across 13 tools
The aggregate `status` tool overlaps with `fuel`, `odometer`, `tire_pressure`, and `lock_status`, but the descriptions clearly position `status` as the default and the others as targeted cached reads. The two wake actions, `refresh_status` and `locate`, are also clearly distinguished from their cached equivalents.
All names use snake_case and are readable, with most being noun/resource names and a few action names (`list_climate_presets`, `refresh_status`, `locate`). This is mostly predictable, though it is not a strict verb_noun convention throughout.
The 13 tools sit comfortably in the appropriate range and each maps to a distinct vehicle data domain or wake action. The aggregate `status` tool does not make the targeted readers redundant, since they support narrower queries without waking the car.
The server covers a broad read-only surface: fuel, tires, locks, maintenance, software updates, valet mode, alerts, remote activity, and location. However, there are no remote command tools for locking, unlocking, remote start, or climate activation, so capabilities and climate presets can be listed but not acted upon, leaving notable gaps.