简介

Windows-MCP​ 是一个轻量级、开源的MCP(Model Context Protocol)服务器,专门为Windows操作系统设计,实现AI智能体与Windows系统的无缝集成。它作为AI智能体和Windows操作系统之间的桥梁,允许智能体执行文件导航、应用程序控制、UI交互、QA测试等任务。

🔗 ​GitHub地址​:

https://github.com/CursorTouch/Windows-MCP

🚀 ​核心价值​:

Windows自动化 · AI智能体 · MCP协议 · 轻量级 · 开源免费

项目背景​:

  • 自动化需求​:解决Windows自动化最后一公里问题

  • AI集成​:连接AI智能体与Windows操作系统

  • 协议标准​:基于MCP协议标准开发

  • 开源精神​:完全开源,社区驱动开发

项目特色​:

  • 🖥️ ​原生集成​:与Windows UI元素原生交互

  • 🤖 ​多模型支持​:支持任何LLM,无需特定模型

  • ⚡ ​轻量高效​:最小依赖,快速安装

  • 🔧 ​丰富工具​:全面的UI自动化工具集

  • 🆓 ​开源免费​:MIT开源许可证

技术优势​:

  • 无需CV​:不依赖传统计算机视觉技术

  • 低延迟​:操作延迟0.7-2.5秒

  • 易扩展​:易于定制和扩展工具

  • 跨平台​:支持多种AI桌面客户端

  • 实时交互​:实时系统交互能力


主要功能

1. ​核心功能体系

Windows-MCP提供了一套完整的Windows自动化解决方案,涵盖UI交互、应用程序控制、系统操作、信息获取等多个方面。

UI交互功能​:

鼠标操作:
- 点击操作: 屏幕坐标点击
- 移动操作: 鼠标指针移动
- 拖拽操作: 从一点拖拽到另一点
- 滚动操作: 垂直和水平滚动
- 右键操作: 右键菜单操作

键盘操作:
- 文本输入: 在元素上输入文本
- 单键操作: 按下单个按键
- 快捷键: 执行键盘快捷键
- 组合键: 复杂组合键操作
- 输入清理: 可选清除现有文本

剪贴板操作:
- 复制操作: 复制到剪贴板
- 粘贴操作: 从剪贴板粘贴
- 内容管理: 剪贴板内容管理
- 格式支持: 多种内容格式支持

应用程序控制​:

应用启动:
- 开始菜单启动: 从开始菜单启动应用
- 快捷方式启动: 通过快捷方式启动
- 命令行启动: 命令行方式启动应用
- 应用切换: 应用间切换操作
- 应用管理: 应用状态管理

窗口控制:
- 窗口调整: 调整窗口大小
- 窗口移动: 移动窗口位置
- 窗口最大化: 最大化窗口
- 窗口最小化: 最小化窗口
- 窗口关闭: 关闭应用窗口

进程管理:
- 进程查看: 查看运行进程
- 进程终止: 终止指定进程
- 进程优先级: 调整进程优先级
- 进程监控: 进程状态监控

系统操作功能​:

Shell命令:
- PowerShell: 执行PowerShell命令
- 命令提示符: 执行CMD命令
- 脚本执行: 执行批处理脚本
- 命令输出: 获取命令执行结果
- 错误处理: 命令错误处理

文件操作:
- 文件浏览: 文件系统浏览
- 文件操作: 文件创建、删除、重命名
- 目录操作: 目录创建和管理
- 文件搜索: 文件内容搜索
- 路径操作: 路径管理操作

系统信息:
- 系统状态: 获取系统状态信息
- 硬件信息: 硬件配置信息
- 软件信息: 安装软件信息
- 网络状态: 网络连接状态
- 性能监控: 系统性能监控

信息获取功能​:

屏幕捕获:
- 屏幕截图: 整个桌面截图
- 区域截图: 指定区域截图
- 窗口截图: 特定窗口截图
- 元素截图: UI元素截图
- 截图格式: 多种图像格式

状态获取:
- UI状态: UI元素状态信息
- 文本内容: 可读文本内容获取
- 可交互元素: 可交互元素识别
- 滚动元素: 可滚动元素识别
- 浏览器状态: 浏览器页面状态

网页抓取:
- 网页内容: 整个网页内容抓取
- 元素提取: 特定元素内容提取
- 结构化数据: 结构化数据提取
- 动态内容: 动态内容处理
- 分页处理: 多页面内容处理

高级功能​:

等待控制:
- 时间等待: 指定时间等待
- 条件等待: 条件满足等待
- 元素等待: 元素出现等待
- 超时控制: 等待超时控制
- 异步等待: 异步等待操作

