qsmcp
MCP server for developing Quickshell widgets that lets AI agents render individual widgets to PNG previews offscreen, without screen capture or affecting the live shell.
README
qsmcp
An MCP server for developing Quickshell widgets with an AI coding agent. Its headline tool renders one widget to a PNG — offscreen, sandboxed, without capturing your screen and without touching your running shell.
The image comes back in the tool result, so the model actually sees what it built.
Why
Iterating on a Quickshell widget normally means restarting the whole shell and
screenshotting the entire desktop. That is slow, leaks everything else on
screen, and disturbs the live session. qs_preview renders just the component.
The render primitive is Qt's Item.grabToImage(callback, targetSize), which
re-renders the item subtree into a framebuffer object. It is not a screen
grab and not a window readback, and it works on an item far larger than its
host window — a 1920×40 bar is captured from an 8×8 window.
Requirements
- Quickshell (
qs) and Qt 6 - Node 22+ — Node strips the TypeScript natively, so there is no build step
kwin_wayland(optional) — only needed to previewPanelWindow-rooted components
Install
git clone https://github.com/fedsfarm/qsmcp ~/Projects/qsmcp
cd ~/Projects/qsmcp && npm install
Register it with Claude Code, project-scoped so it only loads inside your shell
repo. QSMCP_SHELL_ROOT is the directory holding your shell's root QML file:
cd ~/my-shell-repo
claude mcp add qsmcp --scope local \
-e QSMCP_SHELL_ROOT=$HOME/my-shell-repo/quickshell \
-- node $HOME/Projects/qsmcp/src/index.ts serve
Or write it into .mcp.json / any MCP client config by hand:
{
"mcpServers": {
"qsmcp": {
"type": "stdio",
"command": "node",
"args": ["/home/you/Projects/qsmcp/src/index.ts", "serve"],
"env": { "QSMCP_SHELL_ROOT": "/home/you/my-shell-repo/quickshell" }
}
}
}
With QSMCP_SHELL_ROOT unset it falls back to $XDG_CONFIG_HOME/quickshell.
Verify the handshake without a client:
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}' \
| QSMCP_SHELL_ROOT=~/my-shell-repo/quickshell node src/index.ts serve
Tools
| tool | what it does |
|---|---|
qs_preview |
Render one component to a PNG and return the image plus structured QML diagnostics |
qs_symbol |
A component's root type, imports, properties, signals, functions, and a preview hint |
qs_list_components |
List components with root types, optionally filtered |
qs_live_instances |
Read-only. Running Quickshell instances |
qs_live_ipc_describe |
Read-only. qs ipc show — the live IPC surface |
qs_live_prop_get |
Read-only. qs ipc prop get |
qs_live_logs |
Read-only. qs log -t N, never follows |
No tool mutates the running shell. There is deliberately no ipc call, no
reload and no screen capture.
qs_preview arguments
| arg | meaning |
|---|---|
component |
Bare name ("ClockWidget"), path relative to the shell root ("components/Bar.qml"), or an absolute path |
source |
Raw QML to render instead of an existing component. A complete document; relative imports like import "../config" resolve normally, and nothing is written to your tree |
props |
Property values to set on the component, e.g. {"open": true, "tab": "notepad"} |
width / height |
Explicit logical size. Omit to use the component's implicit size |
dpr |
Device pixel ratio, 0.25–4. Default 2 |
background |
theme (default, the shell's panel colour), solid, checker, transparent |
bg_color |
Colour for background: "solid" |
padding |
Logical px around the component. Default 12 |
model_data |
Value for a required modelData property; "screen:0" for the first monitor. Auto-filled when the component requires it |
pre_script |
QML evaluated before mounting, e.g. "Anim.enabled = false" to freeze animations |
ready_expr |
QML that must be true before capture, e.g. "Config.ready && Theme.themesLoaded" |
max_ms |
Deadline for reaching a stable frame. Default 8000 |
save_to |
Also copy the PNG to this path |
Two traps worth knowing:
- A component gated on an
open/visibleproperty renders as a solid rectangle and still reportsok: true. Pass the gating props, or you are looking at a confidently-empty image.qs_symbollists which props exist. widthalso sets the virtual screen width forPanelWindowcomponents, and they size themselves against it. Pass the real monitor width and crop afterwards rather than shrinking the surface.
How isolation works
Offscreen (default). The generated harness sets its own environment before
QGuiApplication exists, using Quickshell's pragma block:
//@ pragma Env QT_QPA_PLATFORM=offscreen
//@ pragma ShellId qsmcp
//@ pragma DataDir/StateDir/CacheDir <scratch>
The server additionally unsets WAYLAND_DISPLAY and
HYPRLAND_INSTANCE_SIGNATURE, so the Wayland backend and Hyprland IPC stay
down — a preview cannot map a surface, capture a screen or dispatch a
compositor command. DISPLAY is kept, because libqoffscreen has a GLX path
(QOffscreenX11GLXContext) that gives hardware GL, which is what makes
ShaderEffect and MultiEffect blur render correctly. No window is ever
mapped on it.
Nested. PanelWindow cannot even be constructed offscreen ("No PanelWindow
backend loaded"), so window-rooted components get a private kwin_wayland --virtual instance on its own XDG_RUNTIME_DIR. KWin implements
zwlr_layer_shell_v1, so the type resolves. That virtual output exposes no
usable EGL config to clients, so Qt Quick falls back to the software renderer
there — reported as degraded: [shadereffect, blur, layer_effects] rather than
silently producing a flat image. Blur fidelity still means a real session.
The overlay
Quickshell.shellDir is the directory of the root QML file, and real configs
derive shellDir + "/themes" and shellDir + "/scripts" from it. So the
harness runs from an overlay: a scratch directory under
$XDG_RUNTIME_DIR/qsmcp/<hash>/shell that mirrors your tree file-by-file.
That buys three things:
- Script stubs. Scripts that apply GTK/Qt/kitty themes, set wallpaper or
change hardware are replaced with executable no-ops. The stub must exist,
not be absent — some configs fall back to a hardcoded absolute path when the
shellDircopy is missing, so a missing stub would silently run the real theme applier. Anything a preview tried to invoke is reported asside_effects_blocked. Only executables are ever stubbed; QML is never touched. - Correct relative imports. A file loaded as
<overlay>/components/Foo.qmlresolvesimport "../config"against its URL, so singletons instantiate exactly once. Mixing real and overlay URLs would create twoThemeobjects. - A shadow
$HOME. Per-entry symlinks to your real home, except the config directories your shell writes to, which are real copies — soConfig.set()and equivalents land in scratch. Directories referenced viaQuickshell.env("HOME") + "/..."are detected automatically; large trees (wallpaper libraries) stay symlinked.
Nothing is ever written under your shell tree. $XDG_RUNTIME_DIR is tmpfs, so
logout is a hard reset.
Settle
Previews never sleep a fixed interval. The harness waits for ready_expr, then
grabs a downscaled probe frame every 120 ms and requires two byte-identical
frames before the real capture. A component that never settles (a clock with
seconds, a spinner) returns the image with settled: false and
reason: "timeout" rather than pretending. pre_script: "Anim.enabled = false"
usually fixes it.
CLI
The same renderer without a client, for scripting or debugging:
QSMCP_SHELL_ROOT=~/my-shell/quickshell node src/index.ts render ClockWidget --out /tmp/clock.png
QSMCP_SHELL_ROOT=~/my-shell/quickshell node src/index.ts render Bar --width 1920 --height 40 --dpr 1 --padding 0
node src/index.ts render --help
node src/index.ts info # resolved config, scratch paths, detected copy paths
The CLI writes JSON to stdout and progress to stderr; you then have to open the PNG yourself. Through MCP the image is in the tool result, which is why the server is the intended path.
Environment
| var | effect |
|---|---|
QSMCP_SHELL_ROOT |
Directory holding the shell's root QML. Defaults to $XDG_CONFIG_HOME/quickshell |
QSMCP_QS_BIN |
Path to the qs binary. Default qs |
QSMCP_STUB_EXTRA |
Comma-separated script names to stub on top of the defaults |
QSMCP_STUB_EXEMPT |
Comma-separated script names to force-keep live |
QSMCP_ALLOW_MUTATING |
1 disables the stub layer entirely. Off by default, and off is the point |
Known limits
- Contact sheets, synthetic hover/press (
QtTest), and a warm daemon are not implemented; every render is a cold spawn (~2 s). - The Quickshell API knowledge layer (parsing
*.qmltypesand the annotated headers) is not built yet. qmllintintegration is not wired. Note that/usr/bin/qmllintis often Qt 5.15; the usable one is/usr/lib/qt6/bin/qmllint.- Nested (window-rooted) previews are software-rendered, so blur and shader effects do not appear.
probes/RESULTS.md records the containment and non-interference probes the
design is built on.
License
GPL-3.0-or-later. See LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。