mcp-server-tuya
Enables AI assistants to control Tuya/Smart Life smart home devices via tools like on/off, brightness, color, and custom commands.
README
mcp-server-tuya
A Model Context Protocol (MCP) server that lets AI assistants (Claude, ChatGPT, Copilot, Cursor, and more) control your Tuya / Smart Life smart home devices.
<p align="center"> <img src="https://img.shields.io/badge/MCP-Compatible-green?style=for-the-badge" alt="MCP Compatible" /> <img src="https://img.shields.io/badge/Tuya-Smart%20Home-orange?style=for-the-badge" alt="Tuya Smart Home" /> </p>
Features
- 10 tools for complete device control (on/off, brightness, color, temperature, custom commands)
- Device name resolution — use friendly names like "Living Room Light" instead of IDs
- Intelligent caching — configurable TTL to reduce API calls
- All Tuya regions — EU, US, CN, IN
- Zero config files — credentials via environment variables
- Works with Claude Desktop, ChatGPT, GitHub Copilot, Cursor, Windsurf, Cline, and any MCP-compatible client
Quick Start
1. Get Tuya Credentials
- Go to Tuya IoT Platform and create an account
- Create a Cloud Project (select your region and "Smart Home" industry)
- Go to Devices > Link Tuya App Account and link your Smart Life / Tuya Smart app
- Copy your Access ID and Access Secret from the project overview
2. Configure your MCP client
<details> <summary><b>Claude Desktop</b></summary>
Add this to your config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"tuya": {
"command": "uvx",
"args": ["mcp-server-tuya"],
"env": {
"TUYA_ACCESS_ID": "your_access_id",
"TUYA_ACCESS_KEY": "your_access_key",
"TUYA_API_ENDPOINT": "https://openapi.tuyaeu.com"
}
}
}
}
</details>
<details> <summary><b>Claude Code</b></summary>
claude mcp add tuya -- uvx mcp-server-tuya
Then set your environment variables:
export TUYA_ACCESS_ID="your_access_id"
export TUYA_ACCESS_KEY="your_access_key"
export TUYA_API_ENDPOINT="https://openapi.tuyaeu.com"
</details>
<details> <summary><b>Cursor</b></summary>
Add this to .cursor/mcp.json in your project:
{
"mcpServers": {
"tuya": {
"command": "uvx",
"args": ["mcp-server-tuya"],
"env": {
"TUYA_ACCESS_ID": "your_access_id",
"TUYA_ACCESS_KEY": "your_access_key",
"TUYA_API_ENDPOINT": "https://openapi.tuyaeu.com"
}
}
}
}
</details>
<details> <summary><b>VS Code (GitHub Copilot)</b></summary>
Add this to your .vscode/settings.json:
{
"mcp": {
"servers": {
"tuya": {
"command": "uvx",
"args": ["mcp-server-tuya"],
"env": {
"TUYA_ACCESS_ID": "your_access_id",
"TUYA_ACCESS_KEY": "your_access_key",
"TUYA_API_ENDPOINT": "https://openapi.tuyaeu.com"
}
}
}
}
}
</details>
<details> <summary><b>ChatGPT / Other MCP clients</b></summary>
Any MCP-compatible client can use this server. The general pattern is:
- Command:
uvx - Args:
["mcp-server-tuya"] - Environment variables:
TUYA_ACCESS_ID,TUYA_ACCESS_KEY,TUYA_API_ENDPOINT
Refer to your client's documentation for how to configure MCP servers. </details>
3. Restart your client
That's it! Ask your AI assistant things like:
- "List all my devices"
- "Turn off the living room light"
- "Set the bedroom light to 50% brightness"
- "What's the temperature in the kitchen?"
- "Turn everything off"
Installation
With uvx (recommended)
No installation needed — uvx runs it directly:
uvx mcp-server-tuya
With pip
pip install mcp-server-tuya
From GitHub
pip install git+https://github.com/juanmartinsantos/mcp-server-tuya.git
Available Tools
| Tool | Description |
|---|---|
tuya_list_devices |
List all devices with IDs, names, categories, and online status |
tuya_get_device_status |
Get current device state (power, brightness, temperature, etc.) |
tuya_get_device_info |
Get detailed device info (model, firmware, capabilities) |
tuya_turn_on_device |
Turn on a device (supports multi-switch devices) |
tuya_turn_off_device |
Turn off a device (supports multi-switch devices) |
tuya_toggle_device |
Toggle device on/off |
tuya_set_brightness |
Set light brightness (0-1000) |
tuya_set_color_temperature |
Set color temperature: warm (0) to cool (1000) |
tuya_set_color |
Set RGB color using HSV values |
tuya_send_command |
Send any custom command to a device |
All tools accept either a device ID or a device name (e.g., "Living Room Light").
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
TUYA_ACCESS_ID |
Yes | — | Tuya Cloud API Access ID |
TUYA_ACCESS_KEY |
Yes | — | Tuya Cloud API Access Secret |
TUYA_API_ENDPOINT |
No | https://openapi.tuyaeu.com |
API endpoint (see regions below) |
TUYA_CACHE_TTL |
No | 60 |
Device list cache duration (seconds) |
TUYA_REQUEST_TIMEOUT |
No | 10 |
API request timeout (seconds) |
API Endpoints by Region
| Region | Endpoint |
|---|---|
| Europe | https://openapi.tuyaeu.com |
| Americas | https://openapi.tuyaus.com |
| China | https://openapi.tuyacn.com |
| India | https://openapi.tuyain.com |
Local Development
# Clone the repository
git clone https://github.com/juanmartinsantos/mcp-server-tuya.git
cd mcp-server-tuya
# Create virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS/Linux
# Install in editable mode
pip install -e ".[dev]"
# Copy and configure environment
cp .env.example .env
# Edit .env with your credentials
# Run the server
mcp-server-tuya
# or: python -m mcp_server_tuya
Troubleshooting
"TUYA_ACCESS_ID environment variable is required"
Your credentials are not set. Make sure you've added the env section to your MCP client config.
"API error: permission deny"
Your Tuya Cloud project doesn't have the right permissions. Go to Tuya IoT Platform > your project > Service API and enable IoT Core and Smart Home APIs.
"Device not found"
The device name doesn't match. Use tuya_list_devices first to see the exact names of your devices.
Server won't start
Make sure you have uv installed. Install it with:
# Windows
winget install --id=astral-sh.uv
# macOS
brew install uv
License
MIT License - see LICENSE for details.
Credits
- FastMCP — Pythonic MCP server framework
- tuya-connector-python — Official Tuya Cloud SDK
- Model Context Protocol — by Anthropic
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。