MCP server for controlling Tuya smart home devices via Claude Desktop and other MCP clients
Project description
mcp-server-tuya
A Model Context Protocol (MCP) server that lets Claude and other LLMs control your Tuya / Smart Life smart home devices.
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, Claude Code, 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 Claude Desktop
Add this to your Claude Desktop 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"
}
}
}
}
3. Restart Claude Desktop
That's it! Ask Claude 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
Claude Code
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"
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 Claude Desktop 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 in Claude Desktop
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_tuya-0.1.0.tar.gz.
File metadata
- Download URL: mcp_server_tuya-0.1.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.3 cpython/3.10.0 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56fd976447bcb6ee6672eaaa1cb097a137ed009bf0e75301d0f3ce5ebaac16a5
|
|
| MD5 |
4fd3f800d821ca6caac77c0efcfd2bfa
|
|
| BLAKE2b-256 |
d339d2a411adec1441de36903dec195a77a12408f93bacb9957491c36a2ba68b
|
File details
Details for the file mcp_server_tuya-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mcp_server_tuya-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.3 cpython/3.10.0 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00948f0b25d4f97d147e3190739d86ed1a066abf4c9c064f58bc6ed0d82903e8
|
|
| MD5 |
44ef6ddd4e4f15b57658e81a5a62ed00
|
|
| BLAKE2b-256 |
680960205fb187deb9bc953942370dab0a890bc68e25318a2c8720f8a91386a2
|