tesla-fleet-mcp
Allows reading Tesla vehicle status through the official Fleet API: lists vehicles and retrieves cached or live data for battery, range, charging, temperatures, climate, locks, sentry mode, doors, windows, and trunks, without waking the vehicle.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
tesla-fleet-mcp
一个自托管的 MCP 服务。它通过特斯拉官方 Fleet API,让 AI 助手(如 Today、Claude、MCP Inspector)读取你自己车辆的状态。
只读:一期只申请
vehicle_device_data权限,不能开锁、开空调或控制充电。不唤醒车辆:默认读取车辆最近一次上报的缓存数据。只有车辆本来就在线时才读实时数据。服务从不调用
wake_up,不会耗电,也不占每天 15 次的唤醒配额。默认国区:默认连接
tesla.cn的接口,海外区域可以通过环境变量切换。一个服务对应一位车主:特斯拉 token 加密保存在你自己的机器上,不经过任何第三方。
本项目与特斯拉公司无关,不是官方产品。
提供的工具
工具 | 说明 |
| 列出账号下的车辆,包括 VIN、名称和在线状态(online / asleep / offline)。 |
| 读取电量、续航(公里)、充电状态、充电上限、车内外温度、空调、锁车、哨兵模式、车门车窗和前后备箱。可选参数 |
get_vehicle_status 返回的 source 字段表示数据来源:
| 含义 |
| 车辆最近一次上报的数据。可能是几个小时前的,具体时间看各部分的 |
| 实时数据。只在车辆已经在线时才会读取。 |
| 车辆在休眠或离线,而且没有缓存。 |
Related MCP server: Tessie MCP Server
准备工作
特斯拉开发者应用。在 developer.tesla.cn(海外用 developer.tesla.com)创建应用:
授权类型选「授权代码和机器对机器」。
允许的来源填你托管公钥的域名,例如
https://你的用户名.github.io。如果要在本地调试,再加一条http://localhost:3000。重定向 URI 填
http://localhost:3000/auth/callback。部署到公网后,再加https://你的域名/auth/callback。权限范围勾选「车辆信息」。
Node.js 20.12 或更高版本。
车主至少登录过一次特斯拉 App,车辆已绑定在这个账号下。
本地运行
git clone https://github.com/frankorbit/tesla-fleet-mcp.git
cd tesla-fleet-mcp
npm install1. 保存 client secret。 macOS 上推荐存进钥匙串,服务启动时会自动读取。执行下面的命令后,在提示处粘贴开发者应用的 client secret:
security add-generic-password -a "$USER" -s tesla-fleet-client-secret -w其他系统可以在 .env.local 里设置 TESLA_CLIENT_SECRET。
2. 生成本地配置。 这一步会生成 .env.local(权限 0600),里面包括随机的访问 Key MCP_ACCESS_KEY 和 token 加密密钥:
TESLA_CLIENT_ID=你的client_id npm run setup3. 注册合作方(每个应用、每个区域只做一次)。 Fleet API 要求先把应用域名注册到对应区域,否则所有车辆接口都会被拒绝。
先生成密钥对:
npm run partner -- keygenkeys/private-key.pem是私钥,留在本地并备份,后续做车辆控制时需要用到。keys/com.tesla.3p.public-key.pem是公钥,要发布到https://你的域名/.well-known/appspecific/com.tesla.3p.public-key.pem。
公钥能访问后,再执行注册:
npm run partner -- register 你的用户名.github.io用 GitHub Pages 托管公钥时,仓库根目录要有 .nojekyll 文件,否则 .well-known 目录不会被发布。
4. 启动服务。
npm run dev5. 授权特斯拉账号。 打开 http://localhost:3000/auth/login,输入 .env.local 里的 MCP_ACCESS_KEY,跳转到特斯拉登录并同意授权。看到「已连接特斯拉」就完成了。
token 加密保存在 data/tesla-token.enc。之后服务会自动刷新 token,不需要重复登录。特斯拉的 refresh token 有效期 3 个月,只要期间服务用过一次就会自动续期。
6. 测试工具。 用 MCP Inspector 连接:
npx @modelcontextprotocol/inspector在 Inspector 里这样填写:
Transport 选 Streamable HTTP。
URL 填
http://localhost:3000/mcp。添加请求头
Authorization: Bearer <MCP_ACCESS_KEY>。
接入 Today 等远程客户端
Today 的自定义 MCP 只支持公网 HTTPS 地址,所以服务需要部署出去,或者用隧道暴露出去:
Fly.io(仓库自带
Dockerfile和fly.toml):先把fly.toml里的 app 名和PUBLIC_BASE_URL换成你自己的,然后执行:fly apps create <app名> fly volumes create tesla_data --region nrt --size 1 fly secrets set TESLA_CLIENT_SECRET=... MCP_ACCESS_KEY=... TOKEN_ENCRYPTION_KEY=... fly deploy --ha=false磁盘只能挂到一台机器上,所以要用
--ha=false。部署后在特斯拉开发者后台补上https://<app名>.fly.dev作为允许的来源,补上https://<app名>.fly.dev/auth/callback作为重定向 URI。其他平台:任何能运行 Node 或 Docker 的平台都可以,例如 VPS 或 Render。需要设置这些环境变量:
PUBLIC_BASE_URL=https://你的域名TESLA_CLIENT_IDTESLA_CLIENT_SECRETMCP_ACCESS_KEYTOKEN_ENCRYPTION_KEY
DATA_DIR必须指向持久化磁盘。否则每次重启都会丢失授权,需要重新登录。临时隧道:例如
cloudflared tunnel --url http://localhost:3000。授权仍然可以在本地localhost完成,隧道只用来对外暴露/mcp。这种用法要设置:TESLA_REDIRECT_URI=http://localhost:3000/auth/callback,让授权回调仍然走本地。HOST=0.0.0.0,前提是隧道进程不在本机运行。
在 Today 中添加自定义连接器,地址填 https://你的域名/mcp,认证方式选 Bearer token,值填 MCP_ACCESS_KEY。
配置项
完整说明见 .env.example。
变量 | 默认值 | 说明 |
| 无,必填 | 开发者应用的 client id。 |
| 读取钥匙串 | 开发者应用的 client secret。 |
| 无,必填,至少 32 位 | MCP 客户端调用 |
| 无,必填 | 32 字节密钥的 base64 编码,用于加密保存的 token。 |
|
| 服务的对外地址。 |
|
| 必须和开发者应用里填写的重定向 URI 一致。 |
| 本地 | 监听地址和端口。公网部署时 |
|
| 加密 token 文件的存放目录。 |
| 国区地址 | 海外区域需要同时覆盖这三个,取值见 |
安全说明
所有接口都需要
MCP_ACCESS_KEY,只有/healthz和授权登录页例外。比较时使用常量时间比较。发起特斯拉授权前必须输入访问 Key。否则服务部署到公网后,任何人都能把自己的特斯拉账号绑定到你的服务上。
授权用的
state一次有效,10 分钟后过期。token 用 AES-256-GCM 加密后保存。文件权限 0600,目录权限 0700。
工具返回的结果只包含上面列出的字段,不会把特斯拉的原始响应转发给模型。服务不申请位置权限,也不读取位置。
不要提交
.env.local、data/和keys/,这三个已经写进.gitignore。
配额
国区「发现级」套餐的配额是每辆车每天 200 次数据请求和 15 次唤醒。本服务从不唤醒车辆,正常对话用不完数据配额。超出配额时,工具会返回 rate_limited。
路线图
车辆控制:锁车 / 解锁、空调、充电上限。需要申请
vehicle_cmds/vehicle_charging_cmds权限,车主还要在车上添加虚拟钥匙(https://tesla.com/_ak/你的域名),并且需要 Vehicle Command Protocol 签名。位置(需要
vehicle_location权限)。提供 Docker 镜像。
开发
npm run typecheck
npm test
npm run build许可证
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
AI for your car: check charge, start climate, lock/unlock, open trunk via Tesla Fleet API. OAuth.
Control your Tesla from your AI assistant - climate, charging, access, and security.
Tesla data for your AI: battery, range, charging, tires, alerts, history. Controls off by default.
Tesla Fleet API for AI: send navigation destinations, read battery and location, run car commands.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides access to Tesla vehicle telemetry data via the Tessie API, enabling real-time monitoring of battery status, charging state, climate controls, location, and other vehicle metrics through 30+ tools with intelligent caching.-
- AlicenseAqualityDmaintenanceEnables AI assistants to control and monitor Tesla vehicles via natural language through the Tessie API, supporting battery, climate, security, charging, and more.611MIT
- AlicenseNot gradedqualityCmaintenanceIntegrates with Tesla Fleet API and TeslaMate API to control vehicles, monitor energy (Powerwall/Solar), manage charging, and analyze driving data, with generative UI and skill workflows.5MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to monitor a Hyundai, Kia, or Genesis vehicle's charge, fuel, range, locks, and location, and optionally pre-heat the cabin, lock or unlock doors, and start or stop charging. Reads come from cached Bluelink data with rate-limited refreshes, and all write commands are disabled by default.232MIT