Allows control and monitoring of Tesla vehicles via the Tesla Fleet API, including functionality to wake up vehicles and retrieve detailed real-time vehicle information and status.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Tesla MCP ServerWake up my vehicle and show me its current status"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Tesla MCP Server
A Model Context Protocol (MCP) server that connects to the Tesla Fleet API, allowing you to control your Tesla vehicle using Claude and other AI assistants that support MCP.
Features
Wake up vehicles: Wake up your Tesla from sleep mode
Vehicle information: Get detailed information about your Tesla vehicles
Real-time updates: Refresh vehicle data on demand
Debugging tools: Access detailed vehicle information to help with troubleshooting
Requirements
Node.js 18+
pnpm (preferred) or npm
Tesla account with at least one vehicle
Tesla API credentials (Client ID and Client Secret)
Ngrok (for development and registration)
Security Best Practices
This project handles sensitive Tesla API credentials. Please follow these security practices:
Never commit credentials: The
.gitignorefile excludes.envandkeys/but always double-checkUse the security checker: Run
./check-secrets.shbefore committing to detect potentially leaked credentialsProtect your private keys: Keep the contents of the
keys/directory secureReview code before sharing: Make sure no credentials are hardcoded in any source files
When forking or sharing this project:
Make sure the
.envfile is not includedCheck that no private keys are committed
Verify the
.gitignorefile is properly set up
Quick Start
Clone the repository
git clone https://github.com/yourusername/tesla-mcp.git cd tesla-mcpInstall dependencies
pnpm installSet up environment variables Create a
.envfile in the root directory:TESLA_CLIENT_ID=your_client_id TESLA_CLIENT_SECRET=your_client_secret TESLA_REFRESH_TOKEN=your_refresh_tokenGet a refresh token (if you don't have one)
pnpm get-tokenRegister your application with Tesla's API
pnpm registerFollow the instructions provided by the script
Build the server
pnpm buildRun the server
pnpm start
Authentication & Registration
This project uses the official Tesla Fleet API OAuth 2.0 authentication flow to securely connect to your Tesla account. The full process involves two steps:
Authentication: Obtaining a refresh token through the OAuth 2.0 flow
Registration: Registering your application with Tesla via the Partner Accounts API
Authentication
Authentication requires:
Client ID and Client Secret from the Tesla Developer Portal
A refresh token obtained through the OAuth 2.0 authorization code flow
The included pnpm get-token utility simplifies this process by:
Opening a browser for you to log in with your Tesla account credentials
Performing the OAuth PKCE (Proof Key for Code Exchange) flow
Exchanging the authorization code for refresh and access tokens
Storing the refresh token in your
.envfile
Registration
The Tesla Fleet API requires applications to be registered before they can access vehicle data. The registration server (pnpm register) automates this process:
Generates the required EC key pair
Uses ngrok to create a temporary public URL for development
Hosts the public key at the required path
Handles the registration API call with Tesla
Ngrok Setup (Required for Registration)
Install ngrok from ngrok.com/download
Create a free account at ngrok.com
Get your auth token from the ngrok dashboard
Authenticate ngrok:
ngrok authtoken YOUR_AUTH_TOKEN
Available MCP Tools
The server provides the following tools that Claude can use:
wake_up: Wakes up a Tesla vehicle from sleep modeTakes
vehicle_idas a required parameterReturns the current state of the vehicle
refresh_vehicles: Refreshes the list of Tesla vehiclesNo parameters required
Updates the internal cache of vehicles
debug_vehicles: Shows detailed information about available vehiclesNo parameters required
Returns ID, vehicle_id, VIN, and state information
Setting Up Claude to Use the MCP Server
Create the Claude configuration directory:
mkdir -p ~/Library/Application\ Support/ClaudeCreate or edit the configuration file:
nano ~/Library/Application\ Support/Claude/claude_desktop_config.jsonAdd the following configuration (adjust the path as needed):
{ "mcpServers": { "tesla-mcp-server": { "command": "/absolute/path/to/tesla-mcp/run-mcp.js" } } }Make the run-mcp.js script executable:
chmod +x run-mcp.jsRestart Claude completely
Using the MCP Server with Claude
Once the server is running and Claude is configured, you can ask Claude to:
"What Tesla vehicles do I have?"
"Can you wake up my Tesla?"
"Show me debug information about my Tesla vehicles"
Troubleshooting
If you encounter issues:
Environment Variables
Ensure your
.envfile contains valid credentialsRun
pnpm get-tokento refresh your token if needed
Server Connection
Check that the server is running (
pnpm start)Verify Claude's configuration points to the correct file path
Vehicle Connectivity
Vehicle might be offline or asleep
Try waking up the vehicle first with the
wake_upcommand
Debug Mode
Use the
debug_vehiclescommand to get detailed information about your vehiclesCheck the server logs in the terminal where you're running the MCP server
HTTP/SSE Mode (Multi-User Hosted Server)
The server can also run in HTTP/SSE mode, allowing you to host it as a web service that supports multiple users. Each user brings their own Tesla Developer App credentials - no pre-configuration required!
Running in HTTP Mode
Or for development:
Environment Variables for HTTP Mode
Note: No Tesla credentials are needed to start the server. Each user provides their own credentials through the web UI.
HTTP Endpoints
Endpoint | Method | Description |
| GET | Server info and documentation |
| GET | Health check endpoint |
| GET | SSE endpoint for MCP client connection |
| POST | Message endpoint for MCP requests |
| GET | Start Tesla OAuth flow |
| GET | OAuth callback (internal) |
| POST | Create a new session and get auth URL |
How Multi-User Auth Works
Client Connects: MCP client connects to
/sseendpointSession Created: Server creates a session and returns session ID
Setup Required: User visits
/setupto enter their Tesla Developer App credentials (Client ID & Secret)User Authenticates: User is redirected to Tesla's OAuth login page
Tokens Stored: Server stores tokens for that session
Tools Available: MCP tools now work with user's Tesla account
Each user needs to:
Create an app at developer.tesla.com
Set the redirect URI to
YOUR_SERVER_URL/auth/callbackEnter their Client ID and Client Secret in the setup page
Connecting MCP Clients
For clients that support HTTP/SSE transport, configure them with:
Deploy to Render (Recommended)
The easiest way to deploy is using Render:
Push to GitHub (if not already):
git add . git commit -m "Add HTTP server with user auth" git push origin mainDeploy on Render:
Go to render.com and sign up/login
Click New → Web Service
Connect your GitHub repo
Configure:
Build Command:
npm install && npm run buildStart Command:
npm run start:http
Add environment variable:
BASE_URL=https://your-app-name.onrender.com(use your actual Render URL)
Click Create Web Service
Get your public URL: Render will give you a URL like
https://tesla-mcp-xxxx.onrender.comTell users to set their Tesla Developer App redirect URI to:
https://your-app-name.onrender.com/auth/callback
Alternative: Docker Deployment
Production Considerations
HTTPS Required: Tesla OAuth requires HTTPS (Render provides this automatically)
BASE_URL: Must be set to your public URL for OAuth redirects to work
No credentials needed: Users provide their own Tesla Developer credentials
Command Line Tools
The server includes several helpful scripts:
npm run build: Compile the TypeScript codenpm run start: Run the stdio MCP servernpm run start:http: Run the HTTP/SSE MCP servernpm run dev:http: Run HTTP server in development modenpm run register: Register your app with Tesla's APInpm run get-token: Get a refresh token from Teslanpm run test-api: Test your connection to the Tesla APInpm run inspector: Run the server with the MCP Inspector for debugging
API Limitations
As of 2023-10-09, Tesla has deprecated many vehicle command endpoints in their REST API. Commands like honking the horn now require the Tesla Vehicle Command Protocol instead of the REST API. This MCP server currently supports only REST API endpoints that remain functional.
Future Enhancements
Possible future improvements include:
Integration with Tesla's Vehicle Command Protocol for additional commands
Support for more vehicle information endpoints
User interface for configuration and monitoring