Connects AI assistants directly to your TeslaMate PostgreSQL database through 18 predefined queries covering battery health, charging patterns, driving analytics, and efficiency metrics. You can ask natural language questions like "What's my battery degradation over time?" or execute custom SELECT queries with built-in validation. Includes both local setup for Claude Desktop and remote Docker deployment with optional bearer token authentication. Perfect when you want conversational access to your Tesla data without building custom dashboards or writing SQL manually.
A Model Context Protocol server that exposes your TeslaMate PostgreSQL database to MCP-aware AI clients (Claude Desktop, Cursor, etc.) over either stdio or streamable HTTP.
run_sql and get_database_schemateslamate://queries and teslamate://queries/{name} for catalog browsing without invoking a toolrun_sql — runs inside a PostgreSQL READ ONLY transaction with statement_timeout, lock_timeout, and an automatic row capget_database_schema reads information_schema at runtime; no stale JSON checked into the repoteslamate-mcp stdio for local clients, teslamate-mcp http for remote/health probe for liveness checksDecimal → float JSON serialization so language models see numbers, not stringsgit clone https://github.com/cobanov/teslamate-mcp.git
cd teslamate-mcp
cp env.example .env
# Edit .env — at minimum, set DATABASE_URL
uv sync
The teslamate-mcp console script has four subcommands:
teslamate-mcp stdio # local (Cursor / Claude Desktop)
teslamate-mcp http [--host] [--port] # remote (HTTP / SSE)
teslamate-mcp gen-token # produce an AUTH_TOKEN value
teslamate-mcp list-tools # diagnostic: list registered tools
python -m teslamate_mcp <subcommand> works too.
Configure your MCP client to launch the stdio server. Example for Cursor or Claude Desktop:
{
"mcpServers": {
"teslamate": {
"command": "uv",
"args": ["--directory", "/path/to/teslamate-mcp", "run", "teslamate-mcp", "stdio"]
}
}
}
cp env.example .env
# Set DATABASE_URL and ideally AUTH_TOKEN
docker compose up -d
The MCP endpoint is at http://localhost:8888/mcp and a liveness probe is exposed at http://localhost:8888/health.
A prebuilt multi-arch image (linux/amd64, linux/arm64) is also published to GHCR on every tagged release:
docker run --rm -e DATABASE_URL=... -p 8888:8888 ghcr.io/cobanov/teslamate-mcp:latest
All settings are read from environment variables (.env supported). Only DATABASE_URL is required.
| Variable | Default | Notes |
|---|---|---|
DATABASE_URL | required | postgresql://user:pass@host:5432/teslamate |
AUTH_TOKEN | empty | Enables bearer auth on the HTTP endpoint |
HOST | 0.0.0.0 | HTTP bind host |
PORT | 8888 | HTTP bind port |
POOL_MIN_SIZE | 1 | psycopg pool floor |
POOL_MAX_SIZE | 10 | psycopg pool ceiling |
QUERY_TIMEOUT_MS | 5000 | statement_timeout for run_sql |
CUSTOM_SQL_ROW_LIMIT | 1000 | LIMIT injected when run_sql doesn't supply one |
LOG_LEVEL | INFO | Standard Python log level |
DEBUG | false | Starlette debug mode (keep off in production) |
Generate a bearer token:
uv run teslamate-mcp gen-token
Vehicle: get_basic_car_information, get_current_car_status, get_software_update_history
Battery & health: get_battery_health_summary, get_battery_degradation_over_time, get_daily_battery_usage_patterns, get_tire_pressure_weekly_trends
Driving: get_monthly_driving_summary, get_daily_driving_patterns, get_longest_drives_by_distance, get_total_distance_and_efficiency, get_drive_summary_per_day
Efficiency: get_efficiency_by_month_and_temperature, get_average_efficiency_by_temperature, get_unusual_power_consumption
Charging & location: get_charging_by_location, get_all_charging_sessions_summary, get_most_visited_locations
get_database_schema — current TeslaMate schema (one row per column)run_sql(query) — execute a custom SELECT or WITH … SELECTDrop a SELECT into src/teslamate_mcp/queries/your_query.sql.
Add a sibling your_query.toml:
name = "get_your_data"
description = "What this returns."
Restart the server. The registry picks it up automatically.
uv sync # install with dev deps
uv run ruff check src tests # lint
uv run ruff format src tests # format
uv run pytest # tests (Docker-backed integration tests skip if Docker is absent)
MIT — see LICENSE.
hovecapital/read-only-local-postgres-mcp-server
cocaxcode/database-mcp
io.github.infoinlet-marketplace/mcp-mysql
io.github.cybeleri/database-admin
io.github.yash-0620/postgres-mcp-secured