这是一个用于控制DJI Tello无人机的模型上下文协议(MCP)服务器实现。该服务器允许任何兼容MCP的客户端通过标准化接口控制Tello无人机。
git clone <repository-url>
cd drone-mcp
pip install -r requirements.txt
要使您的MCP客户端能够连接到Tello无人机服务器,请在您的mcp.json文件中添加以下配置(通常位于~/.cursor/mcp.json或项目目录中):
{
"tello-drone": {
"url": "http://localhost:3000/sse"
}
}
此配置允许启用MCP的工具和模型自动发现并连接到您的Tello无人机服务器。
连接到Tello无人机的WiFi网络(通常以"TELLO-"开头)。
启动MCP服务器:
sudo python tello_mcp.py
服务器将执行以下操作:
http://0.0.0.0:3000启动MCP服务器/sse设置SSE端点/message的消息确保在计划使用客户端(光标、冲浪板、代码)之前服务器正在运行。
服务器提供以下MCP工具:
{
"name": "takeoff",
"description": "命令Tello无人机起飞",
"inputSchema": {
"type": "object",
"properties": {}
}
}
{
"name": "land",
"description": "命令Tello无人机着陆",
"inputSchema": {
"type": "object",
"properties": {}
}
}
{
"name": "move",
"description": "移动Tello无人机到指定方向",
"inputSchema": {
"type": "object",
"properties": {
"direction": {
"type": "string",
"enum": ["up", "down", "left", "right", "forward", "back"]
},
"distance": {
"type": "integer",
"minimum": 20,
"maximum": 500
}
},
"required": ["direction", "distance"]
}
}
{
"name": "rotate",
"description": "顺时针或逆时针旋转Tello无人机",
"inputSchema": {
"type": "object",
"properties": {
"direction": {
"type": "string",
"enum": ["cw", "ccw"]
},
"degrees": {
"type": "integer",
"minimum": 1,
"maximum": 3600
}
},
"required": ["direction", "degrees"]
}
}
要连接MCP客户端:
GET http://localhost:3000/sse
event: endpoint
data: /message?sessionId=<session-id>
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize"
}
{
"jsonrpc": "2.0",
"id": 2,
"method": "listTools"
}
{
"jsonrpc": "2.0",
"id": 3,
"method": "callTool",
"params": {
"name": "takeoff",
"arguments": {}
}
}
服务器实现了全面的错误处理:
所有错误都被记录,并作为正确的JSON-RPC 2.0错误响应返回。
服务器将详细信息记录到stderr,包括:
服务器构建使用:
mcp库用于协议处理服务器无法启动:
无人机无法连接:
命令失败:
MIT
欢迎贡献。