tesla mcp
A Model Context Protocol server that connects to the Tesla Fleet API, allowing AI assistants like Claude to control Tesla vehicles and access vehicle information through natural language commands.
A Model Context Protocol server that connects to the Tesla Fleet API, allowing AI assistants like Claude to control Tesla vehicles and access vehicle information through natural language commands.
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.
This project handles sensitive Tesla API credentials. Please follow these security practices:
.gitignore
file excludes .env
and keys/
but always double-check./check-secrets.sh
before committing to detect potentially leaked credentialskeys/
directory secureWhen forking or sharing this project:
.env
file is not included.gitignore
file is properly set upgit clone https://github.com/yourusername/tesla-mcp.git
cd tesla-mcp
pnpm install
.env
file in the root directory:TESLA_CLIENT_ID=your_client_id
TESLA_CLIENT_SECRET=your_client_secret
TESLA_REFRESH_TOKEN=your_refresh_token
pnpm get-token
pnpm register
Follow the instructions provided by the script
pnpm build
pnpm start
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 requires:
The included pnpm get-token
utility simplifies this process by:
.env
fileThe Tesla Fleet API requires applications to be registered before they can access vehicle data. The registration server (pnpm register
) automates this process:
ngrok authtoken YOUR_AUTH_TOKEN
The server provides the following tools that Claude can use:
wake_up
: Wakes up a Tesla vehicle from sleep mode
Takes vehicle_id
as a required parameter
Returns the current state of the vehicle
refresh_vehicles
: Refreshes the list of Tesla vehicles
No parameters required
Updates the internal cache of vehicles
debug_vehicles
: Shows detailed information about available vehicles
mkdir -p ~/Library/Application Support/Claude
nano ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"tesla-mcp-server": {
"command": "/absolute/path/to/tesla-mcp/run-mcp.js"
}
}
}
chmod +x run-mcp.js
Once the server is running and Claude is configured, you can ask Claude to:
If you encounter issues:
.env
file contains valid credentialspnpm get-token
to refresh your token if neededpnpm start
)wake_up
commanddebug_vehicles
command to get detailed information about your vehiclesThe server includes several helpful scripts:
pnpm build
: Compile the TypeScript codepnpm start
: Run the server using the run-mcp.js scriptpnpm register
: Register your app with Tesla's APIpnpm get-token
: Get a refresh token from Teslapnpm test-api
: Test your connection to the Tesla APIpnpm inspector
: Run the server with the MCP Inspector for debuggingAs 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.
Possible future improvements include: