TeslaMate + Fleet API MCP Server
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
MCP server combining **TeslaMate** historical analytics with **Fleet API** live data and commands. Works with Claude Code, Claude Desktop, Cursor, and any MCP-compatible client.
The first MCP server to bring both data sources together — use TeslaMate for deep analytics and Fleet API for real-time control, or configure just one.
Features
**29 tools** across four categories:
| Category | Tools | Backend |
|----------|-------|---------|
| **Status & History** | tesla_status, tesla_drives, tesla_charging_history, tesla_battery_health, tesla_efficiency, tesla_location_history, tesla_state_history, tesla_software_updates | TeslaMate |
| **Analytics** | tesla_savings, tesla_trip_cost, tesla_efficiency_by_temp, tesla_charging_by_location, tesla_top_destinations, tesla_longest_trips, tesla_monthly_summary, tesla_vampire_drain | TeslaMate |
| **Live Data** | tesla_live | Fleet API |
| **Commands** | tesla_climate_on/off, tesla_set_temp, tesla_charge_start/stop, tesla_set_charge_limit, tesla_lock, tesla_unlock, tesla_honk, tesla_flash, tesla_trunk, tesla_sentry | Fleet API |
**Safety:** unlock and trunk commands require confirm=True. All commands are rate-limited to 40/day.
Quick Start
Claude Code (.mcp.json)
Claude Desktop (claude_desktop_config.json)
Same structure — add under mcpServers.
Local install
Prerequisites
You need **at least one** of these backends configured. Both is ideal.
TeslaMate (analytics + history)
TeslaMate is an open-source Tesla data logger. It records driving, charging, and vehicle state to a Postgres database.
If you already run TeslaMate, you just need the database connection details. If not, see the TeslaMate installation guide.
Fleet API (live data + commands)
Tesla's Fleet API provides real-time vehicle data and remote commands. Setup requires:
1. **Register an app** at developer.tesla.com
2. **Generate OAuth tokens** — use Tesla's token generation flow
3. **Set up the HTTP proxy** — commands must be signed using the Tesla Vehicle Command Protocol. Deploy the tesla-http-proxy from that repo
The proxy is only needed for commands (tesla_climate_on, tesla_lock, etc.). tesla_live works with just a token.
Tesla provides a **$10/month free credit** for Fleet API, which is more than enough for personal MCP use.
Configuration
All configuration is via environment variables.
TeslaMate Database
| Variable | Default | Description |
|----------|---------|-------------|
| TESLAMATE_DB_HOST | *(required)* | Postgres host |
| TESLAMATE_DB_PORT | 5432 | Postgres port |
| TESLAMATE_DB_USER | teslamate | Postgres user |
| TESLAMATE_DB_PASS | *(required)* | Postgres password |
| TESLAMATE_DB_NAME | teslamate | Database name |
Fleet API
| Variable | Default | Description |
|----------|---------|-------------|
| TESLA_VIN | *(required)* | Vehicle VIN |
| TESLA_TOKEN_FILE | *(required)* | Path to tokens.json with OAuth tokens |
| TESLA_CLIENT_ID | | Fleet API client ID (for token refresh) |
| TESLA_CLIENT_SECRET | | Fleet API client secret (for token refresh) |