错误处理:
- 异常捕获: 操作异常捕获
- 错误恢复: 错误自动恢复
- 重试机制: 操作重试机制
- 日志记录: 详细错误日志
- 状态回滚: 状态回滚操作

性能优化:
- 操作优化: 操作性能优化
- 内存管理: 内存使用优化
- 并发控制: 并发操作控制
- 缓存策略: 数据缓存策略
- 资源释放: 资源及时释放

2. ​工具集详情

核心工具列表​:

Click-Tool: 在给定坐标点击屏幕
Type-Tool: 在元素上输入文本(可选清除现有文本)
Clipboard-Tool: 使用系统剪贴板复制或粘贴
Scroll-Tool: 在窗口或特定区域垂直或水平滚动
Drag-Tool: 从一点拖拽到另一点
Move-Tool: 移动鼠标指针
Shortcut-Tool: 执行键盘快捷键(Ctrl+C、Alt+Tab等)
Key-Tool: 按下单个按键
Wait-Tool: 暂停指定时间
State-Tool: 系统状态综合快照(语言、浏览器、活动应用等)
Resize-Tool: 改变应用窗口大小或位置
Launch-Tool: 从开始菜单启动应用程序
Shell-Tool: 执行PowerShell命令
Scrape-Tool: 抓取整个网页信息

工具特性​:

实时性: 操作延迟0.7-2.5秒
可靠性: 高可靠性操作执行
精确性: 精确坐标和元素操作
灵活性: 多种操作方式组合
安全性: 安全操作边界控制
可扩展: 易于添加新工具
跨平台: 支持多种AI客户端
易用性: 简单直观的工具调用

安装与配置

1. ​环境准备

系统要求​:

操作系统:
- Windows 7
- Windows 8/8.1  
- Windows 10
- Windows 11

软件要求:
- Python: 3.13+ 版本
- UV包管理器: 最新版本
- Node.js: 16+ (可选,用于某些客户端)
- Git: 版本控制工具

语言要求:
- 默认语言: 英语(推荐)
- 其他语言: 支持但可能需要禁用某些工具
- 区域设置: 建议使用英语区域设置

硬件要求:
- 内存: 4GB+ RAM
- 存储: 1GB+ 可用空间
- 显示器: 支持图形界面
- 输入设备: 鼠标和键盘

2. ​安装步骤

基础安装​:

# 1. 克隆仓库
git clone https://github.com/CursorTouch/Windows-MCP.git
cd Windows-MCP

# 2. 安装UV包管理器
pip install uv
# 或使用curl安装
curl -LsSf https://astral.sh/uv/install.sh | sh

# 3. 安装Python依赖
uv sync

# 4. 验证安装
python main.py --help

Claude Desktop安装​:

# 安装Claude Desktop扩展
npm install -g @anthropic-ai/dxt

# 构建桌面扩展
npx @anthropic-ai/dxt pack

# 在Claude Desktop中安装
# 设置 -> 扩展 -> 高级设置 -> 安装扩展 -> 选择.dxt文件

Perplexity Desktop安装​:

# 克隆仓库
git clone https://github.com/CursorTouch/Windows-MCP.git
cd Windows-MCP

# 在Perplexity Desktop中添加连接器
# 设置 -> 连接器 -> 添加连接器 -> 高级
# 名称: Windows-MCP
# JSON配置:
{
  "command": "uv",
  "args": ["--directory", "<路径>", "run", "main.py"]
}

Gemini CLI安装​:

# 安装Gemini CLI
npm install -g @google/gemini-cli

# 编辑配置文件
# 打开 %USERPROFILE%/.gemini/settings.json
# 添加配置:
{
  "mcpServers": {
    "windows-mcp": {
      "command": "uv",
      "args": ["--directory", "<路径>", "run", "main.py"]
    }
  }
}

Qwen Code安装​:

# 安装Qwen Code
npm install -g @qwen-code/qwen-code@latest

# 编辑配置文件  
# 打开 %USERPROFILE%/.qwen/settings.json
# 添加配置:
{
  "mcpServers": {
    "windows-mcp": {
      "command": "uv",
      "args": ["--directory", "<路径>", "run", "main.py"]
    }
  }
}

Codex CLI安装​:

# 安装Codex CLI
npm install -g @openai/codex

# 编辑配置文件
# 打开 %USERPROFILE%/.codex/config.toml
# 添加配置:
[mcp_servers.windows-mcp]
command = "uv"
args = ["--directory", "<路径>", "run", "main.py"]

3. ​配置说明

基本配置​:

