Windows 自动化/MCP 工具服务器,基于 stdio 的 JSON-RPC。提供窗口管理、鼠标/键盘、截图/OCR、文本查找点击、Shell 等工具,并支持任务规划执行。
- ✅ 窗口管理与操作
- ✅ 鼠标/键盘自动化
- ✅ 截图与OCR识别
- ✅ 文本查找与点击
- ✅ Shell命令执行
- ✅ 任务规划与执行
- ✅ 离线语音识别(可选)
- 入口点:
src/main.rs调用server::run()启动主循环 - 通信协议:JSON-RPC over stdio
- 可选组件:离线语音识别 Vosk(
build.rs+VOSK_LIB_DIR)
- 操作系统:Windows 10+ x86_64
- 开发工具:Rust MSVC 工具链(
stable-x86_64-pc-windows-msvc) - 可选依赖:Vosk 本地库(仅
stt_vosk_tool需要)
# 进入项目目录
cd d:\0721\main
# 构建发布版本
cargo build --release
# 运行程序
.\target\release\main.exe可按 configs/cherrystudio.mcp.json 集成 MCP 客户端(如 Cherry Studio)。
{
"id": 1,
"method": "tools/list",
"params": {}
}{
"id": 2,
"method": "tools/call",
"params": {
"name": "launch-hyphen-tool",
"input": {
"path": "C:\\Windows\\System32\\notepad.exe"
}
}
}{
"id": 3,
"method": "assistant/execute-plan",
"params": {
"steps": [
{
"tool": "launch-hyphen-tool",
"input": {
"path": "..."
}
},
{
"tool": "wait-window-tool",
"input": {
"title": "记事本"
}
}
]
}
}launch-hyphen-tool→ 启动应用wait-window-tool→ 获取hwndscreenshot-hyphen-tool(mode:"window")ocr-hyphen-tool→ 文本find-text-hyphen-tool→ 坐标click-hyphen-tool或click-text-hyphen-tool→ 点击
screenshot-hyphen-tool(mode:"screen" + region)配合 find-text-hyphen-tool
| 配置文件 | 描述 | 主要配置项 |
|---|---|---|
configs/server.toml |
服务器配置 | transport = "stdio",`log_level = "info" |
configs/cherrystudio.mcp.json |
MCP 客户端配置 | 命令与参数 |
build.rs |
构建配置 | VOSK_LIB_DIR(可选) |
configs/brain.toml |
规划策略配置 | 规划相关参数 |
| 工具名称 | 功能描述 | 输入参数 | 输出结果 |
|---|---|---|---|
launch-hyphen-tool |
启动应用 | { path, args? } |
{ pid } |
wait-window-tool |
等待窗口 | { title, timeout_ms } |
{ hwnd } |
focus-tool |
聚焦窗口 | { hwnd } |
{ ok } |
| 工具名称 | 功能描述 | 输入参数 | 输出结果 |
|---|---|---|---|
click-hyphen-tool |
鼠标点击 | { x, y, button } |
{ ok } |
type-tool |
文本输入 | { text, enter? } |
{ ok } |
shortcut-hyphen-tool |
快捷键 | { keys } |
{ ok } |
| 工具名称 | 功能描述 | 输入参数 | 输出结果 |
|---|---|---|---|
screenshot-hyphen-tool |
截图 | { mode, hwnd?, region? } |
{ image_bgra_base64 } |
ocr-hyphen-tool |
OCR识别 | { image_bgra_base64, lang } |
{ text } |
find-text-hyphen-tool |
查找文本 | { image_bgra_base64, query, fuzz } |
{ bbox, score } |
click-text-hyphen-tool |
文本点击 | { hwnd?, query, region? } |
{ ok } |
| 工具名称 | 功能描述 | 输入参数 | 输出结果 |
|---|---|---|---|
play-cloudmusic-tool |
网易云音乐控制 | { action } |
{ ok } |
注意:
screenshot-hyphen-tool使用两阶段捕获(窗口 DC BitBlt → 屏幕 DC 裁剪兜底),已移除PrintWindow
- 构建警告:未使用导入/变量不影响功能,可后续清理
- 权限问题:UAC 提升应用需管理员运行
- 截图空白/裁剪错误:优先
mode:"window"+hwnd;必要时用mode:"screen"+ 明确region - 文本定位偏差:调
fuzz、限定region、提高截图清晰度
{
"name": "screenshot-hyphen-tool",
"input": {
"mode": "window",
"hwnd": 123456,
"region": {
"x": 0,
"y": 0,
"w": 800,
"h": 600
}
}
}{
"name": "find-text-hyphen-tool",
"input": {
"image_bgra_base64": "...",
"query": "开始播放",
"fuzz": 0.3
}
}{
"name": "click-hyphen-tool",
"input": {
"x": 100,
"y": 200,
"button": "left"
}
}