MQScript MCP Server
# MQScript MCP Server
一个基于 Model Context Protocol (MCP) 的 MQScript 移动自动化脚本语言服务器。
## 概述
本项目提供了一个全面的 MCP 服务器,支持 MQScript 移动自动化脚本语言的所有主要功能。通过这个服务器,AI 应用可以轻松生成和执行 MQScript 代码,用于移动设备自动化操作。
## 支持的功能
### 基础命令 (Basic Commands)
- **触摸命令**: Tap, Touch, Swipe, KeyPress 等触摸操作
- **控制命令**: Delay, For, If, While, Dim 等流程控制
- **颜色命令**: GetPixelColor, FindColor, CmpColor 等颜色检测
- **其他命令**: ShowMessage, TracePrint, RunApp, InputText 等
### 标准库函数 (Standard Library)
- **数学函数**: Abs, Sin, Cos, Tan, Sqr, Rnd 等数学运算
- **字符串函数**: Len, Left, Right, Mid, InStr, Replace, UCase, LCase 等字符串处理
- **类型转换函数**: CInt, CStr, CBool, IsNumeric 等类型转换
- **数组函数**: UBound, Split, Join 等数组操作
### 界面命令 (UI Commands)
- **UI 控件**: NewLayout, AddTextView, AddEditText, AddButton, AddCheckBox 等控件创建
- **UI 属性**: SetText, GetText, SetEnabled, SetVisible 等属性设置
- **悬浮窗**: Create, Show, Hide, AddTextView, AddButton, SetText, OnClick 等悬浮窗操作
### 扩展命令 (Extension Commands)
- **元素操作**: Element.GetText, Element.Click, Element.SetText, Element.Exists 等元素操作
- **设备操作**: Device.GetInfo, Device.Vibrate, Device.SetBrightness, Device.SetVolume 等设备控制
- **电话操作**: Phone.Call, Phone.SendSMS, Phone.GetCallState 等电话功能
- **系统操作**: Sys.Exit, Sys.GetTime, Sys.Shell, Sys.GetEnv, Sys.SetEnv, Sys.Sleep 等系统功能
### 插件命令 (Plugin Commands)
- **JSON 操作**: CJson.Parse, CJson.Stringify, CJson.Get, CJson.Set 等 JSON 处理
- **日期时间**: DateTime.Now, DateTime.Format, DateTime.AddDays, DateTime.Compare 等日期时间操作
- **文件操作**: File.Read, File.Write, File.Exists, File.Delete, File.Copy 等文件处理
- **图灵机器人**: TURING.Chat, TURING.SetConfig 等 AI 对话功能
## 安装和使用
### 安装依赖
```bash
npm install
```
### 编译项目
```bash
npm run build
```
### 启动服务器
```bash
npm start
```
### 开发模式
```bash
npm run dev
```
## MCP 客户端配置
在支持 MCP 的客户端中,添加以下配置:
```json
{
"mcpServers": {
"mqscript": {
"command": "node",
"args": ["path/to/mcp-mqscript-server/build/index.js"],
"env": {}
}
}
}
```
## 工具示例
### 基础触摸操作
```javascript
// 点击屏幕坐标
mqscript_touch_tap({
x: 100,
y: 200,
duration: 100
})
// 滑动操作
mqscript_touch_swipe({
x1: 100,
y1: 200,
x2: 300,
y2: 400,
duration: 500
})
```
### 颜色检测
```javascript
// 获取像素颜色
mqscript_color_getpixelcolor({
x: 100,
y: 200,
resultVariable: "pixelColor"
})
// 查找颜色
mqscript_color_findcolor({
x1: 0,
y1: 0,
x2: 720,
y2: 1280,
color: "0xFF0000",
resultVariable: "redPixelPos"
})
```
### UI 界面创建
```javascript
// 创建布局
mqscript_ui_newlayout({
orientation: "vertical"
})
// 添加按钮
mqscript_ui_addbutton({
id: "btn1",
text: "Click Me"
})
// 显示界面
mqscript_ui_show({
title: "My App"
})
```
### 文件操作
```javascript
// 读取文件
mqscript_file_read({
filePath: "/sdcard/data.txt",
encoding: "UTF-8",
resultVariable: "fileContent"
})
// 写入文件
mqscript_file_write({
filePath: "/sdcard/output.txt",
content: "Hello, World!",
encoding: "UTF-8",
append: false
})
```
## 项目结构
```
mcp-mqscript-server/
├── src/
│ ├── tools/
│ │ ├── basic-commands.ts # 基础命令
│ │ ├── standard-library.ts # 标准库函数
│ │ ├── ui-commands.ts # 界面命令
│ │ ├── extension-commands.ts # 扩展命令
│ │ └── plugin-commands.ts # 插件命令
│ └── index.ts # 主服务器文件
├── build/ # 编译输出目录
├── package.json # 项目配置
├── tsconfig.json # TypeScript 配置
└── README.md # 项目文档
```
## 技术栈
- **TypeScript**: 类型安全的 JavaScript 超集
- **Model Context Protocol SDK**: MCP 协议的官方 SDK
- **Zod**: 运行时类型验证库
- **Node.js**: JavaScript 运行时环境
## 许可证
MIT License
## 贡献
欢迎提交 Issue 和 Pull Request 来改进这个项目。
## 支持
如果你在使用过程中遇到问题,请提交 Issue 或联系维护者。TDQS
Scored across 83 tools
The tools are generally well-differentiated by their specific functions, with clear prefixes like 'mqscript_cjson_' for JSON operations or 'mqscript_device_' for device controls. However, some overlap exists between similar UI interaction tools (e.g., 'mqscript_tap' vs. 'mqscript_element_click') and timing functions (e.g., 'mqscript_delay' vs. 'mqscript_sys_sleep'), which could cause minor confusion for an agent.
All tools follow a consistent 'mqscript_' prefix with snake_case naming, using clear verb_noun patterns (e.g., 'mqscript_file_read', 'mqscript_ui_addcheckbox'). This uniformity makes the tool set predictable and easy to navigate, with no deviations in style or structure.
With 83 tools, the count is excessive for a single server, making it overwhelming and difficult for an agent to manage effectively. This large number suggests poor scoping, as many functions could be consolidated (e.g., multiple string manipulation or UI tools) rather than exposed as separate tools.
The tool set provides comprehensive coverage for mobile automation and scripting, including file operations, UI interactions, device controls, mathematical functions, string manipulation, and system commands. There are no obvious gaps; it supports full CRUD-like workflows and diverse scripting needs without dead ends.