// MCP服务器配置示例
{
  "command": "uv",
  "args": [
    "--directory",
    "C:\\Users\\username\\Windows-MCP",
    "run", 
    "main.py"
  ],
  "env": {
    "PYTHONPATH": "C:\\Users\\username\\Windows-MCP",
    "LANGUAGE": "en_US"
  }
}

环境变量配置​:

# 环境变量设置示例
set PYTHONPATH=C:\Users\username\Windows-MCP
set LANGUAGE=en_US
set DEFAULT_MODEL=gpt-4
set OPENAI_API_KEY=your_api_key_here

工具配置​:

# 工具启用配置
ENABLED_TOOLS = {
    "click_tool": True,
    "type_tool": True, 
    "clipboard_tool": True,
    "scroll_tool": True,
    "drag_tool": True,
    "move_tool": True,
    "shortcut_tool": True,
    "key_tool": True,
    "wait_tool": True,
    "state_tool": True,
    "resize_tool": True,
    "launch_tool": True,  # 非英语系统可能需要禁用
    "shell_tool": True,
    "scrape_tool": True
}

性能配置​:

# 性能参数配置
PERFORMANCE_CONFIG = {
    "timeout": 30,           # 操作超时时间(秒)
    "retry_attempts": 3,     # 重试次数
    "delay_between_actions": 0.5,  # 操作间延迟(秒)
    "screenshot_quality": 80, # 截图质量百分比
    "max_file_size": 10485760,  # 最大文件大小(10MB)
}

使用指南

1. ​基本工作流

使用Windows-MCP的基本流程包括:安装配置 → 连接客户端 → 发送指令 → 执行操作 → 获取结果。整个过程设计为简单直观,用户可以通过自然语言指令控制Windows系统。

2. ​基本使用

自然语言控制​:

1. 打开应用:
   "打开记事本应用程序"
   "启动Chrome浏览器"
   "从开始菜单打开计算器"

2. 文件操作:
   "在桌面上创建新文件夹"
   "重命名文档文件"
   "删除临时文件"

3. 文本输入:
   "在记事本中输入'Hello World'"
   "在搜索框中输入'Windows设置'"
   "在浏览器地址栏输入'https://github.com'"

4. 系统操作:
   "截取屏幕截图"
   "复制当前选中的文本"
   "执行PowerShell命令'Get-Process'"

5. UI交互:
   "点击屏幕坐标(100, 200)"
   "滚动到页面底部"
   "拖拽文件到回收站"

API调用示例​:

# Python客户端使用示例
from mcp import Client

async def control_windows():
    # 连接MCP服务器
    async with Client("windows-mcp") as client:
        # 打开应用程序
        await client.execute_tool("launch_tool", {"app_name": "notepad"})
        
        # 等待应用启动
        await client.execute_tool("wait_tool", {"duration": 2})
        
        # 输入文本
        await client.execute_tool("type_tool", {
            "text": "Hello from Windows-MCP!",
            "clear_existing": True
        })
        
        # 保存文件
        await client.execute_tool("shortcut_tool", {"shortcut": "Ctrl+S"})
        await client.execute_tool("wait_tool", {"duration": 1})
        await client.execute_tool("type_tool", {"text": "test_file.txt"})
        await client.execute_tool("key_tool", {"key": "Enter"})

复杂任务执行​:

// 复杂自动化任务示例
const tasks = [
  {
    tool: "launch_tool",
    params: { app_name: "chrome" },
    description: "打开Chrome浏览器"
  },
  {
    tool: "wait_tool", 
    params: { duration: 3 },
    description: "等待浏览器启动"
  },
  {
    tool: "type_tool",
    params: { 
      text: "https://github.com/CursorTouch/Windows-MCP",
      clear_existing: true
    },
    description: "输入GitHub地址"
  },
  {
    tool: "key_tool",
    params: { key: "Enter" },
    description: "按下回车访问网站"
  },
  {
    tool: "wait_tool",
    params: { duration: 5 },
    description: "等待页面加载"
  },
  {
    tool: "scrape_tool",
    params: {},
    description: "抓取页面内容"
  }
];

// 顺序执行任务
for (const task of tasks) {
  await client.execute_tool(task.tool, task.params);
}

3. ​高级用法

自定义工具开发​:

# 自定义工具示例
from mcp import BaseTool

class CustomScreenshotTool(BaseTool):
    """自定义截图工具"""
    
    name = "custom_screenshot"
    description = "自定义区域截图工具"
    
    async def execute(self, params):
        region = params.get("region", "full")
        quality = params.get("quality", 80)
        format = params.get("format", "png")
        
        # 实现截图逻辑
        if region == "full":
            screenshot = take_full_screenshot(quality, format)
        else:
            screenshot = take_region_screenshot(region, quality, format)
        
        return {
            "screenshot": screenshot,
            "format": format,
            "quality": quality
        }

