A Model Context Protocol (MCP) server that connects your TeslaMate database to AI assistants, enabling natural language queries about your Tesla data.
- π 18 Predefined Queries - Battery health, efficiency, charging, driving patterns, and more
- π Custom SQL Support - Execute safe SELECT queries with built-in validation
- ποΈ Database Schema Access - Explore your TeslaMate database structure
- π Optional Authentication - Bearer token support for remote deployments
- ποΈ Modular Architecture - Clean, maintainable codebase
- TeslaMate running with PostgreSQL
- Python 3.11+ (for local) or Docker (for remote)
git clone https://github.com/cobanov/teslamate-mcp.git
cd teslamate-mcp
cp env.example .env
# Edit .env with your DATABASE_URL
uv syncConfigure your MCP client:
{
"mcpServers": {
"teslamate": {
"command": "uv",
"args": ["--directory", "/path/to/teslamate-mcp", "run", "main.py"]
}
}
}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 -dServer available at: http://localhost:8888/mcp
Create .env file:
DATABASE_URL=postgresql://user:pass@host:5432/teslamate
AUTH_TOKEN= # Optional: for remote authGenerate auth token (optional):
python utils/generate_token.pyVehicle Info:
get_basic_car_information- VIN, model, firmwareget_current_car_status- Real-time status, location, batteryget_software_update_history- Firmware update timeline
Battery & Health:
get_battery_health_summary- Current health metricsget_battery_degradation_over_time- Historical capacityget_daily_battery_usage_patterns- Usage patternsget_tire_pressure_weekly_trends- Tire pressure tracking
Driving Analytics:
get_monthly_driving_summary- Monthly statisticsget_daily_driving_patterns- Driving habitsget_longest_drives_by_distance- Top tripsget_total_distance_and_efficiency- Lifetime statsget_drive_summary_per_day- Daily summaries
Efficiency:
get_efficiency_by_month_and_temperature- Seasonal analysisget_average_efficiency_by_temperature- Temperature impactget_unusual_power_consumption- Anomaly detection
Charging & Location:
get_charging_by_location- Charging patternsget_all_charging_sessions_summary- Complete historyget_most_visited_locations- Frequent places
get_database_schema- View database structurerun_sql- Execute custom SELECT queries (read-only, validated)
"What's my current battery health?"
"Show me my longest drives"
"How does cold weather affect my efficiency?"
"Where do I charge most often?"
"Run a SQL query to find drives over 100km"
teslamate-mcp/
βββ src/ # Core modules
β βββ config.py # Configuration
β βββ database.py # DB operations
β βββ tools.py # Tool registry
β βββ validators.py # SQL validation
βββ queries/ # 18 SQL query files
βββ data/ # Database schema
βββ utils/ # Helper scripts
βββ main.py # Local (STDIO)
βββ main_remote.py # Remote (HTTP)
βββ Dockerfile
βββ docker-compose.yml
- Create SQL file in
queries/:
-- queries/my_query.sql
SELECT * FROM my_table;- Add to
src/tools.py:
ToolDefinition(
name="get_my_data",
description="What this returns",
sql_file="my_query.sql",
)- Restart server - tool auto-registers!
python test_server.py- Authentication: Optional bearer token for remote access
- SQL Validation: Only SELECT queries allowed
- Read-only: No data modification possible
- Use HTTPS: In production environments
This project is licensed under the MIT License. See the LICENSE file for details.
- TeslaMate - Tesla data logging
- Model Context Protocol - AI integration protocol