Skip to main content
Glama
README.md
# Garage MCP

Ask Claude about your car: battery, range, charging, odometer, tire pressure and location.

Garage MCP is a self-hosted, read-only MCP server that works with Tesla vehicles through the official
Fleet API. It never wakes the car and cannot send commands. It is an independent project, not affiliated
with or endorsed by Tesla.

## What you need
- A Railway account
- A Tesla account with a vehicle, a verified email and multi-factor authentication
- A payment method on your Tesla developer account (see [Cost](#cost))
- Claude, or another MCP client that runs on your computer and supports OAuth

## Set up
1. Deploy the template on Railway. There is nothing you have to fill in yet.
2. Open `https://<your-domain>/`. This setup page shows the exact values for the next steps and ticks
   them off as you go.
3. At https://developer.tesla.com, create an app:
   - Name: anything without the word "Tesla" or a model name
   - Grant type: Authorization Code and Machine-to-Machine
   - Allowed origin: `https://<your-domain>`
   - Redirect URI: `https://<your-domain>/auth/callback`
   - Scopes: Vehicle Information, and Vehicle Location if you want the location tool
   - Add a payment method
4. In Railway, open the service's **Variables**, set `TESLA_CLIENT_ID` and `TESLA_CLIENT_SECRET`, and deploy
   the change. The server then registers your domain with Tesla by itself.
5. In Claude: Settings -> Connectors -> Add custom connector, URL `https://<your-domain>/mcp`
6. Click Connect. Enter your `SETUP_SECRET` (from the Railway variables) and sign in to Tesla.

You need both every time you add or reconnect the connector, not each time you use it. The first Tesla
account to connect owns the server. A new connection takes the setup code and a sign-in to that same account,
so a stranger who finds your URL can't get in.

## Variables

| Variable | Value |
|---|---|
| `SETUP_SECRET` | random, 32+ characters. The template generates it |
| `TESLA_CLIENT_ID` | from your Tesla app |
| `TESLA_CLIENT_SECRET` | from your Tesla app |
| `TESLA_API_BASE` | only outside North America: your region's Fleet API URL |
| `TESLA_CACHE_SECONDS` | optional, default 300, minimum 60 |
| `TESLA_DOMAIN` | only if you use a custom domain |

## Tools
- `list_vehicles`
- `get_vehicle_status`
- `get_vehicle_location`

If the car is asleep you get the last reading and its time. Wake the car in the Tesla app, wait a minute and
ask again.

## Troubleshooting
- **Step 3 on the setup page stays unticked:** read the deploy logs. Check the client ID, secret, allowed
  origin and region, then redeploy. A successful run logs `Verified: Tesla holds the same public key`.
- **"Redirect URI" error when signing in:** it must match the setup page exactly.
- **Location is refused:** add the Vehicle Location scope to your Tesla app, then connect again.
- **Changed your domain:** update the Tesla app, then redeploy.
- **Registering by hand:** `TESLA_CLIENT_ID=... TESLA_CLIENT_SECRET=... python register.py <your-domain>`

## Cost
Tesla bills your developer account per request, after a monthly discount, and failed requests below
HTTP 500 count too. Check current prices and set a billing limit on developer.tesla.com. Readings are cached
for 5 minutes, "the car is asleep" for 1 minute, and the vehicle list for an hour. The cache is in memory, so
it resets on redeploy. Railway hosting is billed separately.

## Your data
- Your server talks to Tesla and to the MCP client you connect. It sends nothing to the author of this project.
- Whatever a tool returns, including location, goes to your MCP client and the AI provider behind it.
- Tesla tokens and the last readings (including location) are stored unencrypted on your volume, readable by
  the service only. Anyone with access to your Railway project can read them and your variables.
- To remove everything, delete the Railway project and remove the app's access in your Tesla account.

## Security
- Claude connects with OAuth. Access tokens last an hour, refresh tokens rotate, and only their hashes are
  stored. Only Claude's callback address and Claude Code's localhost callback can receive access.
- Every new connection needs `SETUP_SECRET` and a Tesla sign-in, so being tricked into clicking through
  someone else's sign-in link isn't enough to share your car. Never enter the code on a page you didn't open
  from your own connector setup.
- The setup page at `/` is public. It shows your URLs and setup progress, never secrets or vehicle data.
- To switch Tesla accounts, tick **Switch to a different Tesla account** on the connect page. This ends
  existing connections.
- To disconnect everything but keep the server, remove the app's access in your Tesla account and delete
  `tokens.json`, `oauth.json`, `owner.json` and `snapshot-*.json` from the volume.

## Deploy without the template
1. Railway -> New Project -> Deploy from GitHub repo.
2. Add a **volume** with mount path `/data`. The server refuses to start on Railway without it.
3. Add `SETUP_SECRET`. Generate one with `python -c "import secrets; print(secrets.token_urlsafe(32))"`.
4. Settings -> Networking -> Generate Domain, then follow [Set up](#set-up) from step 2.

## Development
    pip install -r requirements-dev.txt
    ruff check . && ruff format --check . && mypy && python -m pytest

Every pull request also runs Semgrep, a secret scan of the full history and a dependency audit. The
standards any AI assistant working here must follow are in [`CLAUDE.md`](CLAUDE.md).

## License
[MIT](LICENSE)