Skip to main content

电脑分屏 MCP

一个高性能、跨平台的模型上下文协议(MCP)服务器,为 Windows 和 macOS 提供可靠的分屏窗口管理。该服务器通过 MCP 协议暴露 16 个窗口操作工具,使 AI 助手和其他 MCP 客户端能够精确控制桌面窗口布局。

🚀 功能特性

  • 跨平台支持:Windows 和 macOS,具有原生优化
  • 16 个窗口管理工具:全面的分屏布局和控制
  • 高性能:Windows:15-60ms,macOS:50-150ms 每次操作
  • 可靠性优先:强大的回退机制和错误处理
  • MCP 集成:通过 stdio 传输的完整模型上下文协议服务器支持
  • 智能焦点检测:具有平台特定优化的高级窗口焦点检测

🛠️ 安装

前置要求

  • Python:3.9 或更高版本
  • 包管理器uvx(推荐)或 pip

通过 uvx 安装(推荐)

uvx install computer-split-screen-mcp

通过 pip 安装

pip install computer-split-screen-mcp

🔧 MCP 客户端配置

使用以下设置配置您的 MCP 客户端:

{
  "mcpServers": {
    "computer-split-screen": {
      "command": "uvx",
      "args": ["computer-split-screen-mcp"],
      "env": {}
    }
  }
}

替代配置(如果不使用 uvx)

{
  "mcpServers": {
    "computer-split-screen": {
      "command": "python",
      "args": ["-m", "computer-split-screen-mcp"],
      "env": {}
    }
  }
}

🎯 可用工具

分屏布局

二分屏(2 路分割)

  • left-half-screen - 将当前窗口贴靠到左半屏
  • right-half-screen - 将当前窗口贴靠到右半屏
  • top-half-screen - 将当前窗口贴靠到上半屏
  • bottom-half-screen - 将当前窗口贴靠到下半屏

四分屏(4 路分割)

  • top-left-screen - 左上象限(1/4 屏幕)
  • top-right-screen - 右上象限(1/4 屏幕)
  • bottom-left-screen - 左下象限(1/4 屏幕)
  • bottom-right-screen - 右下象限(1/4 屏幕)

三分屏(3 路分割)

  • left-one-third-screen - 左三分之一(1/3 屏幕)
  • middle-one-third-screen - 中间三分之一(1/3 屏幕)
  • right-one-third-screen - 右三分之一(1/3 屏幕)

三分之二(2/3 分割)

  • left-two-thirds-screen - 左三分之二(2/3 屏幕)
  • right-two-thirds-screen - 右三分之二(2/3 屏幕)

窗口控制

  • maximize-screen - 操作系统最大化(有边框,任务栏可见)
  • fullscreen-screen - 全屏模式(平台特定行为)
  • minimize-screen - 将窗口最小化到任务栏/程序坞

⚡ 性能特征

Windows 性能

  • 总时间:每次操作 15-60ms
  • 检测:2-5ms(直接 Win32 API)
  • 操作:10-47ms(带修正的 SetWindowPos)
  • 最佳情况:简单分割 15-25ms
  • 典型情况:大多数操作 20-35ms

macOS 性能

  • 总时间:每次操作 50-150ms
  • 检测:20-50ms(AppleScript + 辅助功能 API)
  • 操作:15-55ms(AXUIElement 操作)
  • 最佳情况:简单分割 50-80ms
  • 典型情况:大多数操作 80-120ms

🔍 技术架构

Windows 实现

  • 通过 pywin32直接 Win32 API 调用
  • DWM 集成用于准确的框架边界
  • DPI 感知定位用于高分辨率显示器
  • 双遍定位用于精确的窗口放置

macOS 实现

  • AppleScript 焦点检测用于可靠性
  • 辅助功能 API用于窗口操作
  • 回退机制用于边缘情况
  • 屏幕感知定位尊重菜单栏和程序坞

