
kwin-mcp
io.github.VibeProgramm由 GitHub 帳號 VibeProgramm 發布v0.9.0更新於 Oct 24, 2026
KDE Plasma 6 Wayland GUI automation for AI agents: 30 tools (EIS input, screenshots, AT-SPI2).
概覽
此 MCP 伺服器讓 AI 助理在 KDE Plasma 6 Wayland 上啟動、觀察並操作 Linux 圖形介面應用程式,可在隔離的虛擬工作階段或真實 KWin 工作階段中進行。
- 可以做什麼
- 啟動、連線與停止 KWin 工作階段(虛擬或即時),在工作階段中啟動應用程式、列出並聚焦視窗,讀取應用程式日誌、查看 Wayland 協定資訊並呼叫工作階段內的 D-Bus 方法。擷取螢幕截圖,可在動作後依指定延遲連續擷取多張畫面,並檢查或搜尋 AT-SPI2 無障礙樹、等待元素出現。注入滑鼠操作:點擊、移動、捲動、拖曳以及按下與放開按鍵。注入鍵盤操作:輸入文字、輸入 Unicode 文字、按下組合鍵以及按住與放開按鍵。注入觸控手勢:輕觸、滑動、捏合與多指滑動。啟用剪貼簿支援後可讀取與設定剪貼簿文字。
- 適用情境
- 適用於 KDE/Qt/GTK 應用程式的端對端圖形介面測試(包括 CI 中的無頭執行),讓代理透過無障礙樹與截圖操作桌面應用程式,以及在真實或容器內的 KWin 桌面上進行即時協作。
- 執行需求
- Linux 上的 KDE Plasma 6 Wayland 環境、Python 3.12 或更新版本、支援虛擬工作階段的 kwin_wayland,以及 libei、spectacle、at-spi2-core、PyGObject 與 D-Bus 繫結。選用:wl-clipboard 用於剪貼簿工具與 Unicode 輸入備援,wtype 用於 Unicode 輸入,wayland-utils 用於列出協定。透過 uv 或 pip 從 git 安裝;不需要帳號或 API 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 kwin-mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
kwin-mcp
Model Context Protocol server for Linux desktop GUI automation on KDE Plasma 6 Wayland
Actively maintained fork of isac322/kwin-mcp. This fork ships the fixes users were waiting for: MCP Python SDK 2.x support, text input in virtual sessions (host keymap isolation), reliable window focus, bounded startup waits, silent input-drop fix, honest error contracts — see the changelog and releases. Install:
uv tool install git+https://github.com/VibeProgramm/kwin-mcp
[Python 3.12+] [License: MIT] [CI]
A Model Context Protocol (MCP) server that enables AI agents (Claude Code, Cursor, and other MCP clients) to launch, interact with, and observe any Wayland application in a fully isolated virtual KWin session -- without affecting the user's desktop. It also supports live desktop automation by connecting to an existing KWin session (real desktop or container) for collaborative workflows. With 30 MCP tools covering mouse, keyboard, touch, clipboard, accessibility tree inspection, screenshot capture, and window management, kwin-mcp provides everything needed for end-to-end GUI testing and desktop automation on Linux.
Table of Contents
- Why kwin-mcp?
- Use Cases
- Quick Start
- Configuration
- Available Tools
- How It Works
- System Requirements
- Installation
- Limitations
- Contributing
- License
Why kwin-mcp?
- Isolated sessions -- Each session runs in its own
dbus-run-session+kwin_wayland --virtualsandbox. Your host desktop is never affected. - Live session support -- Connect to a real KDE Plasma desktop or a KWin instance inside a container (e.g.
systemd-nspawn) for collaborative "share my screen" workflows. - No screenshots required for interaction -- The AT-SPI2 accessibility tree gives the AI agent structured widget data (roles, names, coordinates, states, available actions), so it can interact with UI elements without relying solely on vision.
- Zero authorization prompts -- Uses KWin's private EIS (Emulated Input Server) D-Bus interface directly, bypassing the XDG RemoteDesktop portal. No user confirmation dialogs.
- Works with any Wayland app -- Anything that runs on KDE Plasma 6 Wayland works: Qt, GTK, Electron, and more. Input is injected via the standard
libeiprotocol. - Full input coverage -- Mouse, keyboard, multi-touch, and clipboard -- all injected through the isolated session for complete desktop automation.
Use Cases
Automated GUI Testing
Run end-to-end GUI tests for KDE/Qt/GTK applications in headless isolated sessions. kwin-mcp launches each app in its own virtual KWin compositor, interacts via mouse, keyboard, and touch input, then verifies results through screenshots and the accessibility tree -- all without a physical display.
AI-Driven Desktop Automation
Let AI agents like Claude Code autonomously operate desktop applications. The agent reads the accessibility tree to understand the UI, performs actions through 30 MCP tools, and observes the results via screenshots -- creating a complete feedback loop for any Wayland application.
Live Desktop Collaboration
Connect to your real desktop session and let Claude observe and interact with what you see. Use session_connect or pass --default-live-session to make live mode the default. Also supports attaching to KWin running inside containers (e.g. systemd-nspawn) for isolated agent desktops.
Headless GUI Testing in CI/CD
Integrate Linux desktop GUI testing into CI/CD pipelines. kwin-mcp's virtual sessions require no X11 or physical display server, making it suitable for headless environments like GitHub Actions or GitLab CI runners on Linux.
Kiosk and Embedded Device Automation
Automate kiosk interfaces and embedded Linux desktops running KDE Plasma or a bare KWin Wayland compositor. Use session_start for isolated virtual testing of kiosk UIs, or session_connect to attach directly to a live kiosk or embedded device session for real-time automation and diagnostics.
Quick Start
Requires KDE Plasma 6 on Wayland. See System Requirements for details.
1. Install
2. Configure Claude Code
Add to your project's .mcp.json:
3. Use it
Ask Claude Code to launch and interact with any GUI application:
Claude Code will autonomously start an isolated session, launch the app, read the accessibility tree to find buttons, click them, and take a screenshot to verify the result.
Configuration
Recommended: install as a plugin
The fastest way to wire kwin-mcp into your editor is to install one of the bundled plugins. Each plugin auto-registers the MCP server and ships the kwin-desktop-automation skill, which teaches the agent which tool to call when (session-mode selection, the observe → act → verify loop, US-QWERTY vs Unicode typing, AT-SPI2 coordinate translation, and other platform pitfalls).
Claude Code — install the plugin from the marketplace:
OpenCode — add the npm plugin to your opencode.json:
For the full integration guide (manual fallback, customising the skill, troubleshooting), see docs/ai-agent-integration.md.
Claude Code
Add to your project's .mcp.json:
Or if installed globally:
Claude Desktop
Add to your claude_desktop_config.json:
Running Directly
Available Tools
Session Management (3 tools)
Observation (3 tools)
Mouse Input (6 tools)
Keyboard Input (5 tools)
Touch Input (4 tools)
Clipboard (2 tools)
Window Management (3 tools)
UI Polling (1 tool)
Advanced (3 tools)
Frame capture: Many action tools accept an optional
screenshot_after_msparameter (e.g.,[0, 50, 100, 200, 500]) that captures screenshots at specified delays (in milliseconds) after the action completes. This is useful for observing transient UI states like hover effects, click animations, and menu transitions without extra MCP round-trips. Frame capture uses the fast KWin ScreenShot2 D-Bus interface (~30-70ms per frame).
How It Works
Triple Isolation (+ Optional Home Isolation)
kwin-mcp provides three layers of isolation from the host desktop:
- D-Bus isolation --
dbus-run-sessioncreates a private session bus. The isolated session's services (KWin, AT-SPI2, portals) are invisible to the host. - Display isolation --
kwin_wayland --virtualcreates its own Wayland compositor with a virtual framebuffer. No windows appear on the host display. - Input isolation -- Input events are injected through KWin's EIS interface into the isolated compositor only. The host desktop receives no input from kwin-mcp.
- Home directory isolation (optional) -- When
isolate_home=trueis set insession_start, a temporary HOME directory is created with isolated XDG directories (XDG_CONFIG_HOME,XDG_DATA_HOME,XDG_CACHE_HOME,XDG_STATE_HOME). Apps in the session cannot read or modify host user settings (e.g.~/.config/kdeglobals), improving test reproducibility and safety.XDG_RUNTIME_DIRis intentionally not isolated because the Wayland socket resides there.
Input Injection
Mouse, keyboard, and touch events are injected through KWin's private org.kde.KWin.EIS.RemoteDesktop D-Bus interface. This returns a libei file descriptor that allows low-level input emulation without requiring the XDG RemoteDesktop portal (which would show a user authorization dialog). The connection uses:
- Absolute pointer positioning for precise coordinate-based interaction
- evdev keycodes with full US QWERTY mapping for keyboard input
- Smooth drag interpolation (10+ intermediate steps) for realistic drag operations
- EIS touch emulation for multi-touch gestures (tap, swipe, pinch, multi-finger swipe)
Screenshot Capture
The screenshot tool captures via the KWin org.kde.KWin.ScreenShot2 D-Bus interface (~30-70ms per frame), with spectacle CLI as a fallback. For action tools with the screenshot_after_ms parameter, the same D-Bus interface is used for fast burst capture. Raw ARGB pixel data is read from a pipe and converted to PNG using Pillow.
Accessibility Tree
The AT-SPI2 accessibility bus within the isolated session is queried via PyGObject (gi.repository.Atspi). This provides a structured tree of all UI widgets with their roles (button, text field, menu item, etc.), names, states (focused, enabled, visible, etc.), screen coordinates, and available actions (click, toggle, etc.).
System Requirements
Optional dependencies:
Installing System Dependencies
Arch Linux / Manjaro
Fedora (KDE Spin)
openSUSE (KDE)
Kubuntu / KDE Neon
Installation
Note: the
kwin-mcpname on PyPI tracks the upstream project (isac322/kwin-mcp, v0.7.0, MCP SDK 1.x). This repository is the actively maintained fork (v0.9.0, MCP SDK 2.x); install it from git or from a source checkout. Theuvx kwin-mcpconfig examples in the Configuration section resolve to the PyPI package.
Using uv (recommended)
Using pip
From source
Limitations
- US QWERTY keyboard layout only --
keyboard_typesupports US QWERTY only. For non-ASCII text (Korean, CJK, etc.), usekeyboard_type_unicode, which requireswtypeorwl-clipboardinstalled. - KDE Plasma 6+ required -- Older KDE versions or other Wayland compositors (GNOME, Sway) are not supported.
- AT-SPI2 availability varies -- Some applications may not fully expose their widget tree via AT-SPI2.
- Touch input is EIS-emulated -- Touch events are emulated through KWin's EIS interface, not from a real touchscreen device. Most applications handle emulated touch correctly, but some may behave differently from physical touch.
- Clipboard requires opt-in -- Clipboard tools (
clipboard_get,clipboard_set) are disabled by default becausewl-copycan hang in isolated sessions. Enable withenable_clipboard=trueinsession_start, and ensurewl-clipboardis installed. - QMenu (native context menus) may not appear in AT-SPI2 -- Qt's AT-SPI2 bridge has incomplete support for popup menus on Wayland. Context menus may not be visible in
accessibility_treeorfind_ui_elements. Workaround: usescreenshotto visually locate menu items and click by coordinates. - Screen edge triggers do not work with EIS input -- Auto-hide panels and layer-shell trigger strips rely on Wayland surface input routing, which may not respond to EIS-injected pointer events. Workaround: use
dbus_callwith KWin scripting or keyboard shortcuts instead. - AT-SPI2 coordinate translation is best-effort -- Wayland clients report window-local coordinates (they do not know their global screen position by design). kwin-mcp translates them to true screen coordinates using each window's compositor-side geometry (queried from KWin scripting, matched by caption). If a window cannot be matched, its coordinates fall back to window-local -- cross-reference with
screenshotto disambiguate.
Troubleshooting & Debugging
Verbose libei/EIS diagnostics (KWIN_MCP_DEBUG_EI=1)
Set the environment variable KWIN_MCP_DEBUG_EI=1 to enable verbose
diagnostics for the EIS input injection path (kwin-mcp's direct libei
connection to KWin):
When enabled, the kwin_mcp.input logger is raised to DEBUG level with a
stderr handler and logs EIS device lifecycle events
(ADDED / REMOVED / RESUMED / PAUSED / SEAT_REMOVED), device stalls, and
connection rebuilds. Use it when input injection silently does nothing or
behaves erratically: the log shows whether KWin is pausing/removing its EIS
devices around input bursts and whether kwin-mcp manages to rebuild the
connection.
Other symptoms
- No input backend available in
session_startoutput — KWin did not expose its EIS RemoteDesktop interface; the session degrades to a screenshot/AT-SPI2-only session (no injection). Check the KWin version (Plasma 6 required) and the server log for the degradation reason. keyboard_type_unicodefails in virtual sessions —kwin_wayland --virtualdoes not expose the virtual-keyboard protocolwtypeneeds; the clipboard fallback (requireswl-clipboard) is the primary path there.
Contributing
Contributions are welcome! See CONTRIBUTING.md for development setup, code style guidelines, and the pull request process.
License
來源:README.md,提交 7cef7af
工具
0版本歷史
1- v0.9.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分