MCP理念-模型上下文协议服务器
用于将Claude与硬件设备和家庭自动化集成的MCP服务器集合。
可用的MCP服务器
1.家庭助理服务器(server_home_assistant.py)
通过完全集成家庭助理的Claude控制您的智能家居设备。
特征:
- 光:控制飞利浦秀灯泡和其他灯(开/关、亮度、RGB颜色)
- 气候:读取温度,控制恒温器
- 锁:锁定/解锁智能锁
- 相机:查看快照,发送到Telegram
- 开关:控制智能插头(Tapo等)
- 封面:打开/关闭车库门、百叶窗
- 传感器:读取所有传感器数据(运动、空气质量等)
- 媒体播放器:文本转语音公告
- 电报:发送消息和相机快照
2.Tello无人机服务器(server_tello.py)
通过Claude命令驾驶和控制DJI Tello无人机。
特征:
- 飞行控制(起飞、着陆、移动、旋转、翻转)
- 相机快照捕捉
- 电池和传感器监测
- 视频流(Windows与OpenCV兼容)
快速设置
1.安装依赖项
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
# Install requirements
pip install -r requirements.txt2.配置环境变量
创建一个 .env 使用您的凭据文件:
# Home Assistant Configuration
HA_URL=http://localhost:8123
HA_TOKEN=your_long_lived_access_token_here
TELEGRAM_CHAT_ID=your_telegram_chat_id
# Future: Weather Station (optional)
# WEATHER_STATION_URL=http://192.168.1.1003.配置克劳德桌面
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"homeassistant": {
"command": "C:\\Users\\YourName\\Documents\\FAC\\MCP_Ideas\\.venv\\Scripts\\python.exe",
"args": ["server_home_assistant.py"]
},
"tello": {
"command": "C:\\Users\\YourName\\Documents\\FAC\\MCP_Ideas\\.venv\\Scripts\\python.exe",
"args": ["server_tello.py"]
}
}
}4.重新启动克劳德桌面
配置后,重新启动Claude Desktop以加载MCP服务器。
使用MCP检查员进行测试
用于本地测试的启动检查器:
# Windows - Test Home Assistant Server
npx @modelcontextprotocol/inspector .venv\Scripts\python.exe server_home_assistant.py
# Windows - Test Tello Server
npx @modelcontextprotocol/inspector .venv\Scripts\python.exe server_tello.py检查员打开 http://localhost:5173
检查员卡住了?
# Windows
Get-Process | Where-Object { $_.Path -like "*@modelcontextprotocol*" } | Stop-Process使用示例
家庭助理示例
控制灯:
"Turn on the living room light"
"Set the Hue bulb to 50% brightness"
"Change the bedroom light to blue" (RGB: 0, 0, 255)
"Turn off all lights in the kitchen"气候控制:
"What's the current temperature?"
"Set the thermostat to 22 degrees"
"Show me all climate device status"安全与监控:
"Lock the front door"
"Show me the front door camera"
"Send a camera snapshot to Telegram"
"What's the status of all locks?"智能家居自动化:
"Turn on the Tapo plug"
"Open the garage door"
"Read all sensor values"
"Make an announcement on the speaker: 'Dinner is ready'"Tello无人机示例
基本航班:
"Take off"
"Move forward 50 cm"
"Rotate clockwise 90 degrees"
"Land"摄像头和传感器:
"Show me what the drone sees"
"What's the battery level?"
"Get current height"
"Read all sensor data"高级机动:
"Do a flip forward"
"Fly in a square pattern"
"Return to takeoff position"项目结构
MCP_Ideas/
├── server_home_assistant.py # Home Assistant MCP server
├── server_tello.py # Tello drone MCP server
├── requirements.txt # Python dependencies
├── .env # Environment variables (create this)
├── claude_desktop_config.json # Claude Desktop configuration
├── test_udp_receive.py # Tello UDP connection test
├── add_firewall_rule.ps1 # Windows firewall setup for Tello
└── README.md # This file故障排除
家庭助理连接问题
服务器未连接:
- 验证家庭助理是否正在运行且可访问
- 检查
HA_URL和HA_TOKEN在.env文件 - 确保长期访问令牌有效
- 配置更改后重新启动Claude Desktop
设备没有响应:
- 使用
get_lights,get_switches等,以找到正确的实体ID - 在Home Assistant中检查设备是否联机
- 验证实体ID是否完全匹配(区分大小写)
Tello无人机-Windows视频流
解决方案:
Tello MCP服务器现在使用 OpenCV视频捕获而不是PyAV 在Windows上,它可以正确处理UDP视频流。
PyAV av.open() 在使用UDP URL的Windows上抛出错误10014,但OpenCV运行良好!
做了什么
- 测试脚本已确认:原始UDP套接字工作并接收Tello视频数据
- 找到根本原因:PyAV的FFmpeg包装器无法在Windows上打开UDP流
- 已应用修复:自动补丁使用Windows版OpenCV VideoCapture
- 防火墙规则:可选但推荐(运行
add_firewall_rule.ps1)
测试您的设置
运行UDP测试以验证您的网络:
.venv\Scripts\python.exe test_udp_receive.py如果这显示 [SUCCESS] RECEIVED DATA,你的设置很好!
防火墙规则(可选但推荐)
虽然OpenCV修复应该有效,但仍然建议添加防火墙规则:
- 以管理员身份打开PowerShell
- 导航到项目目录:
cd C:\Users\Alexander\Documents\FAC\MCP_Ideas- 运行防火墙规则脚本:
.\add_firewall_rule.ps1它现在是如何工作的
- 视窗:自动使用OpenCV视频捕获(UDP兼容)
- Linux/Mac:正常使用PyAV
- 两者:30次重试尝试抓取第一帧(处理初始化延迟)
如果视频仍然不起作用
尝试以下附加步骤:
检查您的WiFi连接:
- 确保您已连接到Tello的WiFi网络(Tello-XXXXXX)
- 无人机必须通电
禁用VPN/安全软件:
- 某些VPN或安全软件可能会阻止本地UDP流量
- 暂时禁用以进行测试
替代解决方案:
- 使用WSL2 (如果防火墙修复程序不起作用):
# In WSL2
python server_tello.py- 无相机飞行 (所有命令都有效):
- 起飞、着陆、移动、旋转、翻转、电池等。 - 无人机控制可选摄像头
