# Tuya MCP

> Tuya MCP Server controls and monitors your smart home or industrial hardware through natural conversation. It lets you query device status—checking if a sensor is online, finding its category, or getting its local key—and sends real-time commands (like toggling lights or adjusting temperatures) using only text prompts. Stop jumping between apps; manage all connected Tuya devices from your AI client.

## Overview
- **Category:** productivity
- **Price:** Free
- **Tags:** smart-home, automation, device-control, tuya-cloud, hardware-management

## Description

You're sick of jumping between a dozen apps just to run your place? This server lets your AI client talk straight to your actual hardware, giving you a centralized control panel for everything connected via Tuya. It handles everything from simple switches to complex industrial sensors using only plain text conversation.

When you need to know what's going on with any device, you use **`get_device`**. This function queries and pulls detailed metadata based on a specific Tuya device ID. You get the full picture: its current online status, which hardware category it falls under, and even the local integration key—stuff you need for deep debugging or advanced setup.

To check if a device is actually running right now, **`get_device`** confirms its heartbeat status within the Tuya Cloud. It tells you instantly if that sensor or light fixture is reachable and functioning properly through your cloud project.

When it's time to take action, you use **`send_commands`**. This sends direct instructions to any connected Tuya device. You can tell your agent to toggle switches on and off, adjust brightness levels, or change the operational mode for specific hardware. It executes precise control commands directly to the target device.

Basically, if it's a smart device—whether it's running in your living room or out on an industrial site—your AI client uses these tools to manage it with just words.

## Tools

### get_device
Queries and returns the detailed metadata for a specified Tuya device ID, including status, category, and local key.

### send_commands
Sends direct control instructions to a connected Tuya device, such as toggling an LED or adjusting a switch state.

## Prompt Examples

**Prompt:** 
```
Check the status and details of device ID 'bf78234567890abcdef'.
```

**Response:** 
```
I've queried the device. It is currently Online. It's a 'Smart Plug' (Category: cz) with the local key 'a1b2c3d4...'. Would you like to send any commands to it?
```

**Prompt:** 
```
Turn on the LED for device 'eb4567890123456789'.
```

**Response:** 
```
Command sent successfully. I've instructed device 'eb4567890123456789' to set 'switch_led' to true. The device has confirmed receipt of the command.
```

**Prompt:** 
```
Is my smart heater (ID: 0123456789) reachable right now?
```

**Response:** 
```
Checking connectivity... Yes, the smart heater is currently reporting as Online in the Tuya Cloud. Its last heartbeat was received successfully.
```

## Capabilities

### Query Device Metadata
The server retrieves detailed information on a specified device ID, including its online status, hardware category, and local integration key.

### Execute Control Commands
The server sends specific instructions to the target Tuya hardware, such as turning lights on/off or setting operational modes.

### Check Device Connectivity
You check if a device is currently online and reporting its heartbeat status within the Tuya Cloud.

## Use Cases

### The Quick Night Check
A resident leaves the house late. Instead of checking three different physical switches in the app, they ask their agent: 'Are all the main lights off?' The agent calls `get_device` for multiple IDs and confirms status across the entire home.

### Debugging a Sensor
An IoT developer finds a sensor giving bad data. They use `get_device` to pull the device's local key and category metadata, which they immediately need for writing custom integration code—all without leaving their IDE.

### Emergency Shutdown
A facility manager notices a leak alarm is active. They don't have time to navigate the main control panel. They tell the agent: 'Shut down power to Zone B.' The agent executes `send_commands` on all relevant relays.

### Verifying Device Availability
Before running a major automation script, an engineer needs confirmation that 50 peripheral sensors are online. They ask the agent: 'Check connectivity for all Zone 3 devices.' The agent runs status checks to give them a clear pass/fail report.

## Benefits

- **Centralized Control:** Instead of opening a dozen apps, your AI client handles all hardware interactions. You query status or send commands directly from the chat window.
- **Deep Diagnostics:** Use `get_device` to retrieve more than just an 'online' status. You get category details and local keys—essential info for advanced troubleshooting.
- **Real-Time Action:** The `send_commands` tool lets you toggle switches, adjust brightness, or change modes instantly based on a simple text instruction.
- **Eliminates Context Switching:** Stop jumping between your smart home app, your maintenance dashboard, and your terminal. Everything is unified in one conversation flow.
- **Industry Ready:** Works for both residential smart homes (lights, plugs) and professional industrial setups (sensors, relays), making it versatile for any facility.

## How It Works

The bottom line is that your AI client acts as a single point of access, translating simple text commands into complex hardware instructions.

1. Subscribe to the server and provide your required credentials: the Tuya Client ID, Secret, and Endpoint.
2. Your AI client initiates a request by asking a question or giving an instruction (e.g., 'Turn off the kitchen lights').
3. The agent calls `get_device` for status checks or `send_commands` to perform actions, returning confirmation of success or failure.

## Frequently Asked Questions

**How can I check if a specific smart device is currently online?**
Use the `get_device` tool with the target Device ID. The agent will return the current connectivity status along with other technical metadata from the Tuya Cloud.

**Can I send multiple commands to a device at once?**
Yes! The `send_commands` tool accepts an array of command objects. You can trigger multiple actions, such as turning on a light and setting its color, in a single request.

**What kind of technical details does the agent provide for my hardware?**
By running `get_device`, the agent retrieves the device category, its unique local key, the product name, and its current operational status, allowing for deep technical auditing.

**What credentials does the agent need to use `send_commands`?**
It requires your Tuya Client ID, Secret, and Endpoint. You must provide these three pieces of information when setting up the server connection on Vinkius.

**If a command fails after using `send_commands`, how do I troubleshoot it?**
The agent returns the specific error code provided by the Tuya Cloud API. You need to cross-reference that code with your hardware documentation to fix the issue.

**When running `get_device`, what exactly is a 'local key'?**
The local key is a unique identifier for the device, specific to its physical setup. Developers use this detailed data point when building integrations that bypass standard cloud calls.

**Does `send_commands` support every type of Tuya hardware?**
It supports commands defined by standard instruction sets (like toggling or setting brightness). For specialized or custom functions, you must consult the specific documentation for that device model.

**Can I check connectivity status for devices outside my main Tuya account?**
No. This server is restricted to your connected Tuya IoT ecosystem only. Monitoring other hardware brands requires linking a different, dedicated integration service.