Tesla MCP Server
A Model Context Protocol (MCP) server for the Tesla Fleet API. Control your Tesla and get vehicle data (location, wake up, list cars) from any MCP-capable AI assistant or agent.
Features
- list_cars — List your vehicles and get IDs for use with other tools
- get_vehicle_location — Current GPS location and Google Maps link (parking monitor style)
- wake_up — Wake a vehicle from sleep
- refresh_vehicles / debug_vehicles — Refresh list and debug info
- HTTP/SSE mode — Host as a web service; each user brings their own Tesla Developer credentials (no server-side secrets required)
- Receive and respond to texts (optional) — With Twilio configured, receive inbound SMS via webhook and use get_recent_texts / send_text so the agent can read and reply to messages
Security
- We never see or store your Tesla password. Sign-in is via Tesla’s OAuth in your browser.
- HTTP mode: Credentials and tokens are stored in memory per session only; not written to disk.
- No sensitive data in logs — We do not log tokens, full session IDs, or API response bodies.
- Before you commit: Run
./check-secrets.shto catch accidental hardcoded secrets.
See SECURITY.md for details and how to report issues.
Quick Start (Hosted — recommended)
Use the server without running anything locally. Each user connects with their own Tesla account.
1. Add the server in your MCP client
- Server URL:
https://tesla-mcp.onrender.com/sse
(Or use your own deployed URL; see Deploy below.)
2. First time: connect your Tesla
- Use a tool (e.g. get_setup_url) — the agent will return a link.
- Open the link and enter your Tesla Developer Client ID and Client Secret.
- Log in with your Tesla account when redirected.
- On the success page, copy the connection URL (e.g.
https://.../sse?token=...). Use that URL as your MCP server URL in your client so reconnects keep you logged in. Keep it private. - If you don’t add that URL, your client may get a new session on each reconnect and ask you to set up again.
Getting Tesla Developer credentials: Create an app at developer.tesla.com. Set the redirect URI to https://YOUR_SERVER_URL/auth/callback (e.g. https://tesla-mcp.onrender.com/auth/callback).
Render: Set Instance count to 1 (Dashboard → your service → Settings) so all requests hit the same server and your session isn’t lost.
Quick Start (Local)
Option A: HTTP server (multi-user, browser auth)
git clone https://github.com/Sara3/Tesla-MCP.git
cd Tesla-MCP
npm install
npm run build
npm run start:http
- Open
http://localhost:3000and follow the setup link to add your Tesla Developer credentials and sign in. - In your MCP client, use Server URL:
http://localhost:3000/sse(for production use HTTPS and setBASE_URL).
Option B: Stdio (single user, .env only)
For a single user with credentials in .env:
# .env
TESLA_CLIENT_ID=...
TESLA_CLIENT_SECRET=...
TESLA_REFRESH_TOKEN=...
npm run build
npm start
Configure your MCP client to run the server command (e.g. node run-mcp.js). Get a refresh token with npm run get-token.
Environment variables
| Variable | Required | Description |
|---|---|---|
| HTTP mode | ||
BASE_URL |
Yes (production) | Public HTTPS URL of your server (e.g. https://tesla-mcp.onrender.com) |
TESLA_CLIENT_ID |
Optional | If set with TESLA_CLIENT_SECRET, users go straight to the Tesla login page (no setup page) |
TESLA_CLIENT_SECRET |
Optional | Server Tesla app secret; use with TESLA_CLIENT_ID |
PORT |
No | Port (default 3000) |
HOST |
No | Bind address (default 0.0.0.0) |
| Stdio mode | ||
TESLA_CLIENT_ID |
Yes | From developer.tesla.com |
TESLA_CLIENT_SECRET |
Yes | From developer portal |
TESLA_REFRESH_TOKEN |
Yes | From npm run get-token |
| SMS (Twilio, HTTP mode only) | ||
TWILIO_ACCOUNT_SID |
Optional | Twilio account SID (enables get_recent_texts / send_text) |
TWILIO_AUTH_TOKEN |
Optional | Twilio auth token |
TWILIO_PHONE_NUMBER |
Optional | Your Twilio phone number (E.164, e.g. +15551234567) |
SMS setup: In the Twilio console, set your phone number’s “A message comes in” webhook to https://YOUR_BASE_URL/webhooks/twilio/sms (e.g. https://tesla-mcp.onrender.com/webhooks/twilio/sms). Inbound messages are stored in memory and returned by get_recent_texts; use send_text to reply.
Never commit .env or keys/. Run ./check-secrets.sh before pushing.
Tools (MCP)
| Tool | Description |
|---|---|
| get_setup_url | Get the URL to set up Tesla Developer credentials |
| get_auth_url | Get the URL to connect your Tesla account (after setup) |
| **li |
Tools 7
list_carsList your vehicles and get IDs for use with other toolsget_vehicle_locationGet current GPS location and Google Maps linkwake_upWake a vehicle from sleepget_setup_urlGet the URL to set up Tesla Developer credentialsget_auth_urlGet the URL to connect your Tesla accountget_recent_textsRetrieve recent SMS messages (requires Twilio)send_textSend an SMS message (requires Twilio)Environment Variables
BASE_URLPublic HTTPS URL of your server for productionTESLA_CLIENT_IDTesla Developer Client IDTESLA_CLIENT_SECRETTesla Developer Client SecretTESLA_REFRESH_TOKENTesla refresh token for Stdio modeTWILIO_ACCOUNT_SIDTwilio account SID for SMS features