The Tesla MCP Server allows you to control your Tesla vehicle using Claude and other AI assistants that support the Model Context Protocol (MCP). It connects to the Tesla Fleet API to provide a bridge between your AI assistant and your Tesla vehicle's systems.
git clone https://github.com/yourusername/tesla-mcp.git
cd tesla-mcp
pnpm install
Create a .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
The Tesla MCP Server uses Tesla's Fleet API OAuth 2.0 authentication flow to connect to your Tesla account.
pnpm get-token
This will:
.env
filengrok authtoken YOUR_AUTH_TOKEN
Create the Claude configuration directory:
mkdir -p ~/Library/Application\ Support/Claude
Create or edit the configuration file:
nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
Add 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.js
Restart Claude completely
The server provides the following tools that Claude can use:
Wakes up a Tesla vehicle from sleep mode.
vehicle_id
as a required parameterRefreshes the list of Tesla vehicles.
Shows detailed information about available vehicles.
Once configured, you can ask Claude:
.env
file contains valid credentialspnpm get-token
to refresh your token if neededpnpm start
)wake_up
commanddebug_vehicles
command to get detailed informationpnpm 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 debuggingThere are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.