KDE Plasma
v0.22.0Safely control KDE Plasma 6 desktops from MCP agents
An MCP server that lets AI agents (Claude Code, Codex, Cursor and other MCP clients) see and control a KDE Plasma 6 desktop. It works through KDE's own interfaces (D-Bus, KWin scripting and KConfig) instead of screenshots and simulated clicks. Every write can be previewed and undone. Ask your agent to "tile my editor next to the browser", "switch to a dark theme" or "tell me when the build notification arrives". Questions, ideas or something to show? Join the Discussions. Bugs go in Issues.
Summary extracted from the README.
plasma-mcp
An MCP server that lets AI agents (Claude Code, Codex, Cursor and other MCP clients) see and control a KDE Plasma 6 desktop. It works through KDE's own interfaces (D-Bus, KWin scripting and KConfig) instead of screenshots and simulated clicks.
Every write can be previewed and undone. Ask your agent to "tile my editor next to the browser", "switch to a dark theme" or "tell me when the build notification arrives".
GNOME (beta): the same server also runs on GNOME. It detects the desktop at startup and offers the tools that desktop supports. See GNOME.
Questions, ideas or something to show? Join the Discussions. Bugs go in Issues.
Contents
- Requirements
- Install
- Tools
- GNOME
- Permissions
- Undo and snapshots
- How it works
- Limitations
- Development
Requirements
- KDE Plasma 6 (tested on Plasma 6.8, Wayland, CachyOS)
- Python 3.12+ and uv
kreadconfig6/kwriteconfig6and theplasma-apply-*tools, which ship with Plasma- Optional: KDE Customizer (
kdecon yourPATH), required only for the theme tools
Install
As a Claude Code plugin
In Claude Code (needs uv; the plugin runs uvx plasma-mcp):
/plugin marketplace add RJCogburn/plasma-mcp
/plugin install plasma-mcp@plasma-mcp
If you registered the server by hand before, remove that entry (claude mcp remove plasma)
so it doesn't run twice.
From a release
Install the MCP server as a user tool:
uv tool install plasma-mcp
The executable will be available as plasma-mcp.
Register it with Claude Code:
claude mcp add --scope user plasma -- plasma-mcp
For another MCP client, configure it to run plasma-mcp over stdio.
From source
git clone https://github.com/RJCogburn/plasma-mcp.git
cd plasma-mcp
uv sync
Register it with Claude Code for all your projects:
claude mcp add --scope user plasma -- uv --directory /path/to/plasma-mcp run plasma-mcp
Start a new Claude Code session; the tools appear as mcp__plasma__*.
For other MCP clients, run the stdio command uv --directory /path/to/plasma-mcp run plasma-mcp.
Theme tools (optional)
Either install method needs KDE Customizer for the theme tools:
uv tool install git+https://github.com/RJCogburn/kde-customizer
Upgrading
uv tool upgrade plasma-mcp
Tools
The tier column refers to the permission tiers described below.
Settings
| Tool | Tier | What it does |
|---|---|---|
get_setting |
read | Read a KConfig value, e.g. kwinrc / Windows / FocusPolicy. Nested groups use /. |
set_setting |
write | Write a KConfig value. Dry run by default. |
undo_last |
write | Restore the most recent snapshot (settings or theme). |
Windows
| Tool | Tier | What it does |
|---|---|---|
list_windows |
read | Each window's id, app, title, desktops, geometry and active/minimized state, plus the virtual desktops. |
focus_window |
write | Activate a window. It un-minimizes it and switches to its desktop. |
move_to_desktop |
write | Move a window to a virtual desktop, by name or 1-based number. |
tile_window |
write | Tile it to the left / right / top / bottom half, maximize or unmaximize. |
minimize_window |
write | Minimize a window, or restore it with minimized=false. |
move_resize_window |
write | Move and resize a window to an exact frame geometry (unmaximizes it first). |
close_window |
dangerous | Close a window like its close button does; apps can still ask to save unsaved work. Not undoable. Dry run by default. |
Apps
| Tool | Tier | What it does |
|---|---|---|
list_apps |
read | Installed applications from the app menu (desktop entries): id, name, description, categories. query filters, e.g. "text editor". |
launch_app |
write | Start an installed app by its desktop id. Only installed apps, never arbitrary commands. Returns the app's new windows so the window tools can act on them. Dry run by default. |
Apps work on every desktop (KDE launches through kstart, others through gio launch).
Screenshots
| Tool | Tier | What it does |
|---|---|---|
screenshot |
read (interactive=false: private) |
Capture the screen through xdg-desktop-portal and return it as an image. window_id crops to one window. |
Screenshots only go through the desktop's screenshot portal, never a direct compositor grab, so you stay in control:
interactive=trueopens the portal's dialog for every shot; you pick the area and confirm. Needs only thereadtier.interactive=false(the default) captures the whole desktop without a dialog, but only after you have allowed screenshots once in the portal's permission prompt (KDE remembers it per app; on GNOME it's under Settings → Apps → Screenshots). It also needs theprivatetier, because it sees every window on screen.window_id(KDE and GNOME) crops to that window's frame. Focus the window first, or other windows may cover it.
The agent gets a copy scaled to max_size pixels on the longest edge (default 1568, PNG or
JPEG). The full-resolution file stays in ~/.cache/plasma-mcp/screenshots/ (the newest 20
are kept) and its path is in the result.
Displays
| Tool | Tier | What it does |
|---|---|---|
list_displays |
read | Connected monitors: mode (e.g. 3840x2160@60), refresh rate, scale, rotation, position and logical size, primary, available modes; on KDE also brightness and HDR. |
set_display |
write | Change a monitor's mode, scale, rotation, position, enabled state, primary, or brightness (KDE). Dry run by default; undoable. |
A wrong mode can leave a screen black, and the agent can't see that, so layout changes ask you to confirm:
- KDE: a notification asks "Keep these display settings?" with Keep and Revert buttons. Unless you click Keep within 20 s, the previous layout comes back.
- GNOME: GNOME Shell shows its own "Keep these display settings?" dialog and reverts after 20 s.
set_display waits for the answer and returns confirmation: kept, reverted or
timeout. Brightness changes don't ask. undo_last restores the whole previous layout
(on GNOME the Shell asks you to keep the restored one too). set_display refuses to turn
off the last enabled display.
Accessibility tree
| Tool | Tier | What it does |
|---|---|---|
accessibility_tree |
private | A window's UI elements: role, name, notable states (focused, checked, selected…), text, value and bounds relative to the window. query returns only matching elements, each with its path. KDE and GNOME. |
accessibility_status |
read | Whether accessibility is on, and which apps are on the accessibility bus. |
set_accessibility |
write | Turn accessibility on or off. Dry run by default; undoable. |
This reads the same accessibility data (AT-SPI) that screen readers use, so an agent can see
which buttons, fields and menus a window has without a screenshot. It is read-only: nothing
is clicked or typed. Unnamed layout containers are left out to keep the tree small, and
focused gives the path to the focused element.
Qt and KDE apps (and Chromium-based browsers) only expose their UI while accessibility is
on, which it usually isn't on KDE. Turn it on with set_accessibility(enabled=true); running
apps join within a second. GTK apps are always available. Reading the tree needs the
private tier because it includes what's in text fields.
Theming (needs KDE Customizer)
| Tool | Tier | What it does |
|---|---|---|
current_theme |
read | The global theme, color scheme, Plasma style, icons and cursor in use. |
theme_guide |
read | The theme spec format. Agents read this before writing a theme. |
check_theme |
read | Validate a .toml theme spec (contrast, missing installed themes). |
apply_theme |
write | Build and apply a spec. Dry run by default. It shows the exact install script. layout=true also replaces panels and needs the dangerous tier. |
Notifications
| Tool | Tier | What it does |
|---|---|---|
notify |
write | Show a notification (low / normal / critical). Returns its id. |
close_notification |
write | Close a notification by id. |
notification_status |
read | Server info and whether Do Not Disturb is on. |
watch_notifications |
private | Collect notifications from any app for up to 120 s. |
Media
| Tool | Tier | What it does |
|---|---|---|
media_status |
read | MPRIS players with playback status and the current track. |
media_play_pause |
write | Toggle play/pause on a player. |
Audio
| Tool | Tier | What it does |
|---|---|---|
list_audio |
read | Outputs (speakers, headphones, HDMI) and inputs (microphones) with volume, mute and the default, plus the apps playing or recording. |
set_volume |
write | Volume (0–100 %) and/or mute for a device (default-output, default-input, a name or part of its description) or an app's stream (its id or app name). Dry run by default. |
set_default_audio |
write | Make a device the default output or input. Dry run by default. |
Works on every desktop with PipeWire (or PulseAudio) through pactl. Volume never goes
above 100 %. Undo restores the exact previous per-channel levels, mute state or default.
Power
| Tool | Tier | What it does |
|---|---|---|
power_status |
read | AC or battery, the lid, laptop batteries, wireless peripherals (mouse, keyboard, headset) and the power profile. |
set_power_profile |
write | Switch between power-saver, balanced and performance. Dry run by default. The response names the previous profile (it isn't a config file, so undo_last doesn't cover it). |
Global shortcuts
| Tool | Tier | What it does |
|---|---|---|
list_shortcuts |
read | Every global shortcut with current and default keys. Search by text, by key (key="Meta+E" answers "what uses Meta+E?") or by component. |
set_shortcut |
write | Set or remove (keys=[]) an action's keys. Refuses keys another action already uses. Dry run by default. |
invoke_shortcut |
dangerous | Trigger an action directly, without simulating a key press. Dry run by default. |
Keys use the names System Settings shows, such as Meta+Ctrl+A, Meta+Shift+Left or
Volume Up. Super and Win are accepted for Meta. invoke_shortcut is in the
dangerous tier because some actions log out, shut down or close windows without asking.
Clipboard
| Tool | Tier | What it does |
|---|---|---|
get_clipboard |
private | The current clipboard text. |
clipboard_history |
private | Recent clipboard entries, newest first. |
set_clipboard |
write | Put text on the clipboard. Dry run by default. The previous contents stay in clipboard history. |
Clipboards often hold passwords and private messages, so reading needs the private tier.
Password managers mark secrets so Klipper never records them; plasma-mcp never sees those.
Panels and widgets
| Tool | Tier | What it does |
|---|---|---|
list_panels |
read | Panels (screen, location, height, alignment, hiding, length mode, floating) with their widgets in on-screen order, plus the desktops and their widgets. |
list_widget_types |
read | Installed widget plugins, e.g. org.kde.plasma.digitalclock. search filters. |
get_widget_config |
read | A widget's options in one config group (e.g. Appearance). |
add_widget |
dangerous | Add a widget to a panel (at the end or before another widget) or to a desktop. Dry run by default. |
remove_widget |
dangerous | Remove a widget. Dry run by default. |
set_panel |
dangerous | Change a panel's location, height, alignment, hiding, length mode or floating. Dry run by default. |
add_panel |
dangerous | Create a panel on a screen with a list of widgets. Dry run by default. |
remove_panel |
dangerous | Remove a panel and its widgets. Dry run by default. |
set_widget_config |
dangerous | Set one widget option, e.g. a clock's showSeconds. Dry run by default. |
Panel changes are in the dangerous tier because undoing them restarts plasmashell (your
panels disappear for a second or two). They are still snapshotted and undoable.
Events
| Tool | Tier | What it does |
|---|---|---|
subscribe_events |
read (notifications: private) |
Start buffering events of the given kinds in the background. Returns a cursor. |
poll_events |
read | Events after cursor, oldest first, plus the next cursor. wait_seconds (up to 120) waits for the first event. |
unsubscribe_events |
read | Stop listening (all kinds when none are given). |
| Kind | Events |
|---|---|
windows |
window_opened, window_closed, window_focused (with the window's id, app, title, geometry) |
desktops |
desktop_switched, desktop_added, desktop_removed, desktop_renamed |
media |
playback (Playing / Paused / Stopped), track, player_opened, player_closed |
config |
config_changed: which KConfig file, groups and keys changed (names only, no values) |
screen |
screen_locked, screen_unlocked |
notifications |
notification from any app (app, summary, body, urgency). Needs the private tier. |
clipboard |
clipboard_changed with the new text (first 2000 characters). Needs the private tier. |
power |
on_battery, on_ac, battery_level (every 5%), battery_state, battery_warning, device_added, device_removed, profile_changed, lid_closed, lid_opened, suspending, resumed, shutting_down |
An agent subscribes once and then polls in a loop, for example: "subscribe to windows and
media, then tell me when a new window opens". Events are kept until they're read, so
nothing is lost between calls. The buffer holds the last 1000, and poll_events reports
missed if older ones were dropped.
Push: event resources
For clients that support MCP resource subscriptions, each kind is also a resource,
plasma://events/<kind> (for example plasma://events/windows). Subscribing to one starts
that kind, like subscribe_events, and needs the same tier. The client is then notified
whenever new events of that kind arrive, with no polling. Reading the resource returns the
last 50 events of the kind plus the current cursor, which also works with poll_events.
Both subscription styles are supported: subscriptions/listen streams (MCP 2026-07-28) and
resources/subscribe (earlier protocol versions). A burst of events produces one
notification, not one per event.
GNOME
On GNOME (detected from XDG_CURRENT_DESKTOP), plasma-mcp offers 40 tools. Media,
notifications (Do Not Disturb = GNOME's notification banners off), power, apps, screenshots,
the accessibility tree, displays (no brightness), audio, events and
undo_last work as on KDE. These tools have GNOME versions:
| Tool | Tier | What it does |
|---|---|---|
get_setting |
read | Read a gsettings value, e.g. org.gnome.desktop.interface / color-scheme. |
list_settings |
read | List schemas, or one schema's keys with values and summaries. |
set_setting |
write | Write a gsettings value. Dry run by default; shows the allowed range. |
current_theme |
read | Dark/light preference, accent color, GTK, icon and cursor themes. |
theme_options |
read | The allowed accent colors and color schemes, and the installed themes. |
set_theme |
write | Change any of those. Dry run by default. |
list_shortcuts |
read | Window manager, Shell and media-key shortcuts, e.g. Super+Shift+Left. |
set_shortcut |
write | Set or disable a shortcut; refuses keys already in use. Dry run by default. |
list_windows |
read | Windows and workspaces, in the same shape as on KDE. Needs the extension. |
focus_window |
write | Activate a window (switches workspace, un-minimizes). Needs the extension. |
move_to_desktop |
write | Move a window to a workspace by name or number. Needs the extension. |
tile_window |
write | left / right / top / bottom half, maximize, unmaximize. Needs the extension. |
minimize_window, move_resize_window, close_window |
write / dangerous | As on KDE. Need the extension. |
get_clipboard |
private | The clipboard text. Needs the extension. |
set_clipboard |
write | Put text on the clipboard. Dry run by default. Needs the extension. |
Event kinds on GNOME: media, power, notifications, screen (lock/unlock),
config (config_changed lists the changed dconf keys), and with the extension
windows, desktops (workspace switches) and clipboard.
The GNOME Shell extension
GNOME's Wayland session has no public API for windows or the clipboard, so those tools use a small bundled GNOME Shell extension (GNOME 45 to 50). Install it once:
plasma-mcp install-gnome-extension # then log out and back in
plasma-mcp uninstall-gnome-extension # to remove it
It exposes org.plasmamcp.Shell on your session bus. Clipboard text is never sent in a
broadcast signal, and the extension itself refuses clipboard reads unless
private = true is set in ~/.config/plasma-mcp.toml, so turning on the extension
doesn't hand your clipboard to every program on the bus. Like other session-bus services,
it trusts programs running as your user (sandboxed Flatpak apps can't reach it).
Undo works the same way: undo_last puts each changed key back, or resets it to its
default if it was never set, so dconf ends up exactly as it was.
Not on GNOME: clipboard history (GNOME keeps none), invoking shortcuts, and panels/widgets (no GNOME equivalent). On other desktops, the desktop-independent tools (media, notifications, power, apps, events) are available.
Tested on Fedora 44 with GNOME 50.
Permissions
Tools are grouped into tiers. You choose which tiers are enabled in
~/.config/plasma-mcp.toml:
[tiers]
read = true # default: on (includes screenshots you approve in a dialog)
write = true # default: on (settings, themes, windows, clipboard, apps, displays, audio)
dangerous = false # default: off (panels and widgets, invoking shortcuts, closing windows)
private = false # default: off (other apps' notifications, the clipboard, dialog-free
# screenshots, the accessibility tree)
When a tool's tier is off, the call fails with an error that names the tier and this file.
Undo and snapshots
Every real write first copies the config files it can touch to
~/.local/state/plasma-mcp/snapshots/. undo_last restores the newest snapshot and
deletes it, so repeated calls step further back.
Restoring files alone doesn't change a desktop that's already running, so theme snapshots also record what was active: global theme, color scheme, Plasma style, cursor and icons. On undo, plasma-mcp re-applies those first, then copies the files back. A theme change and its undo leave your config byte-for-byte as it was. This was verified on a live desktop.
Two KDE details matter here:
- A global theme's values live in
~/.config/kdedefaults/, not in the files you would expect. Snapshots include that folder. - plasmashell keeps the panel layout in memory, writes it back when it exits, and writes
panel settings (height, alignment, ...) to disk about 10 seconds after a change. So
layout undo (panel tools and
apply_theme(layout=true)) stops plasmashell, copies the files back, starts it again, then re-applies each panel's settings as they were live when the snapshot was taken. Verified live: a panel removed seconds after being changed comes back exactly as it was.
How it works
- Settings:
kreadconfig6/kwriteconfig6. - Windows: a KWin script can't return a value to whoever loaded it. So for each call,
plasma-mcp exports a small D-Bus object, loads a one-shot script that calls back to it
with JSON (
callDBus), then unloads the script. Seeplasma_mcp/kwin.py; new KWin features can reusekwin.run(js). - Theming: shells out to KDE Customizer's
kdec(check,apply,ai-guide) rather than importing it, so the theme format and its install script stay in one place. - Notifications:
org.freedesktop.Notifications. Watching uses a D-Bus monitor connection (BecomeMonitor) that only matchesNotifycalls. - Media: MPRIS over the session bus.
- Audio:
pactl(PipeWire's PulseAudio interface) with JSON output (-f json). - Power: on the system bus. UPower for AC, lid and batteries (including wireless
peripherals), power-profiles-daemon for the profile, and logind's
PrepareForSleep/PrepareForShutdownfor suspend, resume and shutdown events. - Global shortcuts: kglobalaccel (
org.kde.kglobalaccel). Keys travel as Qt key codes;plasma_mcp/qtkeys.pymaps them to names and is generated from Qt itself (scripts/gen_qtkeys.py). kglobalaccel keeps shortcuts in memory, so undo sets the old keys back over D-Bus before restoringkglobalshortcutsrc. - Clipboard: Klipper (
org.kde.klipper, part of plasmashell). Clipboard events listen forclipboardHistoryUpdatedand report only when the text actually changed. - Panels and widgets: plasmashell's desktop scripting API
(
org.kde.PlasmaShell.evaluateScript). Tool arguments are passed to the script as a JSON value, never spliced into its code. Seeplasma_mcp/shell.py. - Screenshots:
org.freedesktop.portal.Screenshot. The image comes back as a file URI in the request'sResponsesignal; Pillow crops and scales it. Window crops map KWin's (or Mutter's) logical window geometry onto the image, which spans all screens. - Displays:
kscreen-doctoron KDE (-jto read,output.<name>.<setting>to apply, atomically) andorg.gnome.Mutter.DisplayConfig(GetCurrentState/ApplyMonitorsConfig, persistent) on GNOME. Undo re-applies the complete previous layout throughplasma_mcp/display_restore.py. - Accessibility tree: the AT-SPI bus (address from
org.a11y.Bus.GetAddress). A window is matched to its accessible frame by process id (KWin or the Shell extension), then by title. Each element's details are read in parallel with a per-call timeout, so a hung app can't stall the server. - Events: one shared D-Bus connection with signal matches for desktops, screen lock,
KConfig changes and MPRIS, plus a monitor connection for notifications. Window events
come from a long-running KWin script (
plasma_mcp_events) that calls back over D-Bus. Nothing listens until something subscribes, and everything (including the KWin script) is removed on unsubscribe or when the server exits.
Limitations
- Plasma 6, or GNOME with a smaller tool set. The KWin scripting API changed between Plasma versions, so Plasma 5 isn't supported. On GNOME, see GNOME for what's missing.
- No synthetic keyboard or mouse input. On Wayland that needs ydotool, libei or the RemoteDesktop portal, and it is out of scope for now. The accessibility tree is read-only for the same reason.
- Apps that don't support accessibility show little or nothing in
accessibility_tree(Tk, many games, some Electron apps). - An unanswered screenshot dialog blocks the portal. While a portal consent dialog is
open, xdg-desktop-portal answers no other app.
screenshotgives up after 120 s and closes its request; if the portal stays stuck, runsystemctl --user restart xdg-desktop-portal. - Window crops on mixed-scale screens are verified on KDE (1× and 1.25× side by side) but not yet on GNOME.
- Window geometry updates asynchronously. After
tile_window, calllist_windowsagain about half a second later to see the new size. - Fixed-size dialogs ignore tile and maximize.
- Widgets can't be moved within a panel yet. plasmashell's scripting API can insert a new widget at a position but not reorder existing ones while it runs. Remove and re-add instead (the widget's settings are lost).
get_widget_configshows only options that have been set. Defaults aren't stored, so a fresh widget's group can look empty.- Shortcuts are single key combinations. KDE allows multi-chord sequences (e.g.
Ctrl+X, Ctrl+S);set_shortcutsets one combination per key andlist_shortcutsshows the first chord. - Clipboard is text only. Images and rich formatting aren't read, and
set_clipboardputs plain text. Clearing the clipboard or its history isn't supported (it can't be undone). - Pushed events depend on the client. The
plasma://events/<kind>resources notify subscribers, but many MCP clients don't subscribe to resources or show the updates to the agent yet.poll_events(withwait_secondsto block until something happens) works everywhere. KWin reportswindow_focusedfor a new window just beforewindow_opened. - Do Not Disturb. While it is on, only
criticalnotifications pop up. plasma-mcp never changes your Do Not Disturb setting.
Development
uv sync --extra dev
uv run pytest
- Project notes and conventions for coding agents:
CLAUDE.md. - Every new tool must call
policy.require(<tier>), and every config write must go throughsnapshots.takebefore changing anything. - Test write tools on throwaway windows (a Tk or
kdialogwindow you open yourself), never on the user's own windows.
License
MIT, see LICENSE.