home / mcp / teslamate mcp server

TeslaMate MCP Server

A Model Context Protocol (MCP) server that provides access to your TeslaMate database, allowing AI assistants to query Tesla vehicle data and analytics.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "cobanov-teslamate-mcp": {
      "url": "http://localhost:8888/mcp",
      "headers": {
        "AUTH_TOKEN": "YOUR_TOKEN",
        "DATABASE_URL": "postgresql://user:pass@host:5432/teslamate"
      }
    }
  }
}

You can connect your TeslaMate PostgreSQL database to AI assistants using this MCP server, enabling natural language queries about your Tesla data while keeping safety and structure intact.

How to use

You will run the MCP server either locally or remotely and then connect an MCP client to start asking questions about your Tesla data. Use the predefined queries to get quick insights on battery health, driving patterns, charging behavior, and more. You can also run custom SQL SELECT queries against your TeslaMate schema in a read-only, validated fashion. Start by ensuring your TeslaMate database is reachable from the MCP server and that authentication (if used) is configured.

How to install

Prerequisites: you need a working TeslaMate instance with PostgreSQL, Python 3.11 or newer for local usage, or Docker for remote deployments.

# Local setup using UVX (Cursor/Claude Desktop style)
git clone https://github.com/cobanov/teslamate-mcp.git
cd teslamate-mcp
cp env.example .env
# Edit .env to set your DATABASE_URL
uv sync

# Local MCP client configuration example (inline JSON)
```
```json
{
  "mcpServers": {
    "teslamate": {
      "command": "uv",
      "args": ["--directory", "/path/to/teslamate-mcp", "run", "main.py"]
    }
  }
}

Additional configuration and runtime details

If you prefer remote deployment, you can run the MCP server with Docker. After you have a .env with your DATABASE_URL, start the container stack with the following command.

git clone https://github.com/cobanov/teslamate-mcp.git
cd teslamate-mcp
cp env.example .env
# Edit .env with your DATABASE_URL
docker-compose up -d

How to access the server

Once running, the MCP server is available at http://localhost:8888/mcp. Connect your MCP client to this URL and begin issuing natural language queries or SELECT-based requests through the safe, read-only endpoints.

Configuration basics

Create your environment file with the following keys. These values are required to establish the TeslaMate connection and optional for remote authentication.

DATABASE_URL=postgresql://user:pass@host:5432/teslamate
AUTH_TOKEN=                    # Optional: for remote auth

Starting tokens for authentication (optional)

If you want to enable optional token-based authentication for remote deployments, generate an auth token using the provided helper.

python utils/generate_token.py

Available tools

get_basic_car_information

Returns VIN, model, and firmware details for the connected TeslaMate vehicle.

get_current_car_status

Provides real-time status including location and battery state.

get_software_update_history

Shows firmware update history for the vehicle.

get_battery_health_summary

Summarizes current battery health metrics.

get_battery_degradation_over_time

Charts historical battery capacity degradation.

get_daily_battery_usage_patterns

Reveals daily patterns in battery usage.

get_tire_pressure_weekly_trends

Tracks weekly tire pressure trends.

get_monthly_driving_summary

Aggregates driving stats on a monthly basis.

get_daily_driving_patterns

Analyzes daily driving habits.

get_longest_drives_by_distance

Identifies top trips by distance.

get_total_distance_and_efficiency

Displays lifetime distance and efficiency.

get_drive_summary_per_day

Provides daily drive summaries.

get_efficiency_by_month_and_temperature

Analyzes efficiency by month and ambient temperature.

get_average_efficiency_by_temperature

Averages efficiency across temperature ranges.

get_unusual_power_consumption

Detects anomalous power usage.

get_charging_by_location

Shows charging patterns by location.

get_all_charging_sessions_summary

Summarizes all charging sessions.

get_most_visited_locations

Lists locations visited most often.

get_database_schema

Views the database schema.

run_sql

Executes safe SELECT queries against the database.