# 注册自定义工具
client.register_tool(CustomScreenshotTool())

错误处理机制​:

# 错误处理示例
async def safe_execute(tool_name, params, max_retries=3):
    for attempt in range(max_retries):
        try:
            result = await client.execute_tool(tool_name, params)
            return result
        except Exception as e:
            print(f"尝试 {attempt + 1} 失败: {str(e)}")
            if attempt == max_retries - 1:
                raise
            await asyncio.sleep(1)  # 等待后重试

# 安全执行工具
await safe_execute("click_tool", {"x": 100, "y": 200})

性能监控​:

# 性能监控装饰器
def monitor_performance(func):
    async def wrapper(*args, **kwargs):
        start_time = time.time()
        try:
            result = await func(*args, **kwargs)
            end_time = time.time()
            duration = end_time - start_time
            print(f"工具执行时间: {duration:.2f}秒")
            return result
        except Exception as e:
            end_time = time.time()
            duration = end_time - start_time
            print(f"工具执行失败,耗时: {duration:.2f}秒,错误: {str(e)}")
            raise
    return wrapper

# 应用性能监控
@monitor_performance
async def execute_with_monitoring(tool_name, params):
    return await client.execute_tool(tool_name, params)

应用场景实例

案例1:自动化软件测试

场景​:自动化Windows应用程序测试

解决方案​:使用Windows-MCP进行自动化UI测试。

实施方法​:

async def automated_testing():
    test_cases = [
        {
            "name": "记事本功能测试",
            "steps": [
                {"tool": "launch_tool", "params": {"app_name": "notepad"}},
                {"tool": "type_tool", "params": {"text": "自动化测试文本"}},
                {"tool": "shortcut_tool", "params": {"shortcut": "Ctrl+S"}},
                {"tool": "type_tool", "params": {"text": "test_output.txt"}},
                {"tool": "key_tool", "params": {"key": "Enter"}},
                {"tool": "shortcut_tool", "params": {"shortcut": "Alt+F4"}}
            ]
        },
        {
            "name": "计算器功能测试", 
            "steps": [
                {"tool": "launch_tool", "params": {"app_name": "calculator"}},
                {"tool": "click_tool", "params": {"x": 100, "y": 200}},  # 数字按钮
                {"tool": "click_tool", "params": {"x": 200, "y": 200}},  # 加号按钮
                {"tool": "click_tool", "params": {"x": 100, "y": 300}},  # 数字按钮
                {"tool": "click_tool", "params": {"x": 300, "y": 400}},  # 等号按钮
                {"tool": "state_tool", "params": {}}  # 验证结果
            ]
        }
    ]
    
    for test_case in test_cases:
        print(f"执行测试: {test_case['name']}")
        for step in test_case["steps"]:
            await client.execute_tool(step["tool"], step["params"])

测试价值​:

  • 自动化测试​:减少手动测试工作量

  • 可重复性​:测试用例可重复执行

  • 覆盖率​:提高测试覆盖率

  • 效率提升​:大幅提升测试效率

  • 质量保证​:确保软件质量

案例2:日常办公自动化

场景​:办公室日常任务自动化

解决方案​:使用Windows-MCP自动化办公任务。

实施方法​:

async def office_automation():
    # 早晨启动 routine
    morning_tasks = [
        {"tool": "launch_tool", "params": {"app_name": "outlook"}},
        {"tool": "wait_tool", "params": {"duration": 5}},
        {"tool": "launch_tool", "params": {"app_name": "teams"}},
        {"tool": "launch_tool", "params": {"app_name": "chrome"}},
        {"tool": "type_tool", "params": {"text": "公司内部网站"}},
        {"tool": "key_tool", "params": {"key": "Enter"}}
    ]
    
    # 文件处理任务
    file_tasks = [
        {"tool": "shell_tool", "params": {"command": "mkdir C:\\DailyReports"}},
        {"tool": "shell_tool", "params": {"command": "copy *.docx C:\\DailyReports\\"}},
        {"tool": "shell_tool", "params": {"command": "压缩每日报告文件"}}
    ]
    
    # 执行任务
    for task in morning_tasks + file_tasks:
        await client.execute_tool(task["tool"], task["params"])

办公自动化价值​:

  • 时间节省​:节省重复性任务时间

  • 减少错误​:减少人工操作错误

  • 标准化​:任务执行标准化

  • 效率提升​:提高工作效率

  • 专注重点​:专注于重要工作

案例3:系统管理自动化

