MCP Teslamate Fleet

مجتمعي أدوات المطورين

TeslaMate analytics and Tesla Fleet API commands: telemetry, driving history, energy analytics and remote control of climate, charging, locks and sentry.

التثبيت

خطوات التثبيت موجودة في التوثيق أدناه. التوثيق

التوثيق

مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.

المحتويات
  1. TeslaMate + Fleet API MCP Server
  2. Features
  3. Quick Start
  4. Prerequisites
  5. Configuration
  6. Architecture
  7. Limitations
  8. Credits
  9. License

TeslaMate + Fleet API MCP Server

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:

CategoryToolsBackend
Status & Historytesla_status, tesla_drives, tesla_charging_history, tesla_battery_health, tesla_efficiency, tesla_location_history, tesla_state_history, tesla_software_updatesTeslaMate
Analyticstesla_savings, tesla_trip_cost, tesla_efficiency_by_temp, tesla_charging_by_location, tesla_top_destinations, tesla_longest_trips, tesla_monthly_summary, tesla_vampire_drainTeslaMate
Live Datatesla_liveFleet API
Commandstesla_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_sentryFleet API

Safety: unlock and trunk commands require confirm=True. All commands are rate-limited to 40/day.

Quick Start

Claude Code (.mcp.json)
{
  "mcpServers": {
    "tesla": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/lodordev/mcp-teslamate-fleet", "mcp-teslamate-fleet"],
      "env": {
        "TESLAMATE_DB_HOST": "localhost",
        "TESLAMATE_DB_PASS": "your_password",
        "TESLA_VIN": "your_vin",
        "TESLA_TOKEN_FILE": "/path/to/tokens.json",
        "TESLA_CLIENT_ID": "your_client_id",
        "TESLA_CLIENT_SECRET": "your_client_secret",
        "TESLA_PROXY_URL": "https://localhost:4443",
        "TESLA_VERIFY_SSL": "false"
      }
    }
  }
}
Claude Desktop (claude_desktop_config.json)

Same structure — add under mcpServers.

Local install
git clone https://github.com/lodordev/mcp-teslamate-fleet
cd tesla-mcp
pip install -e .

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
VariableDefaultDescription
TESLAMATE_DB_HOST(required)Postgres host
TESLAMATE_DB_PORT5432Postgres port
TESLAMATE_DB_USERteslamatePostgres user
TESLAMATE_DB_PASS(required)Postgres password
TESLAMATE_DB_NAMEteslamateDatabase name
Fleet API
VariableDefaultDescription
TESLA_VIN(required)Vehicle VIN
TESLA_TOKEN_FILE(required)Path to tokens.json with OAuth tokens
TESLA_CLIENT_IDFleet API client ID (for token refresh)
TESLA_CLIENT_SECRETFleet API client secret (for token refresh)
TESLA_PROXY_URLHTTP proxy URL for commands
TESLA_FLEET_URLNA regionFleet API endpoint (regional options)
TESLA_VERIFY_SSLtrueSet false for self-signed proxy certs
Vehicle Configuration
VariableDefaultDescription
TESLA_CAR_ID1TeslaMate car ID (for multi-car instances)
TESLA_BATTERY_KWH75Usable battery capacity in kWh
TESLA_BATTERY_RANGE_KM525EPA range at 100% in km

Energy consumption is estimated from ideal range deltas using these values. Adjust for your vehicle:

VehicleBattery (kWh)Range (km)
Model 3 Standard Range54350
Model 3 Long Range75500
Model Y Long Range75525
Model S Long Range100650
Model X Long Range100560
Cost Defaults

These are defaults — tesla_savings and tesla_trip_cost accept per-call overrides.

VariableDefaultDescription
TESLA_ELECTRICITY_RATE0.12Electricity cost in $/kWh
TESLA_GAS_PRICE3.50Gas price in $/gallon (for comparison)
TESLA_GAS_MPG28Comparable gas vehicle MPG

Architecture

Single-file Python server (~1400 lines) using FastMCP. Two data paths:

┌─────────────┐     ┌──────────────┐
│  TeslaMate   │────▶│   Postgres   │──┐
│  (logger)    │     │  (telemetry) │  │
└─────────────┘     └──────────────┘  │   ┌───────────┐     ┌────────────┐
                                       ├──▶│ tesla.py  │────▶│ MCP Client │
┌─────────────┐     ┌──────────────┐  │   │ (server)  │     │ (Claude,   │
│  Tesla       │────▶│ HTTP Proxy   │──┘   └───────────┘     │  Cursor)   │
│  Fleet API   │     │ (commands)   │                         └────────────┘
└─────────────┘     └──────────────┘

Limitations

  • Single vehicle — queries use a configurable car_id but tools don't accept it as a parameter. Multi-car users should run separate server instances.
  • Imperial units — output is in miles, °F, and PSI. Metric support is planned.
  • Estimated kWh — TeslaMate's drives table doesn't include energy consumed directly. We estimate from ideal range deltas using your configured battery capacity. Accuracy is ~90-95%.

Credits

Inspired by cobanov/teslamate-mcp. Built with FastMCP and TeslaMate.

License

MIT

الأسئلة الشائعة

ما هو MCP Teslamate Fleet؟

TeslaMate analytics and Tesla Fleet API commands: telemetry, driving history, energy analytics and remote control of climate, charging, locks and sentry.

كيف أثبّت MCP Teslamate Fleet؟

اتبع خطوات التثبيت في توثيقه المعروض في هذه الصفحة وفي مستودعه.

هل MCP Teslamate Fleet مفتوح المصدر؟

نعم. شيفرته متاحة على GitHub بترخيص MIT.

من يصون MCP Teslamate Fleet؟

ينشره lodordev. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.

من القوائم المجتمعية awesome-mcp-servers ومستودع المشروع على GitHub. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.