TeslaMate MCP Server
A Model Context Protocol (MCP) server that connects your TeslaMate database to AI assistants, enabling natural language queries about your Tesla data.
Features
- 🚗 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
Prerequisites
- TeslaMate running with PostgreSQL
- Python 3.11+ (for local) or Docker (for remote)
Quick Start
Local Setup (Cursor/Claude Desktop)
git clone https://github.com/cobanov/teslamate-mcp.git
cd teslamate-mcp
cp env.example .env
# Edit .env with your DATABASE_URL
uv sync
Configure your MCP client:
{
"mcpServers": {
"teslamate": {
"command": "uv",
"args": ["--directory", "/path/to/teslamate-mcp", "run", "main.py"]
}
}
}
Remote Setup (Docker)
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
Server available at: http://localhost:8888/mcp
Configuration
Create .env file:
DATABASE_URL=postgresql://user:pass@host:5432/teslamate
AUTH_TOKEN= # Optional: for remote auth
Generate auth token (optional):
python utils/generate_token.py
Available Tools
Predefined Queries (18 tools)
Vehicle 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
Custom Queries (2 tools)
get_database_schema- View database structurerun_sql- Execute custom SELECT queries (read-only, validated)
Example Queries
"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"
Project Structure
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
Development
Adding New Queries
- 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!
Testing
python test_server.py
Security
- Authentication: Optional bearer token for remote access
- SQL Validation: Only SELECT queries allowed
- Read-only: No data modification possible
- Use HTTPS: In production environments
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- TeslaMate - Tesla data logging
- Model Context Protocol - AI integration protocol
Metadata
Release files for iflow-mcp_cobanov-teslamate-mcp 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iflow_mcp_cobanov_teslamate_mcp-0.2.2.tar.gz | 7.9 kB | Without provenance | Details for iflow_mcp_cobanov_teslamate_mcp-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| iflow_mcp_cobanov_teslamate_mcp-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for iflow_mcp_cobanov_teslamate_mcp-0.2.2-py3-none-any.whl |
Total release size: 17.5 kB
Release files / iflow_mcp_cobanov_teslamate_mcp-0.2.2.tar.gz
| Download URL | iflow_mcp_cobanov_teslamate_mcp-0.2.2.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04f53857f6c85ebdd0b5d4ac12d2cd62e83123ad598e487017845a5def5de9a8
|
|
BLAKE2b-256 checksum How to use checksums |
c1416b1a00ef89ee8b62d5197075d2162f37e6d9bd8600f42a6a73dea92600a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / iflow_mcp_cobanov_teslamate_mcp-0.2.2-py3-none-any.whl
| Download URL | iflow_mcp_cobanov_teslamate_mcp-0.2.2-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d45b42f6198119cd022cf5c650e1a2dfa6c6cb795c99371a3b40c1feff363629
|
|
BLAKE2b-256 checksum How to use checksums |
df25d2ce34a9c9f2ec6dbfcd35c027ffb81473ad6340f599b62eccd12a84ff60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for iflow-mcp_cobanov-teslamate-mcp 0.2.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.