场景​:Windows系统管理任务自动化

解决方案​:使用Windows-MCP进行系统管理。

实施方法​:

async def system_administration():
    admin_tasks = [
        # 系统维护
        {"tool": "shell_tool", "params": {"command": "磁盘清理"}},
        {"tool": "shell_tool", "params": {"command": "系统文件检查"}},
        
        # 软件更新
        {"tool": "launch_tool", "params": {"app_name": "windows update"}},
        {"tool": "click_tool", "params": {"x": 500, "y": 300}},  # 检查更新按钮
        {"tool": "wait_tool", "params": {"duration": 10}},
        
        # 安全扫描
        {"tool": "launch_tool", "params": {"app_name": "windows security"}},
        {"tool": "click_tool", "params": {"x": 400, "y": 200}},  # 快速扫描
        {"tool": "wait_tool", "params": {"duration": 15}},
        
        # 性能监控
        {"tool": "shell_tool", "params": {"command": "获取系统性能指标"}},
        {"tool": "shell_tool", "params": {"command": "生成性能报告"}}
    ]
    
    # 执行系统管理任务
    for task in admin_tasks:
        result = await client.execute_tool(task["tool"], task["params"])
        print(f"任务完成: {result}")

系统管理价值​:

  • 自动化运维​:自动化系统维护任务

  • 及时性​:及时执行维护任务

  • 一致性​:维护操作一致性

  • 监控能力​:系统状态监控能力

  • 问题预防​:预防性维护和问题预防


总结

Windows-MCP作为一个轻量级、开源的MCP服务器,通过其强大的Windows集成能力、丰富的工具集、多客户端支持和易用性,为AI智能体与Windows系统的交互提供了完整的解决方案。

核心优势​:

  • 🖥️ ​深度集成​:与Windows系统深度集成

  • 🤖 ​模型无关​:支持任何LLM模型

  • ⚡ ​轻量高效​:最小依赖,快速运行

  • 🔧 ​工具丰富​:全面的自动化工具

  • 🆓 ​完全开源​:MIT开源许可证

适用场景​:

  • 自动化软件测试和QA

  • 日常办公任务自动化

  • 系统管理和维护

  • 业务流程自动化

  • 教育和培训演示

立即开始使用​:

# 克隆仓库
git clone https://github.com/CursorTouch/Windows-MCP.git

# 安装依赖
cd Windows-MCP
pip install uv
uv sync

# 运行服务
python main.py

资源链接​:

  • 📚 ​项目地址​:GitHub仓库

  • 📖 ​使用文档​:详细使用文档

  • 🎥 ​演示视频​:功能演示视频

  • 💬 ​社区支持​:X(Twitter)关注

  • 🔧 ​开发指南​:贡献开发指南

最佳实践​:

  • 🎯 ​明确目标​:明确自动化目标

  • 📋 ​计划任务​:详细规划自动化任务

  • 🔧 ​逐步实施​:从简单任务开始

  • ✅ ​测试验证​:充分测试验证功能

  • 📊 ​监控优化​:监控性能并优化

通过Windows-MCP,您可以​:

  • 自动化操作​:自动化Windows操作任务

  • 提高效率​:大幅提高工作效率

  • 减少错误​:减少人工操作错误

  • 集成AI​:AI智能体集成Windows

  • 定制开发​:自定义开发自动化工具

无论您是开发者、测试人员、系统管理员还是普通用户,Windows-MCP都能为您提供强大、易用且高效的Windows自动化解决方案!​

特别提示​:

  • ⚠️ ​谨慎使用​:在受控环境中使用

  • 🔒 ​安全考虑​:注意系统安全风险

  • 📖 ​文档阅读​:详细阅读使用文档

  • 🤝 ​社区参与​:参与社区讨论

  • 🔄 ​持续更新​:关注版本更新

通过Windows-MCP,开启Windows自动化新体验!​

未来发展​:

  • 🚀 ​更多功能​:持续添加新功能

  • 🔌 ​更多集成​:更多客户端集成

  • 🤖 ​AI增强​:更智能的AI集成

  • 🌍 ​多语言​:多语言支持改进

  • 📊 ​性能优化​:持续性能优化

加入社区​:

参与方式:
- GitHub Issues: 问题反馈和功能建议
- X(Twitter): 关注最新动态
- 代码贡献: Pull Request贡献
- 文档改进: 帮助改进文档
- 案例分享: 分享使用案例

社区价值:
- 技术交流和学习
- 问题解答和支持  
- 功能建议和讨论
- 项目贡献和认可
- 职业发展机会

通过Windows-MCP,构建智能的Windows自动化未来!​

Logo

更多推荐