Smart Home Control MCP Server
Enables controlling smart home devices like lights, fans, air conditioners, and Android TVs through natural language commands, with persistent state and TV content search/playback via ADB.
README
🏠 Smart Home Control System
Welcome to your personal smart home automation hub! This project lets you control all your smart devices through a simple MCP (Model Context Protocol) server. Whether you want to dim the lights, crank up the AC, or binge-watch your favorite Netflix series, this system has got you covered.
What This Does
Think of this as your smart home's brain. It's an MCP server that connects to various devices around your house and lets you control them through natural language commands. You can control lights, fans, air conditioners, and even your smart TV - all from one place!
The system uses MQTT for real-time communication between devices and stores all your device states persistently, so your settings are remembered even after restarts.
🚀 Quick Setup
Prerequisites
- Python 3.11 or higher
- ADB (Android Debug Bridge) installed for TV control
- Optional: MQTT broker running on localhost
Installation
-
Clone this repository
-
Install dependencies:
uv sync -
Create a
.envfile with your authentication credentials:AUTH_TOKEN=your_secret_token_here MY_NUMBER=your_validation_number -
Run the server:
python smart_home_server.py
The server will start on http://0.0.0.0:8002 and you're ready to go!
🏡 Supported Devices
Standard Smart Devices
- Lights - Control power and brightness
- Fans - Adjust speed settings
- Air Conditioners - Set temperature
- Chimneys - Change operation modes
Smart TVs (Android TV/Google TV)
- Full remote control via ADB
- App launching (Netflix, YouTube)
- Content search and playback
- Volume and navigation control
🛠️ Available Tools
Here's everything you can do with this system:
Basic Device Control
turn_on_device(room, device_name)
Powers on any device in your smart home. Works with lights, fans, ACs, you name it!
turn_off_device(room, device_name)
Turns off devices. Pretty straightforward - the opposite of turning them on.
set_device_value(room, device_name, key, value)
This is where the magic happens! Adjust specific settings like:
- Light brightness:
set_device_value("bedroom", "light1", "brightness", "80") - Fan speed:
set_device_value("livingroom", "fan1", "speed", "3") - AC temperature:
set_device_value("bedroom", "ac1", "temperature", "22")
get_device_state(room, device_name)
Check what's going on with a specific device - is it on? What's the current brightness? Temperature?
get_all_states()
Get a complete overview of every device in your home. Perfect for checking everything at once.
TV Control - Basic Functions
tv_volume_up(room, device_name) & tv_volume_down(room, device_name)
Adjust TV volume. The system tracks the current volume level too.
tv_mute(room, device_name)
Toggle mute on your TV. Hit it again to unmute.
tv_open_app(room, device_name, app)
Launch apps on your TV. Currently supports:
netflix- Open Netflixyoutube- Open YouTubehome- Go to home screen
tv_navigate(room, device_name, direction)
Navigate your TV interface:
back- Go back one screenhome- Return to home screen
check_tv_connection(room, device_name)
Test if your TV is connected and responding. Great for troubleshooting!
TV Setup & Management
add_tv_device(room, device_name, ip_address, port=5555)
Add a new smart TV to your system. You'll need the TV's IP address (find it in your TV's network settings).
Example: add_tv_device("livingroom", "main_tv", "192.168.1.100")
update_tv_config(room, device_name, ip_address, port=5555)
Update an existing TV's network settings. Useful when your TV gets a new IP address.
remove_tv_device(room, device_name)
Remove a TV from your system completely.
list_tv_devices()
See all your configured TVs, their IP addresses, and connection status.
load_tv_configs_from_file()
Load TV configurations from a JSON file. You can manually edit device_states/tv_config.json to add multiple TVs at once.
Advanced TV Content Control
tv_search_and_play(room, device_name, query, app="netflix")
The crown jewel! Search for content and automatically start playing it.
Examples:
tv_search_and_play("livingroom", "tv", "Breaking Bad", "netflix")tv_search_and_play("bedroom", "tv", "funny cat videos", "youtube")
tv_search_content(room, device_name, query, app="netflix")
Search for content but don't auto-play. Let you browse the results first.
play_netflix_show(room, device_name, show_name)
Dedicated Netflix function with enhanced error handling and troubleshooting tips.
play_youtube_video(room, device_name, search_query)
YouTube-specific search with smart fallbacks when the interface is tricky.
youtube_voice_search_workaround(room, device_name, search_query)
Alternative YouTube search using voice search interface. Sometimes works better than regular search.
TV Remote Control
tv_send_text(room, device_name, text)
Type text into TV search fields or any text input.
tv_press_key(room, device_name, key)
Press specific remote control buttons:
- Navigation:
up,down,left,right,enter,back,home - Media:
play,pause,search,menu
youtube_navigate_and_play(room, device_name, direction="down", steps=1)
Navigate YouTube's interface manually. Useful when automatic search fails.
Troubleshooting
diagnose_tv_connection(room, device_name)
Run comprehensive diagnostics on your TV connection:
- Network connectivity test
- ADB connection status
- Device responsiveness check
- App availability verification
Perfect for figuring out why your TV isn't responding!
🏠 Room Management
The system is smart about room names. You can use natural variations:
- "living room", "livingroom", "lounge", "hall" → all become "livingroom"
- "bed room", "bedroom", "master bedroom" → all become "bedroom"
- "kitchen", "cook room" → both become "kitchen"
📁 Project Structure
hack/
├── smart_home_server.py # Main MCP server with all the tools
├── devices.py # Device classes (Light, Fan, AC, TV, etc.)
├── registry.py # Initial device registry
├── device_states/ # Persistent storage
│ ├── devices.json # Device states
│ └── tv_config.json # TV configurations
└── main.py # Entry point
🔧 Technical Details
- MCP Server: Runs on FastMCP with Bearer token authentication
- TV Control: Uses ADB (Android Debug Bridge) for smart TV interaction
- MQTT Support: Optional MQTT broker integration for real-time updates
- Persistent Storage: All device states are saved automatically
- Error Handling: Comprehensive error messages and connection diagnostics
🤔 Troubleshooting TV Setup
If your android TV isn't connecting:
- Enable Developer Options: Go to Settings → About → Keep pressing on "Build" until developer mode activates
- Enable USB Debugging: In Developer Options, turn on "USB Debugging"
- Enable Network ADB: Turn on "Network ADB" if available
- Check IP Address: Make sure you have the correct IP (Settings → Network) and IP changes everytime you start the TV
- Same Network: Ensure your TV and server are on the same WiFi network
- Use Diagnostics: Run
diagnose_tv_connection()for detailed troubleshooting
🎉 Getting Started
- Start with basic devices like lights and fans
- Add your TV using
add_tv_device() - Test the connection with
check_tv_connection() - Try some basic TV controls like volume or opening apps
- Experiment with content search and playback
- Use
diagnose_tv_connection()if you run into issues
That's it! You now have a full smart home control system that can handle everything from dimming lights to finding your next binge-watch series. Enjoy your automated home! 🏡✨
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。