Tesla MCP Server

Tesla MCP Server

Enables control and monitoring of Tesla vehicles through the Tessie API, providing access to vehicle state (battery, location, climate) and commands (lock/unlock, climate control, navigation) with support for both local and Cloudflare Worker deployment.

Category
访问服务器

README

Tesla MCP Server

Streamable HTTP MCP server for Tesla vehicle control via the Tessie API.

Author: overment

[!WARNING] You connect this server to your MCP client at your own responsibility. Language models can make mistakes, misinterpret instructions, or perform unintended actions. Always verify commands before execution, especially for actions like unlocking, opening trunks, or sending navigation destinations.

The HTTP layer is designed for convenience during development, not production-grade security. If deploying remotely, harden it: proper token validation, secure storage, TLS termination, strict CORS/origin checks, rate limiting, and audit logging.

Notice

This repo works in two ways:

  • As a Node/Hono server for local workflows
  • As a Cloudflare Worker for remote interactions

Features

  • State — Battery, range, location, climate, doors, charging status
  • Commands — Lock/unlock, climate, trunks, sentry, navigation
  • Location-aware — GPS coordinates for context-aware interactions
  • Dual Runtime — Node.js/Bun or Cloudflare Workers

Design Principles

  • LLM-friendly: Two unified tools, not 1:1 API mirrors
  • Watch-ready: Designed for AI agents with location context
  • Secure: Tessie API key stored as secret, clients use separate bearer token
  • Clear feedback: Detailed command results and vehicle state

Installation

Prerequisites: Bun, Tessie Account.

Ways to Run (Pick One)

  1. Local Development — Standard setup with bearer token auth
  2. Cloudflare Worker (wrangler dev) — Local Worker testing
  3. Cloudflare Worker (deploy) — Remote production

1. Local Development — Quick Start

  1. Get Tessie credentials:

    • Visit developer.tessie.com
    • Go to Developer SettingsGenerate Access Token
    • Copy your access token
    • Note your vehicle's VIN
  2. Configure environment:

cd tesla-mcp
bun install
cp .env.example .env

Edit .env:

PORT=3000
AUTH_ENABLED=true
AUTH_STRATEGY=bearer

# Generate with: openssl rand -hex 32
BEARER_TOKEN=your-random-auth-token

# Tessie credentials
TESSIE_ACCESS_TOKEN=your-tessie-access-token
TESSIE_VIN=your-vehicle-vin
  1. Run:
bun dev
# MCP: http://127.0.0.1:3000/mcp

Claude Desktop / Cursor:

{
  "mcpServers": {
    "tesla": {
      "command": "npx",
      "args": ["mcp-remote", "http://localhost:3000/mcp", "--transport", "http-only"],
      "env": { "NO_PROXY": "127.0.0.1,localhost" }
    }
  }
}

2. Cloudflare Worker (Local Dev)

bun x wrangler dev --local | cat

Create .dev.vars for local secrets:

BEARER_TOKEN=your_random_auth_token
TESSIE_ACCESS_TOKEN=your_tessie_token
TESSIE_VIN=your_vehicle_vin

Endpoint: http://127.0.0.1:8787/mcp


3. Cloudflare Worker (Deploy)

  1. Create KV namespace for session storage:
bun x wrangler kv:namespace create TOKENS

Output will show:

Add the following to your wrangler.toml:
[[kv_namespaces]]
binding = "TOKENS"
id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  1. Update wrangler.toml with your KV namespace ID:
[[kv_namespaces]]
binding = "TOKENS"
id = "your-kv-namespace-id-from-step-1"
  1. Set secrets:
# Generate a random token for client authentication
openssl rand -hex 32
bun x wrangler secret put BEARER_TOKEN
# Paste the generated token when prompted

# Tessie API credentials
bun x wrangler secret put TESSIE_ACCESS_TOKEN
# Paste your Tessie token when prompted

bun x wrangler secret put TESSIE_VIN
# Paste your VIN when prompted
  1. Deploy:
bun x wrangler deploy

