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.
Install the uv package manager by running:
curl -LsSf https://astral.sh/uv/install.sh | sh
snapshot.json
file in your home directory (~
)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.
To see all available commands and options:
tuyactl --help
tuyactl <command> [options]
Display all your Tuya devices:
tuyactl list
Turn devices on or off:
tuyactl on <device-id>
tuyactl off <device-id>
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>
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.
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.
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"
]
}
}
}
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.
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.