tuya-infrared-mcp
An MCP server that enables AI assistants to control devices via Tuya infrared remote control, supporting actions like toggling power and setting modes through natural language.
README
Tuya Infrared MCP Server
English | 中文
A Model Context Protocol (MCP) server that allows AI assistants to control devices through Tuya infrared remote control.
Features
- 🎮 Control devices via Tuya infrared remote control
- 🔌 MCP protocol support (Streamable HTTP)
- 🌐 RESTful API with health check endpoint
- ⚙️ Easy configuration via environment variables
- 🔒 Secure credential management
Prerequisites
- Node.js >= 14.0.0
- Tuya IoT Platform account
- Tuya infrared remote control device
- Learned IR codes for your target device
Quick Start
1. Install Dependencies
npm install
2. Configure Environment Variables
Copy .env.example to .env and fill in your credentials:
cp .env.example .env
Edit .env:
TUYA_BASE_URL=https://openapi.tuyacn.com
TUYA_ACCESS_ID=your_access_id_here
TUYA_ACCESS_SECRET=your_access_secret_here
TUYA_DEVICE_ID=your_device_id_here
TUYA_REMOTE_ID=your_remote_id_here
TUYA_CATEGORY_ID=13
KEY_SWITCH=your_switch_key_here
KEY_MODE_15MIN=your_mode_key_here
PORT=3036
3. Run Server
npm start
Server will run on http://localhost:3036
How to Get Tuya Credentials
Step 1: Create Tuya IoT Platform Account
- Go to Tuya IoT Platform
- Register and create a new project
- Choose "Custom Development"
- Select data center (e.g., China)
Step 2: Get API Credentials
- Go to your project dashboard
- Navigate to "Overview" → "Authorization Key"
- Copy
Access IDandAccess Secret
Step 3: Enable Infrared API Service
- Go to "Service API" tab
- Search for "Infrared Remote Control" (万能红外开放能力)
- Enable the service
Step 4: Link Your Device
- Add your Tuya infrared remote to Tuya Smart App
- Go to project "Devices" tab
- Click "Link Tuya App Account"
- Link your Tuya Smart App account
- Your device will appear in the device list
Step 5: Get Device Information
Use the test script to get device info:
const { TuyaContext } = require('@tuya/tuya-connector-nodejs');
const context = new TuyaContext({
baseUrl: 'https://openapi.tuyacn.com',
accessKey: 'your_access_id',
secretKey: 'your_access_secret'
});
// Get device list
const devices = await context.request({
path: '/v1.0/devices',
method: 'GET'
});
console.log(devices);
Step 6: Learn IR Codes
- Use Tuya Smart App to learn IR codes from your device's remote
- Use API to get learned keys:
// Get remote list
const remotes = await context.request({
path: `/v1.0/infrareds/${DEVICE_ID}/remotes`,
method: 'GET'
});
// Get learned keys for a remote
const keys = await context.request({
path: `/v1.0/infrareds/${DEVICE_ID}/remotes/${REMOTE_ID}/keys`,
method: 'GET'
});
console.log(keys);
MCP Configuration
For Claude Desktop / Claude Code
Add to your MCP configuration file:
{
"mcpServers": {
"tuya-infrared": {
"transport": {
"type": "streamable-http",
"url": "http://localhost:3036/mcp"
}
}
}
}
For Remote Access
If running on a server:
{
"mcpServers": {
"tuya-infrared": {
"transport": {
"type": "streamable-http",
"url": "http://your-server-ip:3036/mcp"
}
}
}
}
Note: Make sure to open port 3036 in your firewall.
API Endpoints
Health Check
GET /health
Response:
{
"status": "ok",
"service": "tuya-infrared-mcp"
}
MCP Endpoint
POST /mcp
Content-Type: application/json
Available MCP Tools
send_infrared
Send infrared signal to control your device.
Parameters:
action(string): Action typeswitch: Toggle power switchmode_15min: Change to 15-minute mode
Example:
// In AI assistant
send_infrared({ action: "switch" })
send_infrared({ action: "mode_15min" })
Limitations
- Infrared signal requires line-of-sight
- Distance limitation (typically 1-3 meters)
- Remote control must be powered on
- Cannot work through walls or obstacles
Troubleshooting
"Sign Invalid" Error
- Check if your Access Secret is correct
- Make sure you linked your Tuya Smart App account to the project
"API Not Subscribed" Error
- Enable "Infrared Remote Control" service in your project
Connection Timeout
- Check if port 3036 is open
- Verify server is running
- Check firewall settings
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- Built with Tuya IoT Platform
- Based on Model Context Protocol
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
E2B
Using MCP to run code via e2b.