Endpoint: https://<worker-name>.<account>.workers.dev/mcp


Client Configuration

Alice App

Add as MCP server with:

  • URL: https://your-worker.workers.dev/mcp
  • Type: streamable-http
  • Header: Authorization: Bearer <your-BEARER_TOKEN>

Claude Desktop / Cursor (Local Server)

{
  "mcpServers": {
    "tesla": {
      "command": "npx",
      "args": ["mcp-remote", "http://127.0.0.1:3000/mcp", "--transport", "http-only"],
      "env": { "NO_PROXY": "127.0.0.1,localhost" }
    }
  }
}

Claude Desktop / Cursor (Cloudflare Worker)

{
  "mcpServers": {
    "tesla": {
      "command": "npx",
      "args": ["mcp-remote", "https://your-worker.workers.dev/mcp", "--transport", "http-only"]
    }
  }
}

MCP Inspector (Quick Test)

bunx @modelcontextprotocol/inspector
# Connect to: http://localhost:3000/mcp (local) or https://your-worker.workers.dev/mcp (remote)

Tools

tesla_state

Get the current state of your Tesla vehicle.

// Input
{}

// Output
{
  display_name: string;           // Vehicle name
  battery_level: number;          // 0-100%
  battery_range_km: number;       // Estimated range in km
  charging: {
    state: string;                // "Disconnected", "Charging", "Complete", "Stopped"
    minutes_remaining: number | null;
    charge_limit: number;         // Charge limit %
  };
  location: {
    latitude: number;
    longitude: number;
    heading: number;              // 0-359°
    speed: number | null;         // km/h or null if parked
  };
  locked: boolean;
  sentry_mode: boolean;
  climate: {
    is_on: boolean;
    inside_temp: number;          // °C
    outside_temp: number;         // °C
    target_temp: number;          // °C
    is_defrosting: boolean;
  };
  doors: {
    front_left: boolean;          // true = open
    front_right: boolean;
    rear_left: boolean;
    rear_right: boolean;
    frunk: boolean;
    trunk: boolean;
    charge_port: boolean;
  };
  state: "online" | "asleep" | "offline";
  odometer_km: number;
  last_updated: string;           // ISO 8601
}

tesla_command

Execute commands on your Tesla vehicle.

// Input
{
  command: "lock" | "unlock" | "start_climate" | "stop_climate" |
           "set_temperature" | "start_defrost" | "stop_defrost" |
           "open_frunk" | "open_trunk" | "open_charge_port" |
           "close_charge_port" | "enable_sentry" | "disable_sentry" |
           "flash" | "honk" | "share";
  temperature?: number;           // Required for set_temperature (15-28°C)
  destination?: string;           // Required for share
  locale?: string;                // Optional for share (e.g., "en-US")
}

// Output
{
  success: boolean;
  command: string;
  message: string;
}

Commands Reference:

Command Description Parameters
lock Lock the vehicle
unlock Unlock the vehicle
start_climate Start climate control
stop_climate Stop climate control
set_temperature Set cabin temperature temperature (15-28°C)
start_defrost Turn on max defrost
stop_defrost Turn off defrost
open_frunk Open front trunk
open_trunk Toggle rear trunk
open_charge_port Open charge port door
close_charge_port Close charge port door
enable_sentry Enable sentry mode
disable_sentry Disable sentry mode
flash Flash the lights
honk Honk the horn
share Send destination to navigation destination, locale?

Examples

1. Get vehicle state

{
  "name": "tesla_state",
  "arguments": {}
}

2. Lock the car

{
  "name": "tesla_command",
  "arguments": {
    "command": "lock"
  }
}

3. Set temperature to 22°C

{
  "name": "tesla_command",
  "arguments": {
    "command": "set_temperature",
    "temperature": 22
  }
}

4. Start climate before leaving

{
  "name": "tesla_command",
  "arguments": {
    "command": "start_climate"
  }
}

5. Navigate to a destination

{
  "name": "tesla_command",
  "arguments": {
    "command": "share",
    "destination": "Golden Gate Bridge, San Francisco"
  }
}