跨平台功能

  • 自动平台检测
  • 条件依赖加载
  • 统一 API 接口
  • 错误处理和恢复

📋 平台依赖

Windows

  • 必需pywin32>=306
  • 用途:Win32 API 访问、DWM 集成、窗口操作

macOS

  • 必需pyobjc-core>=10.1,<11pyobjc-framework-Cocoa>=10.1,<11pyobjc-framework-Quartz>=10.1,<11pyobjc-framework-ApplicationServices>=10.1,<11
  • 用途:辅助功能 API、AppleScript 集成、窗口管理

🚨 故障排除

常见问题

macOS 焦点检测问题

  • 症状:窗口不移动或选择了错误的窗口
  • 解决方案:确保终端在系统偏好设置 > 安全性与隐私 > 隐私 > 辅助功能中具有辅助功能权限

Windows DPI 问题

  • 症状:在高 DPI 显示器上窗口定位不正确
  • 解决方案:服务器自动处理 DPI 感知,但确保安装 pywin32>=306

MCP 客户端连接问题

  • 症状:直接调用时功能正常,但通过 MCP 失败
  • 解决方案:检查 MCP 客户端日志,确保正确配置,重启 MCP 客户端

性能优化

  • 首次运行:可能由于系统预热而较慢
  • 后续运行:应该持续快速
  • 复杂应用:Safari、Chrome 可能由于窗口结构而需要更长时间

🔧 开发

项目结构

computer-split-screen/
├── src/splitscreen_mcp/
│   ├── __init__.py          # 包初始化
│   ├── __main__.py          # MCP 服务器入口点
│   └── window_actions.py    # 核心窗口管理逻辑
├── pyproject.toml           # 项目配置
├── README.md               # 本文件
└── LICENSE                 # MIT 许可证

从源码构建

git clone https://github.com/Beta0415/computer-split-screen-mcp.git
cd computer-split-screen-mcp
uvx install -e .

运行测试

# 测试窗口检测
python3 -c "from src.splitscreen_mcp.window_actions import left_half_window; left_half_window()"

# 测试 MCP 服务器
uvx run computer-split-screen-mcp

贡献

📄 许可证

本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。

🤝 贡献

欢迎贡献!请随时提交拉取请求。对于重大更改,请先开一个 issue 来讨论您想要更改的内容。

📊 版本历史

  • v1.4.4 - 当前稳定版本
    • 跨平台窗口管理
    • 16 个全面工具
    • 高性能实现
    • 完整 MCP 协议支持

🆘 支持

如果您遇到任何问题或有疑问:

  1. 检查上面的故障排除部分
  2. 查看 MCP 客户端日志中的错误
  3. 直接测试功能以隔离问题
  4. 在项目仓库上开一个 issue

为 MCP 社区用心构建 ❤️

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpcn_splitscreen-0.1.23.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpcn_splitscreen-0.1.23-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file mcpcn_splitscreen-0.1.23.tar.gz.

File metadata

  • Download URL: mcpcn_splitscreen-0.1.23.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for mcpcn_splitscreen-0.1.23.tar.gz
Algorithm Hash digest
SHA256 b2cd9a25fa2c7105733468c372270b4d687cf2a3c6a7a99c8126b4205e41c708
MD5 454fa9bbb8b1ce43bae1926224e84edb
BLAKE2b-256 738aeac8f366bdcd60c3c5a39f13125f9bf21f67f4e31a04d1684e18c56174e1

See more details on using hashes here.

File details

Details for the file mcpcn_splitscreen-0.1.23-py3-none-any.whl.

File metadata

File hashes

Hashes for mcpcn_splitscreen-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 f0e4cdd8d1c95175ff959bcb862fcab38388d383809f9bbe78364b7bb8784459
MD5 c852ce5ce4df41a7fe92339d868877eb
BLAKE2b-256 b0e05875c0320777e299d3cf9f23b7a70755a20213e6f630ab6e79c01023e126

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.23 This release

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page