Tuya Smart Home MCP server

Integrates with Tuya smart home devices using tinytuya, enabling control and monitoring for home automation scenarios like voice commands and energy optimization.
Back to servers
Provider
Cabra Lattice
Release date
Feb 04, 2025
Language
Python
Package
Stats
3.4K downloads
2 stars

The tuyactl tool allows you to control Tuya smart devices using simple command-line commands. It requires a separate Tuya Server running in the background (tuyad) and uses local keys to securely communicate with your devices.

Requirements

  • uv: A fast Python package installer and runner
  • Tuya Local Keys: Device-specific keys needed to control your Tuya devices

Installation

Install uv

Install the uv package manager by running:

curl -LsSf https://astral.sh/uv/install.sh | sh

Obtain Tuya Local Keys

  1. Follow the tinytuya setup wizard to discover your devices and obtain their local keys
  2. Place the resulting snapshot.json file in your home directory (~)

Start the Tuya Server

Run the server in the background with:

nohup tuyad > tuyad.log 2>&1 &

This launches the tuyad server as a background process and saves its output to tuyad.log.

Using tuyactl

View Available Commands

To see all available commands and options:

tuyactl --help

Basic Command Structure

tuyactl <command> [options]

List Your Devices

Display all your Tuya devices:

tuyactl list

Control Device Power

Turn devices on or off:

tuyactl on <device-id>
tuyactl off <device-id>

Adjust Lighting

For smart lights, you can control various parameters:

# Set brightness (1-100%)
tuyactl brightness <device-id> 75

# Set color temperature
tuyactl temperature <device-id> 5000

# Set color (RGB)
tuyactl color <device-id> 255,0,0

# Set lighting mode
tuyactl mode <device-id> <mode-name>

# Enable music mode
tuyactl music <device-id>

Configuration

You can customize the location of your snapshot.json file (which contains your device keys) using environment variables. By default, tuyactl looks for this file in your home directory.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later