Skip to content

v0.1.0

Latest

Choose a tag to compare

@cursor cursor released this 22 Oct 19:37
· 7 commits to main since this release
785ddbf

Tesla-GrokBot-Connector v0.1.0

This is the first release. It lets Grok Bot answer questions about your Tesla by reading the official Tesla Fleet API. It runs on your own Grok Bot computer. It is not a website, and it is not a tile in a connector store.

This project is not affiliated with, endorsed by, or sponsored by Tesla, Inc.

Full detail is in the README. The install steps below follow INSTALL.md.

What it is

A read-only connector. Grok Bot starts it as a local command (stdio). There is no public server.

It does not lock or unlock the car, honk, start climate, or start and stop charging. Those actions are not in the program. The only exception is an optional wake: one tool, tesla_wake_and_refresh, can ask Tesla to wake the car so a fresh reading can be taken. You have to pass confirm=true, and a local budget caps how often that can happen.

If the car is asleep, a normal question uses the last saved snapshot. It does not wake the car.

What it can read

  • Your vehicle list. The VIN is masked. The name and model are included when Tesla sends them.
  • Battery level, range, charging state, whether the car is plugged in, and whether it is locked.
  • Climate: inside and outside temperature in Celsius, whether climate is on, and the set points.
  • Location, only if you opt in. The default is a coarse position of about 1 km. Precise coordinates are available only when you ask for them, and they are not saved in the local history.
  • Odometer, in miles. You can also ask for the last 7 days, 30 days, or this week from the saved history.
  • The installed software version, and any pending update fields Tesla sends.
  • A local history of readings, kept on the Grok Bot computer, plus reports: weekly mileage, range trend, a charging summary, and a low-charge check.
  • A local usage and cost estimate for this month, including how much of the wake budget is left. That estimate is not Tesla’s invoice.
  • Charging sessions, only if you opt in. Tesla’s charging-history scope is broader than a read: it is also the scope that can start and stop charging. This connector still does not call charge control. Whether home charging shows up depends on Tesla and is not confirmed in this version.

Distances from Tesla are miles. Temperatures are Celsius. If the account has one car, you do not need to name it.

Safety

  • No charge control and no vehicle commands. The Fleet API client refuses any path other than listing vehicles, reading one vehicle, reading vehicle data, the optional wake, and the optional charging history. The poller cannot wake the car.
  • Wake budget: 3 wakes a day, at least 30 minutes apart, and never more than 3 per minute. You cannot raise the per-minute cap above 3.
  • Sign-in tokens are encrypted (AES-GCM) in a file that only your user can read. The encryption key stays in the environment. It is not written into the token file and it is not stored in git.
  • tesla_usage shows a local cost estimate. Tesla bills data reads and wakes. A light pattern (a poll every couple of hours, a handful of questions, and rare wakes) is often inside Tesla’s monthly discount, but that is an estimate.
  • Set a billing limit of about $10 in the Tesla developer dashboard, and add a card. The dashboard default is $0, which disables the app. Alerts arrive at 80% and 100%. Going over the limit suspends the API.
  • Location and charging history are off until you turn them on and sign in again. The connector never asks for vehicle_cmds or user_data.

Known limit

Tesla rejects a charging-history request that covers more than one year. If you ask for a longer range, this connector splits it into consecutive windows of at most 365 days, up to 10 years, drops duplicate sessions, and returns the newest session first. Leave the dates out to get the last 365 days.

How to install

You install this on the Grok Bot computer, not on your laptop. Keep the client id, client secret, and token key off chat.

1. Prerequisites

  • Python 3.11 or newer, and uv.
  • A Tesla account with a verified email and multi-factor authentication. Sign in to the Tesla mobile app at least once.
  • A Tesla developer application that you own, created at developer.tesla.com (China: developer.tesla.cn). Name it something that does not sound like an official Tesla product, such as “GrokBot Vehicle Bridge”.
  • On that app, enable openid, offline_access, and vehicle_device_data. Add location or charging history only if you have decided to opt in.
  • Redirect URI: http://localhost:8765/callback. Add https://<your-domain>/callback.html as well if you want the paste fallback.
  • A domain where you can publish a public key. One option is GitHub Pages: put an empty .nojekyll file at the site root so Pages will serve /.well-known/, and copy only the public key to .well-known/appspecific/com.tesla.3p.public-key.pem. Whether Tesla accepts a github.io address is not confirmed. If registration fails, use a domain you own.
  • A key pair, generated outside this repository:
