teslamate-mcp
Connects an AI assistant to a TeslaMate PostgreSQL database for read-only reporting on vehicle, battery, driving, charging, and efficiency history.
Vehicle & status: basic car details (VIN, model, firmware), current status (location, battery level, state), and software update history.
Battery: health summary, degradation over time, and daily battery usage patterns.
Driving: monthly and per-day drive summaries, daily driving patterns, and longest drives by distance.
Efficiency: lifetime distance and efficiency, efficiency by month/temperature, average efficiency by temperature, and unusual power consumption (anomalies).
Charging: summary of all charging sessions, charging statistics by location, and most visited locations.
Maintenance monitoring: weekly tire pressure trends.
All 18 exposed tools are read-only, take no arguments (each returns the full report for every car), and return array-of-row results.
Connects to a PostgreSQL database containing TeslaMate data to retrieve and analyze Tesla vehicle information.
Allows querying Tesla vehicle data from a TeslaMate database, providing access to vehicle information, driving statistics, charging data, battery health, efficiency metrics, and location analytics.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@teslamate-mcp what's my current battery health?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
TeslaMate MCP Server
Connect your AI assistant to your TeslaMate data. This is a Model Context Protocol (MCP) server. It reads your TeslaMate PostgreSQL database. It gives MCP clients (Claude Desktop, Cursor, and others) 77 tools, 12 prompts, and interactive charts.
Documentation · Tool reference · Configuration · Deployment
What you can ask
"Is my battery really degrading?" — the server estimates usable capacity in kWh from your charging sessions.
"How much range do I lose while parked?" — the server finds vampire drain between drives.
"Show the route of my longest drive." — the server returns the GPS track, with an interactive map on chart-capable clients.
"Compare my driving this month with last month." — one call returns both windows, per metric.
"Can I reach Ankara (450 km) at 5°C without charging?" — the server estimates the arrival battery % from your own drives at that temperature.
"Why isn't my car sleeping?" — the server reads TeslaMate's state log and lists the periods the car stayed awake while parked.
"What did my car do on Saturday?" — one call returns the drives, charges, and parked time in order.
"How long will the charging stop take, and when should I leave for work?" — the server times a charge from your own past sessions, and finds the routes you drive again and again.
"Is anything wrong with my car?" — one call checks logging, open drives, tire pressures and slow leaks, parked drain, sleep, full charges left sitting, range loss, and the battery level.
"What does driving cost me per 100 km, and how calmly do I drive?" — the server splits charging into AC and DC prices per month, and counts hard accelerations and hard braking from the power samples.
Related MCP server: Prometheus MCP Server
Highlights
65 SQL report tools. A health check, battery capacity, charge cycles and degradation (per month and per km), sleep and state history, climate run while parked, a year or month in review, a timeline of each day, trips, frequent routes, range and charging-time estimates, consumption by speed, driving style, fast-charging speeds, charging costs (with estimates for missing ones), cost per 100 km, and fuel savings, elevation, vampire drain, geofences, driving and charging hours, the regions visited, routes, and search tools for drives and charging sessions.
10 interactive charts (MCP Apps). Charging curves (one session, or several overlaid), battery degradation, drive and trip maps with elevation profiles, a monthly or yearly activity dashboard, a year- or month-in-review card, a map of visited places, a map of every road driven, and consumption against temperature. On clients without chart support, the same tools return plain rows.
Guidance for the assistant. MCP instructions and 12 prompts map questions to tools, and
get_unit_preferenceslets the assistant answer in the units set in TeslaMate.Typed inputs and outputs. Each report tool declares its parameters and result columns in a
.tomlfile. The server validates the declarations at startup. Parameters bind as SQL placeholders, never as string concatenation.Safe custom SQL.
run_sqlruns yourSELECTinside a PostgreSQLREAD ONLYtransaction, with timeouts and a row cap. The transaction always rolls back.Optional cost writes, with confirmation. One opt-in tool writes charging costs. A column-scoped database grant limits what it can touch. Clients with MCP elicitation show a confirmation dialog first.
Local-time reports. Set
REPORT_TIMEZONEand daily, weekly, and monthly buckets follow your local midnight.Two transports. Run
teslamate-mcp stdiofor local clients. Runteslamate-mcp httpfor remote clients, with bearer-token auth and a/healthprobe.
Requirements
TeslaMate with its PostgreSQL database.
Python 3.11+ for a local install, or Docker for a server install.
Quick start — local (stdio)
Install:
git clone https://github.com/cobanov/teslamate-mcp.git cd teslamate-mcp cp env.example .env # set DATABASE_URL uv syncAdd the server to your MCP client. Example for Claude Desktop or Cursor:
{ "mcpServers": { "teslamate": { "command": "uv", "args": ["--directory", "/path/to/teslamate-mcp", "run", "teslamate-mcp", "stdio"] } } }
Quick start — Docker
cp env.example .env # set DATABASE_URL, and set AUTH_TOKEN for remote use
docker compose up -dThe MCP endpoint is http://localhost:8888/mcp. The health probe is http://localhost:8888/health. It runs a SELECT 1 against the database and returns 503 when the database is unreachable.
A multi-arch image (linux/amd64, linux/arm64) is published to GHCR on each release:
docker run --rm -e DATABASE_URL=... -p 8888:8888 ghcr.io/cobanov/teslamate-mcp:latestDeploy on Unraid, behind Cloudflare
You can reach this server from claude.ai, Claude Desktop, and mobile — with OAuth login and with no open ports on your home network.
The Unraid + Cloudflare deployment guide shows the full path:
Run the container on Unraid with the included Community Apps template.
Publish it through a Cloudflare Tunnel. No inbound firewall rules are necessary.
Put a Cloudflare Zero Trust MCP Server Portal in front. The portal handles OAuth for Claude clients and sends the bearer token upstream.
The guide includes the exact dashboard fields, verification commands for each phase, and a troubleshooting table.
The portal rewrites
ui://resource URIs, so the interactive charts (show_*tools) do not render through it. To get them, connect Claude through Cloudflare Access directly. The guide's direct connection section shows how.
Tools
Each report tool accepts optional filters: car_name everywhere, plus days, limit, and thresholds where they apply. A call with no arguments returns the full report.
Tools return metric values (km, km/h, °C, bar, m) and rated range. get_unit_preferences reads the units chosen in TeslaMate's settings (km or mi, °C or °F, bar or psi, rated or ideal range) so the assistant can convert when it answers; the charts stay metric.
The server also sends MCP instructions: how to read units, time zones and costs, and which tool answers which kind of question.
Reports (28)
Group | Tools |
Vehicle |
|
Battery |
|
Driving |
|
Efficiency |
|
Charging |
|
Insights (16)
Tool | What it returns |
| "Is anything wrong?": eight checks per car, worst first, each with alert, warn, ok, or unknown, a value, and what it means: days since TeslaMate last logged the car, drives and charges left open, tire pressure spread and a tire losing more than the others (a slow leak), rated km lost per day parked, hours a day awake while parked, charges to 95 % or more left sitting, range lost since the first charges, and the battery level |
| Usable capacity in kWh, estimated from charging sessions (energy added ÷ SOC gained), per month and car |
| Rated range at 100 % per odometer bucket (1000 km by default), from charges that ended at 50 % or more, with the drop from the car's best bucket; degradation per km, like TeslaMate's Projected Range dashboard |
| Per month: hard accelerations and hard regenerative braking per 100 km, time above a speed (120 km/h by default), top speed, the share of energy regen recovered, and a 0–100 style score; thresholds are parameters |
| Charging sessions by the local hour they started, AC and DC apart, with kWh and each hour's share; shows whether home charging lands in a night tariff |
| Range lost while parked between drives; gaps that contain a charge do not count |
| kWh added vs kWh drawn per car, split into AC and DC |
| Charging totals per TeslaMate geofence, plus an "Ungeofenced" group |
| Share of samples above 80% and below 20% state of charge |
| The last N days vs the N days before, one row per metric |
| A month by day or a year by month: drives, distance, consumption, charging, and cost per bucket, empty days included |
| A year or month in review in one row: totals, distance against the period before (cut at the same point while it runs), charging and cost, and highlights: longest drive, busiest day, most efficient day or month, favourite destination and charging spot, top speed, temperature range, software updates |
| Times the climate ran while parked (preconditioning, cooling down after arriving, Keep Climate / Dog / Camp mode): minutes, estimated battery kWh, cooling or heating, temperatures, and where |
| The same per month: sessions, preconditioning count, hours, hours plugged in, estimated kWh and cost |
| "Will I make it?": energy and battery % a drive of a given distance takes, from this car's own drives at a similar temperature (optionally motorway drives only, or drives at a given average speed), with a conservative figure and the arrival battery % |
| "How long will the stop take?": minutes from one battery % to another per charger type (Supercharger, other fast charger, AC), from the time past sessions spent at each percent, with a slow figure and the kWh added |
Timeline and car state (4)
TeslaMate logs whether each car is online, asleep, or offline. get_current_car_status reads that log too, and reports whether the car is driving, charging, online, asleep, or offline right now. It also gives the cabin climate and the four tire pressures. Most rows logged while driving have neither, so each group comes from the latest row that has it, with the time of that row.
Tool | What it returns |
| What the car did, in order: drives, charges, the time parked between them, and software updates, with places, battery %, kWh, and cost; answers "what did my car do on Saturday?" |
| Per car and local day: hours online, asleep, and offline, driving and charging hours, idle awake hours (online while parked and not charging), and wake-ups |
| The online periods that kept the car awake while parked, longest first, with where it was parked; answers "why isn't my car sleeping?" |
| Logging holes: drives and charges TeslaMate never closed, and stretches with no position across which the odometer moved or the battery level rose (a drive or charge that was not logged). A parked car logs nothing, so long parks stay out |
Search and detail (6)
Tool | What it returns |
| Drives filtered by date range, location text, distance, and car; sortable. Each drive has its Wh/km against what the car usually uses at the same outside temperature |
| Charging sessions filtered by date range, location, energy, and car |
| Full statistics for one drive, with ideal range, the start and end geofence names, and the energy the motors used and regenerative braking recovered |
| GPS track points for one drive, downsampled |
| Power and SOC curve for one charging session, downsampled |
| One charging session, AC or DC: energy added and used, battery % at start and end, cost, duration, geofence, AC phases, cable, and peak power |
Costs (5)
A session with no cost recorded counts as unknown, not free: averages per kWh use only the sessions that have a cost, and each report says how many sessions lack one.
Tool | What it returns |
| Costs grouped by month, location, or car, with the number of sessions that have no cost |
| An estimated cost for each session with none: free Supercharging, a price you give, the geofence tariff, what you paid at the same place, or the typical price for that charger type |
| Per month: distance, kWh added split into AC and DC, cost, the AC, DC, and overall price per kWh, cost per 100 km, and kWh charged per 100 km |
| What the same distance would have cost in fuel, against what charging cost, per car |
| Each TeslaMate geofence with its center, radius, and tariff: cost per unit, session fee, and billing type |
Trips (3)
TeslaMate ends a drive every time the car parks, so a road trip with a WC break and a charging stop is several drives. The trip tools merge a car's consecutive drives while each stop in between stays short: up to max_stop_minutes (default 30) without charging, or max_charging_stop_minutes (default 120) when a charging session happened during the stop. Overnight stops end a trip.
Tool | What it returns |
| One row per trip: legs, stops and charging stops, distance, driving vs stopped time, moving speed, battery % at start and end, kWh added on the way; filter by date, car, distance, legs, or a place the trip passed through |
| One trip's timeline: each drive, and each stop with where and how long, plus kWh and battery % for charging stops |
| GPS track of a whole trip across its drives, downsampled, with the stop before each leg |
Fast charging (3)
A session is DC when a sample came from a fast charger, or had no AC phases while power flowed; a Tesla-branded fast charger is a Supercharger.
Tool | What it returns |
| DC sessions with peak power, average power, average power across 20–80% (the fair comparison), minutes from 20% to 80%, whether the battery heater ran, and cost |
| The same per location and charger type: which fast chargers are fastest and cheapest for your car |
| Power against battery % for several sessions, for overlaying their curves |
Charts (10)
show_charging_curve, show_charging_curve_comparison, show_battery_degradation, show_drive_route, show_trip_route, show_activity_report, show_visited_places, show_driven_roads, show_efficiency_vs_temperature, and show_recap are the chart versions of their get_* tools. On chart-capable clients they draw an interactive chart in the conversation. On other clients they return the same rows as the get_* tool. The route, trip, places, and roads maps are interactive (pan, zoom, fit) and draw over CARTO's light or dark basemap, matching the client; the trip map also marks every stop, with charging stops highlighted. The route and trip maps draw an elevation profile under the track; hovering it finds the place on the map. Where the client cannot run the interactive map (no WebGL, or workers blocked), a static map over Esri's gray canvas is drawn instead. show_activity_report is a monthly or yearly dashboard, show_visited_places maps where the car parks (sized by arrivals, charging places highlighted), show_driven_roads draws every road the car has driven as one network (a route driven many times is drawn once: the newest drive between each pair of places), and show_efficiency_vs_temperature plots every drive's consumption against outside temperature with the 5 °C average. show_recap is a year- or month-in-review card with the headline distance and highlights. Set MAP_TILES=false to keep the maps fully offline.
Custom (2)
get_database_schema— lists all tables, shows the columns of one table, and re-reads the schema when you passrefresh=true.run_sql— runs one customSELECTorWITH … SELECT.
Prompts (12)
Ready-made workflows that name the tools to call, in order: status_report, summarize_driving, analyze_battery_health, analyze_charging, find_anomalies, weather_efficiency, diagnose_sleep, plan_trip, review_trip, monthly_recap, year_in_review, and charging_costs_and_savings. With cost writes on, backfill_costs_from_receipts joins them.
Cost writes (opt-in, off by default)
Set ENABLE_CHARGING_WRITES=true to register set_charging_cost(charging_process_id, cost). It sets the cost of one charging session. This is the same field that the TeslaMate UI edits. A backfill_costs_from_receipts prompt guides the receipt-matching workflow.
Give the database role write access to that single column only:
GRANT UPDATE (cost) ON charging_processes TO teslamate_ro;This grant is the security boundary. The tool cannot write anything else. On clients with MCP elicitation, the user confirms each write in a dialog. run_sql stays read-only in all cases.
Configuration
The server reads all settings from environment variables. It also reads a .env file. Only DATABASE_URL is required.
Variable | Default | Purpose |
| required |
|
| empty | Turns on bearer auth for the HTTP endpoint |
| empty | Cloudflare Access team domain; accepts Access-verified requests |
| empty | Audience tag of that Access application (set with the above) |
|
| HTTP bind host |
|
| HTTP bind port |
|
| Minimum pool connections |
|
| Maximum pool connections |
|
|
|
|
| Tighter |
|
| Most rows |
|
| IANA timezone for report buckets |
|
| Interactive basemap under the route, trip, places, and roads maps (CARTO tiles; Esri as fallback) |
|
| Registers |
|
| Python log level |
|
| Starlette debug mode; keep off in production |
Generate a bearer token:
uv run teslamate-mcp gen-tokenAdd your own query
No code change is necessary. The server finds new queries at startup.
Put a
SELECTinsrc/teslamate_mcp/queries/your_query.sql.Add
your_query.tomlnext to it:name = "get_your_data" description = "What this returns, units, grouping, and available filters." [[params]] # optional: typed tool arguments name = "car_name" type = "string" # string | integer | number | boolean description = "Case-insensitive substring match on the car's name." [[params]] name = "limit" type = "integer" description = "Maximum number of rows returned." default = 10 minimum = 1 maximum = 100 [[output]] # optional: one entry per result column name = "car_name" type = "string"Write parameters as
%(car_name)splaceholders in the SQL. Do not build SQL from strings. Cast the first use of each placeholder, for example%(limit)s::int. Write a literal%as%%. The reserved%(tz)splaceholder bindsREPORT_TIMEZONE.Restart the server. The registry validates the pair and registers the tool. Run
teslamate-mcp list-toolsto confirm.
The startup validation rejects a query when a declared parameter is missing from the SQL, or when the SQL uses an undeclared parameter.
Security
run_sqlruns in aREAD ONLYtransaction that always rolls back. Timeouts and a row cap apply.Connect with a
SELECT-only PostgreSQL role, not TeslaMate's ownteslamateuser. TeslaMate's Compose makes that user a superuser, and a read-only transaction still lets a superuser read server files throughrun_sql. SECURITY.md has theCREATE ROLEsnippet.The maps' basemap is fetched by the viewer's browser from CARTO (from Esri where the client cannot run the interactive map), which reveals the viewer's IP address and the rough area being viewed. The map library itself (MapLibre GL) is served by this server, not a CDN.
MAP_TILES=falseturns this off.The HTTP transport compares bearer tokens with a timing-safe function. Behind Cloudflare Access, it can instead verify the signed
Cf-Access-Jwt-Assertion(signature, issuer, audience, expiry).Report vulnerabilities through private security advisories. See SECURITY.md.
Development
uv sync # install with dev dependencies
uv run ruff check src tests # lint
uv run ruff format src tests # format
uv run pytest # database tests need Docker or TESLAMATE_TEST_DATABASE_URL (a scratch database)License
MIT — see LICENSE.
Available Tools
18 toolsget_all_charging_sessions_summaryB
Get the summary of all charging sessions for each car. Returns charging statistics including total sessions, energy consumed, and costs.
Inputs: no named parameters. Returns: result
get_average_efficiency_by_temperatureB
Get the average efficiency by temperature for each car. Helps understand how temperature affects vehicle efficiency.
Inputs: no named parameters. Returns: result
get_basic_car_informationB
Get the basic car information for each car. Returns VIN, model, firmware version, and other vehicle details.
Inputs: no named parameters. Returns: result
get_battery_degradation_over_timeB
Get the battery degradation over time for each car. Tracks battery health metrics and capacity changes.
Inputs: no named parameters. Returns: result
get_battery_health_summaryB
Get the battery health summary for each car. Provides current battery health status and statistics.
Inputs: no named parameters. Returns: result
get_charging_by_locationB
Get the charging by location for each car. Shows charging patterns and statistics grouped by location.
Inputs: no named parameters. Returns: result
get_current_car_statusB
Get the current car status for each car. Returns real-time vehicle status including location, battery level, and state.
Inputs: no named parameters. Returns: result
get_daily_battery_usage_patternsB
Get the daily battery usage patterns for each car. Analyzes battery consumption patterns throughout the day.
Inputs: no named parameters. Returns: result
get_daily_driving_patternsB
Get the daily driving patterns for each car. Shows driving habits and patterns by day of week and time.
Inputs: no named parameters. Returns: result
get_drive_summary_per_dayB
Get the drive summary per day for each car. Provides daily driving statistics including distance, duration, and efficiency.
Inputs: no named parameters. Returns: result
get_efficiency_by_month_and_temperatureB
Get the efficiency by month and temperature for each car. Analyzes how seasonal temperature changes affect vehicle efficiency.
Inputs: no named parameters. Returns: result
get_longest_drives_by_distanceB
Get the longest drives by distance for each car. Lists the longest trips taken with details about distance and duration.
Inputs: no named parameters. Returns: result
get_monthly_driving_summaryB
Get the monthly driving summary for each car. Provides monthly statistics for distance, energy usage, and costs.
Inputs: no named parameters. Returns: result
get_most_visited_locationsB
Get the most visited locations for each car. Shows frequently visited places with visit counts and durations.
Inputs: no named parameters. Returns: result
get_software_update_historyB
Get the software update history for each car. Tracks firmware updates and version changes over time.
Inputs: no named parameters. Returns: result
get_tire_pressure_weekly_trendsB
Get the tire pressure weekly trends for each car. Monitors tire pressure changes and patterns by week.
Inputs: no named parameters. Returns: result
get_total_distance_and_efficiencyB
Get the total distance and efficiency for each car. Provides lifetime statistics for distance traveled and energy efficiency.
Inputs: no named parameters. Returns: result
get_unusual_power_consumptionB
Get the unusual power consumption for each car. Identifies anomalies in power usage that might indicate issues.
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Most tools have distinct purposes focusing on different aspects of Tesla vehicle data (charging, driving, battery, efficiency, locations, etc.), though some like 'get_battery_degradation_over_time' and 'get_battery_health_summary' could potentially overlap in scope, and 'get_daily_driving_patterns' and 'get_drive_summary_per_day' might be confused for similar daily analyses. Descriptions help clarify, but there is minor ambiguity in a few cases.
All tool names follow a consistent 'get_' prefix with descriptive snake_case nouns, such as 'get_all_charging_sessions_summary' and 'get_current_car_status'. This uniform pattern makes the tool set predictable and easy to navigate, with no deviations in naming conventions.
With 18 tools, the count is slightly high but reasonable for a comprehensive Tesla data analytics server, covering various metrics like charging, driving, battery, and efficiency. It might feel a bit heavy, but each tool appears to serve a specific purpose within the domain, avoiding redundancy.
The tool set provides extensive coverage for analyzing Tesla vehicle data, including real-time status, historical trends, charging patterns, driving habits, battery health, efficiency metrics, and anomaly detection. There are no obvious gaps; it supports a full lifecycle of data retrieval and analysis without dead ends for the stated purpose.
Maintenance
Related MCP Connectors
MCP server wrapping the Tesla Fleet API and TeslaMate API
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Official Fibery MCP server: query and update your workspace from any AI client via OAuth.
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA 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.20MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants to query Prometheus metrics, discover available data, and analyze system performance through natural language interactions.5242 npmMIT
- AlicenseBqualityDmaintenanceMCP server combining TeslaMate historical analytics with Fleet API live data and commands. Works with Claude Code, Claude Desktop, Cursor, and any MCP-compatible client.292MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for PostgreSQL, MySQL, and SQLite that gives AI assistants secure database access via the Model Context Protocol.47 npm5MIT