Skip to main content

TeslaMate + Fleet API MCP Server

mcp-teslamate-fleet 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:

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)

{
  "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

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)
TESLA_PROXY_URL HTTP proxy URL for commands
TESLA_FLEET_URL NA region Fleet API endpoint (regional options)
TESLA_VERIFY_SSL true Set false for self-signed proxy certs

Vehicle Configuration

Variable Default Description
TESLA_CAR_ID 1 TeslaMate car ID (for multi-car instances)
TESLA_BATTERY_KWH 75 Usable battery capacity in kWh
TESLA_BATTERY_RANGE_KM 525 EPA range at 100% in km

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

Vehicle Battery (kWh) Range (km)
Model 3 Standard Range 54 350
Model 3 Long Range 75 500
Model Y Long Range 75 525
Model S Long Range 100 650
Model X Long Range 100 560

Cost Defaults

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

Variable Default Description
TESLA_ELECTRICITY_RATE 0.12 Electricity cost in $/kWh
TESLA_GAS_PRICE 3.50 Gas price in $/gallon (for comparison)
TESLA_GAS_MPG 28 Comparable 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

Metadata

Release files for mcp-teslamate-fleet 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-teslamate-fleet 0.1.0
File Size Uploaded Provenance Actions
mcp_teslamate_fleet-0.1.0.tar.gz 18.2 kB With provenance Details for mcp_teslamate_fleet-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcp-teslamate-fleet 0.1.0
File Interpreter ABI Platform Actions
mcp_teslamate_fleet-0.1.0-py3-none-any.whl Python 3 none any Details for mcp_teslamate_fleet-0.1.0-py3-none-any.whl

Total release size: 46.1 kB

Release files / mcp_teslamate_fleet-0.1.0.tar.gz

Download URL mcp_teslamate_fleet-0.1.0.tar.gz
Size 18.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a2e010771afbb516c3e63b3db677c8b1d1e2df5a928cd0a6da88e7f4991944b1
BLAKE2b-256 checksum
How to use checksums
127008fe073ac0fd658533425659a535d408ec8f5f2aee1c733895ce050390f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / mcp_teslamate_fleet-0.1.0-py3-none-any.whl

Download URL mcp_teslamate_fleet-0.1.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a5744e96e5bcff67ebb1e38dfb9f8a5af796ee9b89632cc6bd7e9cfc8eafbf2
BLAKE2b-256 checksum
How to use checksums
6a58adb0b883eb00557522bc8643b3da92e35a51a0139f7bb87a54b47fc048c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Security for mcp-teslamate-fleet 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcp_teslamate_fleet-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page