scripts/generate-keypair.sh "$HOME/tesla-partner-keys"

Publish the public key only. This connector does not use the private key.

  • In the Tesla developer dashboard, add a payment method and set a billing limit around $10.

2. Get the code

git clone https://github.com/naoiseirwin/Tesla-Grokbot-Connector.git /workspace/tesla-grokbot-connector

Checkout tag v0.1.0 if you want this exact release.

3. Configuration

Write /workspace/.tesla-mcp/config.env (mode 600) with your client id, client secret, and region. Do not put the token key in that file. Hold TESLA_TOKEN_KEY in the environment of the process. Generate a key on a private terminal with tesla-mcp gen-key, and do not paste it into chat.

TESLA_CLIENT_ID=your_client_id_here
TESLA_CLIENT_SECRET=your_client_secret_here
TESLA_REGION=eu

TESLA_REGION is na, eu, or cn. The shape of the file is .env.example.

Optional, both off by default:

TESLA_ENABLE_LOCATION=true
TESLA_ENABLE_CHARGING_HISTORY=true

TESLA_ENABLE_CHARGING_HISTORY requests vehicle_charging_cmds. That scope can start and stop charging at Tesla. This server does not expose those calls. Leave it unset unless you accept that grant.

chmod 700 /workspace/.tesla-mcp
chmod 600 /workspace/.tesla-mcp/config.env

4. Partner registration

Register the domain once for each region where you have a car. The client id and secret come from the environment, not from chat.

export TESLA_CLIENT_ID=...
export TESLA_CLIENT_SECRET=...
export TESLA_REGION=eu
uv run --directory /workspace/tesla-grokbot-connector tesla-mcp register-partner \
  --domain your.domain.example

The command prints an HTTP status and the first line of the public key Tesla stored. It does not print the partner token. A wrong region returns HTTP 421. Details: docs/partner-registration.md.

5. Sign in

uv run --directory /workspace/tesla-grokbot-connector tesla-mcp auth

A browser on that computer opens Tesla’s consent screen. The wizard listens on http://127.0.0.1:8765/callback for five minutes. If Tesla asks for a password or multi-factor authentication, use Take over. Do not paste the redirect URL or the code into chat.

Tokens are saved to /workspace/.tesla-mcp/tokens.json.enc (mode 600), encrypted with TESLA_TOKEN_KEY.

If localhost is not an allowed redirect, host docs/github-pages/callback.html on your domain, set TESLA_REDIRECT_URI to that URL, and run:

uv run --directory /workspace/tesla-grokbot-connector tesla-mcp auth --paste

Paste the code into that terminal, not into chat.

6. Add it to Grok Bot

Do not use Add-connector or the Plugins marketplace. In Grok Bot chat, send:

Add a custom MCP server called tesla that runs: uv run --directory /workspace/tesla-grokbot-connector tesla-mcp

The Bot should repeat the name, command, and args. Click Add it. The process needs TESLA_CLIENT_ID, TESLA_CLIENT_SECRET, and TESLA_TOKEN_KEY in its environment, or it needs to be able to read the client id and secret from /workspace/.tesla-mcp/config.env. The token key stays in the environment.

Field Value
Name tesla
Transport stdio command on the Grok Bot computer
Command uv run --directory /workspace/tesla-grokbot-connector tesla-mcp

Then type @, attach tesla, and ask something like “How charged is the car?” That reads status or the last snapshot. It does not wake the car.

An optional poll, every 1–2 hours, also does not wake the car:

uv run --directory /workspace/tesla-grokbot-connector tesla-mcp poll

More