FlaUI MCP
MCP(模型上下文协议)服务器,使AI代理能够使用可访问性API自动化Windows桌面应用程序,就像Playwright自动化浏览器一样。
 ](https://github.com/shanselman/FlaUI-MCP/releases) 
为什么存在
当Playwright的MCP服务器自动化浏览器时,它提供:
browser_snapshot→ 带有元素引用的结构化可访问性树browser_click ref="..."→ 按参照而非坐标单击
FlaUI MCP为Windows桌面应用程序带来了相同的模式:
windows_snapshot→ 可访问性树,包含以下引用w1e5windows_click ref="w1e5"→ 按ref单击元素
无截图解析。没有坐标猜测。只是语义元素引用。
快速演示
Agent: Calculate 3 × 3
1. windows_launch { "app": "calc.exe" }
→ Window handle: w1
2. windows_snapshot { "handle": "w1" }
→ - window "Calculator" [ref=w1]
- button "Three" [ref=w1e43]
- button "Multiply by" [ref=w1e35]
- button "Equals" [ref=w1e38]
- text "Display is 0" [ref=w1e15]
3. windows_batch { "actions": [
{"action": "click", "ref": "w1e43"},
{"action": "click", "ref": "w1e35"},
{"action": "click", "ref": "w1e43"},
{"action": "click", "ref": "w1e38"},
{"action": "snapshot", "handle": "w1"}
]}
→ 1. click: Invoked Three
2. click: Invoked Multiply by
3. click: Invoked Three
4. click: Invoked Equals
5. snapshot: ... "Display is 9" ...安装
先决条件
- Windows 10/11
- .NET 8.0运行时
下载发布
从下载最新版本 发布 并提取到文件夹中。
配置MCP客户端
添加到您的MCP配置中(例如。, ~/.copilot/mcp-config.json):
{
"mcpServers": {
"windows": {
"type": "local",
"command": "C:\\path\\to\\FlaUI-MCP.exe",
"tools": ["*"]
}
}
}或使用 dotnet run:
{
"mcpServers": {
"windows": {
"type": "local",
"command": "dotnet",
"args": ["run", "--project", "C:\\path\\to\\src\\FlaUI.Mcp"]
}
}
}可用工具
| 工具 | 说明 |
|---|---|
windows_launch | 启动Windows应用程序 |
windows_snapshot | 使用元素引用获取可访问性树 |
windows_click | 按ref单击元素 |
windows_type | 在元素中键入文本 |
windows_fill | 清除并填充文本字段 |
windows_get_text | 获取元素的文本内容 |
windows_screenshot | 将窗口/元素捕获为PNG格式 |
windows_list_windows | 列出所有打开的窗口 |
windows_focus | 将窗口置于前台 |
windows_close | 关闭窗口 |
windows_batch | 在一次调用中执行多个操作 |
运作原理
辅助功能快照
当你打电话的时候 windows_snapshot,你会得到一个结构化的文本树:
- window "Calculator" [ref=w1e1]
- group "Number pad" [ref=w1e39]
- button "Seven" [ref=w1e47]
- button "Eight" [ref=w1e48]
- button "Nine" [ref=w1e49]
- text "Display is 0" [ref=w1e15]这来自 Windows用户界面自动化 -相同的API屏幕阅读器使用。每个元素都有:
- 角色 (按钮、文本、组、文本框)
- 名字 (“七”,“显示为0”)
- 参考 (w1e47)-用于交互的句柄
- 状态 (\[禁用\]、\[只读\]、\[选中\])
为什么不截图?
| 方法 | 优点 | 缺点 |
|---|---|---|
| 可访问性树 | 语义清晰、精确、快速,适用于任何分辨率 | 需要UI自动化支持 |
| 截图+视觉 | 适用于任何应用程序 | 缓慢、昂贵、不精确、依赖分辨率 |
FlaUI MCP使用可访问性,因为它是屏幕阅读器使用的——它是为程序化UI交互而设计的。
从源头构建
# Clone
git clone https://github.com/shanselman/FlaUI-MCP.git
cd FlaUI-MCP
# Build
dotnet build src/FlaUI.Mcp
# Run
dotnet run --project src/FlaUI.Mcp建筑
┌─────────────────────────────────────────────────────────────────┐
│ AI Agent (GitHub Copilot, Claude, etc.) │
│ - Calls MCP tools: windows_snapshot, windows_click, etc. │
└─────────────────────────────────────────────────────────────────┘
│ MCP Protocol (JSON-RPC over stdio)
▼
┌─────────────────────────────────────────────────────────────────┐
│ FlaUI-MCP Server (.NET 8) │
│ - Implements MCP tool handlers │
│ - Builds agent-friendly accessibility snapshots │
│ - Maps element refs ↔ AutomationElements │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ FlaUI Library (github.com/FlaUI/FlaUI) │
│ - UIA3Automation for modern apps (WPF, UWP, Win32) │
│ - Control patterns: Invoke, Value, Toggle, Selection │
│ - Tree walking and element discovery │
└─────────────────────────────────────────────────────────────────┘支持的应用程序
适用于支持UI自动化的任何Windows应用程序:
- ✅ Win32应用程序(记事本、资源管理器等)
- ✅ WPF应用程序
- ✅ WinForms应用程序
- ✅ UWP/应用商店应用程序(计算器、设置等)
- ⚠️ 电子应用程序(部分-取决于可访问性实现)
- ❌ 游戏(通常不支持UI自动化)
贡献
欢迎投稿!请参阅 贡献.md 作为指导方针。
许可证
MIT许可证-请参阅 许可证 了解详情。
