Tuya Audio Controller MCP Service is an open-source intelligent audio playback control service from Tuya, built on the Model Context Protocol (MCP) standard. It bridges the Tuya IoT cloud platform with AI large-model clients, enabling AI Agents to control audio device playback through natural language.
The project is fully open source under the MIT License — developers are free to deploy, modify, and build upon it.
| Dimension | Specification |
|---|---|
| License | MIT License |
| Deployment | Developer self-hosted (local / cloud server) |
| MCP framework | FastMCP (class-based) |
| Transport protocols | WebSocket + Streamable HTTP dual-mode |
| Supported clients | Claude Desktop / Cline / Continue.dev, and more |
| Playback intents | 9 — full coverage |
| Language support | Chinese / English / Japanese multi-language input |
| GitHub | https://github.com/tuya-community/tuya-audio-controller-mcp |
AI Client (Claude / Cline / Continue.dev)
│
▼ HTTPS + API Key (Streamable HTTP)
┌─────────────────────────────────────────┐
│ MCP Server (FastMCP) │
│ ┌─────────────┬────────────────────┐ │
│ │ query_tags │ music_play_ctrl │ │
│ └──────┬──────┴─────────┬──────────┘ │
│ │ │ │
│ Tag Service Intent Router │
│ │ ┌────┼────┐ │
│ │ Play Ctrl Mode │
└─────────┼───────────┼────┼────┼─────────┘
│ │ │ │
┌────▼────┐ ┌───▼────▼────▼───┐
│Tuya File│ │ Redis │
│Platform │ │ (State / Token │
│ API │ │ / Playlist) │
└─────────┘ └─────────────────┘
│
┌────▼────────────────┐
│ Tuya IoT Cloud │
│ (Device ctrl / │
│ MCP SDK) │
└─────────────────────┘
The service supports two transport modes simultaneously, adapting to different integration scenarios:
| Mode | Protocol | Use Case | Connection Method |
|---|---|---|---|
| WebSocket | WS / WSS | Connecting to Tuya IoT cloud for device-level messaging | Tuya MCP SDK persistent connection |
| Streamable HTTP | HTTPS | Direct connection from AI clients | RESTful requests, stateless |
WebSocket mode targets device-side communication (via the Tuya MCP SDK); Streamable HTTP mode targets AI clients (Claude Desktop, etc.). Both modes can run simultaneously.
| Component | Responsibility | Technology |
|---|---|---|
| MCP Server | Tool registration, request routing, response orchestration | FastMCP (class-based) |
| Tag Service | Audio tag management and retrieval | Tuya File Platform API |
| Intent Router | Playback intent recognition and dispatch | Rule-based routing (Play / Ctrl / Mode — three branches) |
| State Manager | Playback state, token, and playlist management | Redis |
| Auth Module | Client authentication and permission validation | URL API Key + HMAC-SHA256 |
| Intent | ID | Description | Parameters |
|---|---|---|---|
| Play | play |
Retrieve audio by tag and play | tag (tag allowlist) |
| Next | next |
Skip to next track in playlist | — |
| Previous | prev |
Skip to previous track in playlist | — |
| Pause | stop |
Pause current playback | — |
| Resume | resume |
Resume paused playback | — |
| Replay | replay |
Restart current track from beginning | — |
| Single loop | single_loop |
Set current track to loop | — |
| Sequential loop | sequential_loop |
Loop through playlist in order | — |
| Cancel loop | no_loop |
Cancel loop mode | — |
The service registers two MCP Tools for AI clients to invoke:
| Tool | Function | Input |
|---|---|---|
query_tags |
Query the list of available audio tags | No parameters |
music_play_ctrl |
Execute a playback control operation | intent + tag (optional) |
Tool descriptions follow the MCP specification, including complete parameter validation rules and semantic descriptions, ensuring accurate invocation by large models.
AI large models can produce hallucinated parameters when calling tools (fabricating tags or intents that do not exist). This service guards against that through the following mechanisms:
| Mechanism | Description |
|---|---|
| Tag allowlist | The tag parameter for the play intent must match the allowlist; invalid tags are rejected immediately |
| Intent enumeration | The intent parameter is restricted to 9 valid values; invalid intents return an error |
| Multilingual pass-through | Chinese / English / Japanese input is passed through as-is without semantic inference |
| Strict validation | Pydantic models enforce correct parameter types and formats |
The quality of MCP Tool descriptions directly affects large-model invocation accuracy. Design principles for this service’s Tool descriptions:
| Layer | Mechanism | Protects |
|---|---|---|
| Client → MCP Server | URL parameter API Key | Prevents unauthorized AI clients from connecting |
| MCP Server → Tuya Cloud | HMAC-SHA256 signature | OpenAPI call authentication |
| Dependency | Version / Notes |
|---|---|
| Python | 3.10+ |
| Redis | For state storage and caching |
| Tuya developer account | To obtain Access ID / Secret |
| Network | Access to Tuya OpenAPI |
# 1. Clone the project
git clone https://github.com/tuya-community/tuya-audio-controller-mcp.git
cd tuya-audio-controller-mcp
# 2. Configure environment variables
cp .env.example .env
# Edit .env and fill in:
# TUYA_ACCESS_ID=<Tuya Access ID>
# TUYA_ACCESS_SECRET=<Tuya Access Secret>
# REDIS_URL=<Redis connection URL>
# API_KEYS=<List of client authentication keys>
# 3. Install dependencies
pip install -r requirements.txt
# 4. Start the service
python scripts/manage_services.py start
# 5. Verify running status
python scripts/manage_services.py status
Add the MCP Server in Claude Desktop / Cline / Continue.dev:
{
"mcpServers": {
"tuya-audio-controller": {
"url": "https://your-domain.com/mcp?key=your-api-key"
}
}
}
Once configured, audio devices can be controlled through natural language:
"Play a Jay Chou song for me" → play intent, tag retrieval
"Next track" → next intent
"Set to single loop" → single_loop intent
The open-source architecture supports further development:
| Extension Direction | Location | Description |
|---|---|---|
| Add new playback intents | Intent Router | Add new intent-handling branches |
| Extend audio sources | Tag Service | Integrate other audio platform APIs |
| Custom authentication | Auth Module | Replace with OAuth / JWT or other schemes |
| Add device types | MCP Tool definitions | Extend to video devices, lighting, etc. |
| Adjust state management | State Manager | Replace Redis with another storage backend |
| Dimension | Traditional Voice Control | Custom API Integration | Tuya Audio Controller MCP |
|---|---|---|---|
| Integration method | Voice assistant binding | Write invocation code manually | MCP standard protocol — plug-and-play with any AI client |
| AI compatibility | Single platform | Requires per-client adaptation | Universal: Claude / Cline / Continue.dev |
| Anti-hallucination | Not applicable | Must handle manually | Tag allowlist + intent enumeration + strict validation |
| Deployment ownership | Vendor-hosted | Self-built | Fully self-deployable (MIT open source) |
| Extensibility | Closed | High full-development cost | Open-source architecture, extend as needed |
| Transport modes | Single | Choose per need | WebSocket + HTTP dual-mode simultaneously |
MCP (Model Context Protocol) is the standardized protocol for AI Agent tool invocation. Compared to custom API integration:
| Dimension | Custom API | MCP Standard Protocol |
|---|---|---|
| Client compatibility | Adapt each client individually | Standardized — works with all MCP clients |
| Tool discovery | Requires documentation or manual configuration | Automatic discovery and description |
| Parameter validation | Implement yourself | Built into the protocol via schema validation |
| Ecosystem reach | Isolated | Interoperable with the MCP ecosystem |
| Value | Description |
|---|---|
| Data sovereignty | Audio control data does not pass through third parties — meets privacy compliance requirements |
| Auditability | Code is fully open; security can be independently verified |
| Customizability | Freely extend intents, device types, and authentication methods to fit business needs |
| No vendor lock-in | MIT license — free to fork and modify |
| Reference implementation | Serves as an MCP Server development template; architecture can be reused for other IoT MCP services |
| Scenario | Description |
|---|---|
| Smart home audio control | Control home speakers to play music via voice or text |
| AI Agent toolchain | As an Agent capability module, giving AI the ability to control audio playback |
| MCP protocol reference implementation | A complete MCP Server development template, reusable for other device categories |
| IoT + AI education | Demonstrates the full pipeline for connecting AI large models to IoT devices |
| Enterprise private deployment | Self-hosted to meet data compliance requirements |
| Resource | URL |
|---|---|
| GitHub repository | https://github.com/tuya-community/tuya-audio-controller-mcp |
| MCP protocol specification | https://modelcontextprotocol.io |
| Tuya IoT Open Platform | https://platform.tuya.com |
| FastMCP framework | https://github.com/jlowin/fastmcp |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback