MCP Server for Interaction with the Z Ecosystem (zurin, zbar, and zmenu)
Find a file
2026-11-09 01:11:15 +00:00
docs docs: record the live-test fixes (pointer, close race, layer arrange coalescing) 2026-10-17 11:24:53 +01:00
scripts feat: input injection tools + PERMISSION_LEVEL enforcement 2026-10-17 09:34:42 +01:00
src/zmcp docs: integration release notes, changelog and diagnostics; bump to 0.2.0 2026-10-17 11:32:53 +01:00
tests feat: input injection tools + PERMISSION_LEVEL enforcement 2026-10-17 09:34:42 +01:00
.gitignore chore: gitignore — editors, mypy cache and logs 2026-10-17 11:34:26 +01:00
CHANGELOG.md docs: integration release notes, changelog and diagnostics; bump to 0.2.0 2026-10-17 11:32:53 +01:00
config.example.toml feat: input injection tools + PERMISSION_LEVEL enforcement 2026-10-17 09:34:42 +01:00
LICENSE feat: zmcp 0.1.0 — MCP server for the Z ecosystem (zurin, zbar, zmenu) 2026-10-17 03:35:34 +01:00
pyproject.toml chore: update repository links and author metadata to the gabriel account 2026-11-09 01:11:15 +00:00
README.md chore: update repository links and author metadata to the gabriel account 2026-11-09 01:11:15 +00:00

zMCP

MCP server that bridges the Z ecosystem — zurin (compositor), zbar (status bar) and zmenu (launcher) — into any MCP client (opencode, Claude Desktop, …).

The whole integration uses the existing interfaces only: zurin's control socket ($XDG_RUNTIME_DIR/zurin.sock), zmenu's CLI/stdin/stdout modes and zbar's TOML config plus its Python integration scripts. No changes to the upstream projects.

What you get

  • 84 tools covering queries, control, events, menus, the bar and cross-ecosystem search.
  • Event streaming: subscribe to zurin events (window focus/open/close, workspaces, modes, monitors), pushed as resource updates and kept in a ring buffer for lossless polling.
  • Waiting tools: zurin_wait_for_client, zurin_wait_for_workspace, zurin_wait_for_event — let the agent block on a condition instead of polling.
  • Human-in-the-loop: zmenu_pick opens a menu on the desktop and returns the human's choice to the model.
  • Research helpers: z_search, z_docs, zurin_actions_reference, zurin_config_get, zurin_keybinds, zbar_script_output.

Requirements

  • Python ≥ 3.11
  • Zurin
  • zmenu on $PATH for menu tools; zbar for bar tools (both optional)

Install

git clone https://git.vortexia.wiki/gabriel/zmcp
cd zmcp
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"    # or: pipx install .

Run it (stdio MCP server):

zmcp            # console script
python -m zmcp  # module form

MCP client configuration

opencode (opencode.json) or Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "zmcp": {
      "command": "/path/to/zmcp/.venv/bin/zmcp",
      "env": { "ZMCP_LOG_LEVEL": "WARNING" }
    }
  }
}

Permission levels

Every tool call passes through a permission middleware backed by a single per-tool table (src/zmcp/permissions.py). Set the level in ~/.config/zmcp/config.toml (permission_level) or with ZMCP_PERMISSION_LEVEL; z_health reports the active level.

Level Allows
0 — read-only queries, searches, docs, health, event reads (nothing changes state)
1 — controlled (default) non-destructive writes (focus, workspaces, layout, gaps, opacity, appearance, validated config patches with backups, menus for the human) and basic interaction (zurin_type, zurin_key, zurin_pointer)
2 — full automation everything, destructive actions included: arbitrary commands (zurin_launch_command), closing windows, zurin_dispatch, zurin_raw_command, zbar_restart, zbar_script_click, zmenu_show (executes agent-authored commands)

Notes:

  • Denied calls return a readable permission denied: ... needs level N error with the knobs to raise it.
  • The older enable_spawn / enable_process_control settings still apply as additional gates on top of the level.
  • Input injection (zurin_type/zurin_key/zurin_pointer) lives at level 1 by design ("basic interaction"): keep in mind it types into whatever has focus, including password prompts. Set permission_level = 0 for strictly read-only sessions.

Configuration

Optional file at ~/.config/zmcp/config.toml (see config.example.toml):

Key Default Meaning
permission_level 1 0 read-only · 1 controlled writes + interaction · 2 full automation
command_timeout_s 6.0 zurin IPC reply timeout (compositor answers by 5 s)
subprocess_timeout_s 15.0 zmenu/zbar script/zurin -t subprocess timeout
event_buffer_size 1000 ring buffer depth for zurin_events
enable_spawn true allow zurin_launch_command (arbitrary shell)
enable_process_control false allow zbar_restart (SIGTERM + respawn)
allow_any_menu_path false allow menu files outside the zmenu custom dir
zmenu_bin / zbar_bin / zurin_bin / python_bin names binary overrides
zbar_config_path ~/.config/zbar/config.toml zbar config
zmenu_custom_dir ~/.config/zmenu/custom custom menu directory
zurin_config_path ~/.config/zurin/config.toml zurin config fallback

Environment overrides: ZMCP_CONFIG, ZMCP_RUNTIME_DIR (else XDG_RUNTIME_DIR), ZMCP_LOG_LEVEL, ZMCP_PERMISSION_LEVEL, ZMCP_COMMAND_TIMEOUT_S, ZMCP_SUBPROCESS_TIMEOUT_S, ZMCP_EVENT_BUFFER_SIZE, ZMCP_ENABLE_SPAWN, ZMCP_ENABLE_PROCESS_CONTROL, ZMCP_ALLOW_ANY_MENU_PATH, ZMCP_USE_PERSISTENT, ZMCP_ZMENU_BIN, ZMCP_ZBAR_BIN, ZMCP_ZURIN_BIN, ZMCP_PYTHON_BIN, ZMCP_ZBAR_CONFIG, ZMCP_ZMENU_CUSTOM_DIR, ZMCP_ZMENU_CONFIG, ZMCP_ZURIN_CONFIG.

Tools

Tool Description
zurin_version compositor version + IPC protocol
zurin_status mode, layout, gaps, border, config path, counts
zurin_workspaces workspaces per monitor + client counts (all_workspaces lists every tag)
zurin_clients windows with local filters (appid, title, workspace, monitor, flags)
zurin_client_details one window by id
zurin_search_clients fuzzy search over titles/appids
zurin_monitors outputs, modes, focused flag
zurin_apps / zurin_app_details configured apps and their commands
zurin_focused focused window details
zurin_get mode/gaps/layout/border/opacity
zurin_config_get / zurin_keybinds parse the zurin TOML config
zurin_validate_config zurin -t dry validation
zurin_actions_reference the action table (grounding for dispatch)
zurin_raw_command escape hatch: any single protocol line

zurin — control

Tool Description
zurin_open_app launch a configured [apps] entry
zurin_launch_command spawn a shell command (gate: enable_spawn)
zurin_close_client close by id or the focused window
zurin_focus / zurin_focus_stack / zurin_focus_direction focus by id, stack delta or direction
zurin_swap_window / zurin_resize_active / zurin_zoom tiling operations
zurin_toggle_floating / zurin_toggle_fullscreen window state
zurin_set_layout select or toggle layouts
zurin_workspace_switch / zurin_workspace_toggle workspace navigation
zurin_move_client_to_workspace / zurin_toggle_client_workspace focused-window tagging
zurin_move_client_to_monitor / zurin_focus_monitor / zurin_send_client_to_monitor multi-monitor
zurin_gaps / zurin_opacity / zurin_reset_opacity appearance
zurin_set_mode keybind submaps
zurin_screenshot clipboard, or to a file with save_path (returns path/size)
zurin_screenshot_image screenshot returned as an image the model can see
zurin_wallpaper change the wallpaper at runtime (fill/fit/tile/center)
zurin_type type UTF-8 text into the focused window (\n = Return, submit option)
zurin_key press a key/chord: Return, super+q, ctrl+shift+t (bypasses keybinds)
zurin_pointer move (absolute) / click / scroll the pointer
zurin_reload reload config (+ wallpaper)
zurin_dispatch any whitelisted action