Authentication Flow

┌─────────────────────────────────────────────────────────────────┐
│  Client (Alice App, Claude Desktop)                             │
│      │                                                          │
│      │ Authorization: Bearer <BEARER_TOKEN>                     │
│      ▼                                                          │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │  Cloudflare Worker / Node.js Server                      │   │
│  │                                                          │   │
│  │  1. Validate BEARER_TOKEN (client auth)                  │   │
│  │  2. Use TESSIE_ACCESS_TOKEN (internal API key)           │   │
│  │                                                          │   │
│  │  env.TESSIE_ACCESS_TOKEN ──┐                             │   │
│  │  env.TESSIE_VIN ───────────┼──► TessieClient             │   │
│  │                            │         │                   │   │
│  │                            │         ▼                   │   │
│  │                            │   api.tessie.com            │   │
│  └─────────────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────────────┘

Key points:

  • BEARER_TOKEN: Random token you generate — authenticates clients to your MCP server
  • TESSIE_ACCESS_TOKEN: Your Tessie API key — used internally by the server
  • Clients never see your Tessie credentials

HTTP Endpoints

Endpoint Method Purpose
/mcp POST MCP JSON-RPC 2.0
/health GET Health check

Development

bun dev           # Start with hot reload
bun run typecheck # TypeScript check
bun run lint      # Lint code
bun run build     # Production build
bun start         # Run production

Architecture

src/
├── shared/
│   └── tools/
│       ├── tesla-state.ts      # Get vehicle state
│       └── tesla-command.ts    # Execute commands
├── services/
│   └── tessie.service.ts       # Tessie API client
├── schemas/
│   ├── commands.ts             # Command definitions
│   ├── outputs.ts              # Tool output schemas
│   └── tessie.ts               # Tessie API response schemas
├── config/
│   └── metadata.ts             # Server & tool descriptions
├── index.ts                    # Node.js entry
└── worker.ts                   # Workers entry

Environment Variables

Node.js (.env)

Variable Required Description
TESSIE_ACCESS_TOKEN Tessie API access token
TESSIE_VIN Tesla Vehicle VIN
BEARER_TOKEN Auth token for MCP clients
PORT Server port (default: 3000)
HOST Server host (default: 127.0.0.1)
AUTH_ENABLED Enable auth (default: true)
AUTH_STRATEGY bearer (default)

Cloudflare Workers (wrangler.toml + secrets)

wrangler.toml vars:

AUTH_ENABLED = "true"
AUTH_STRATEGY = "bearer"

Secrets (set via wrangler secret put):

  • BEARER_TOKEN — Random auth token for clients
  • TESSIE_ACCESS_TOKEN — Tessie API access token
  • TESSIE_VIN — Your vehicle's VIN

KV Namespace:

[[kv_namespaces]]
binding = "TOKENS"
id = "your-kv-namespace-id"

Troubleshooting

Issue Solution
401 Unauthorized Check BEARER_TOKEN is set and client sends Authorization: Bearer <token>
"TESSIE_ACCESS_TOKEN not configured" Set secret: wrangler secret put TESSIE_ACCESS_TOKEN
"TESSIE_VIN not configured" Set secret: wrangler secret put TESSIE_VIN
"Tessie API error" Verify TESSIE_ACCESS_TOKEN is valid at developer.tessie.com
Vehicle not found Check TESSIE_VIN is correct (17 characters)
Vehicle offline Vehicle may be in deep sleep. Commands will wake it (takes ~30s)
Command timeout Tessie waits up to 90s for vehicle wake. Try again.
KV namespace error Run wrangler kv:namespace create TOKENS and update wrangler.toml
"ReadableStream is not defined" Node.js version too old (needs 18+). Use full path to newer node.
"spawn bunx ENOENT" Claude Desktop can't find bunx. Use npx instead.

Debugging

Test with MCP Inspector:

bunx @modelcontextprotocol/inspector
# Connect to your endpoint and test tools

Check Worker logs:

wrangler tail

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选