Events

Tool Description
zurin_subscribe / zurin_unsubscribe push events as resource updates
zurin_events query the ring buffer (since_seq for incremental polling)
zurin_wait_for_event block until a matching event
zurin_wait_for_client wait for a window to open/close
zurin_wait_for_workspace wait for a workspace to activate

zmenu

Tool Description
zmenu_show_apps launcher with zurin [apps]
zmenu_show custom items (selection executes its command)
zmenu_show_file open a TOML menu
zmenu_pick ask a human and get the choice back
zmenu_pick_file ask a human over a TOML menu file (--print builds, dmenu fallback)
zmenu_list_menus / zmenu_read_menu / zmenu_validate_menu menu file tooling
zmenu_get_theme / zmenu_set_theme read/patch ~/.config/zmenu/config.toml (backup + atomic)

zbar

Tool Description
zbar_status process + config state, reload support probe, live control probe
zbar_config_get / zbar_validate_config / zbar_config_set TOML read/validate/patch (backup + atomic write)
zbar_get_appearance / zbar_set_appearance live appearance over the control socket
zbar_visibility / zbar_notify hide/show the bar; transient message for the human
zbar_widgets live widget state (volume, battery, network, clock)
zbar_subscribe / zbar_events control-socket events (visibility, config)
zbar_reload reload in place (control socket, SIGHUP fallback)
zbar_restart SIGTERM + detached respawn (gate: enable_process_control)
zbar_scripts_list / zbar_script_output / zbar_script_click integration scripts (weather, sysmon, bluetooth, music)

Cross-ecosystem

Tool Description
z_health diagnose runtime dir, socket, protocol, binaries
z_snapshot combined session picture
z_search search windows, apps, keybinds, menus and actions at once
z_docs embedded reference (overview/actions/ipc/configuration)
z_events_export export buffered event history

Resources

zurin://status, zurin://workspaces, zurin://clients, zurin://focused, zurin://monitors, zurin://events, zbar://config, zmenu://menus, docs://actions, docs://overview.

Roadmap

Planned source changes in zurin/zbar/zmenu that deepen the integration — every one backward compatible — are tracked in docs/ecosystem-roadmap.md (quick wins, the zbar control socket, zmenu flags, milestones and zmcp follow-ups).

Notes & limitations

  • zumcp talks to the running session; start zurin first. z_health reports what is missing.
  • The compositor refuses state changes while the session is locked (ERR: locked); tools surface that as a clear error.
  • zbar has no IPC on stock builds: zbar_config_set writes the file (backup + atomic), and the running bar applies it via zbar_reload (control socket or SIGHUP on builds that support it; the tool probes first) or zbar_restart (gate enable_process_control). With the zmcp-integration zbar build, zbar_get_appearance/zbar_set_appearance, zbar_visibility, zbar_notify, zbar_widgets and the event stream become available.
  • screenshot region and zmenu_pick need a human at the screen; they are interactive by design.
  • quit and chvt have no dedicated tools (see zurin_dispatch whitelist); zurin_raw_command can still send any protocol line.

Diagnostics

.venv/bin/python scripts/live_check.py

Reports, per feature and capability, what the running zurin/zbar/zmenu builds expose right now (including the active permission level) and exits non-zero while anything still needs a rebuild — the fastest way to verify an install.

Development

.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest            # unit + integration tests (fake zurin socket, fake zmenu)
.venv/bin/ruff check src tests

The test suite runs entirely without a Wayland session: a fake zurin socket server and fake zmenu scripts exercise the protocol, tools and resources through the SDK's in-memory client.

License

GPL-3.0-or-later, matching the Z ecosystem projects.