MCP Servers for Agents
Connect coding agents to Ljós with the authoring MCP server (ljos
mcp) and the live application inspector (ljos run --mcp and ljos
attach).
This page explains how to connect coding agents to Ljós's two Model Context Protocol (MCP) servers: the authoring server (
ljos mcp) for static checking, formatting and project queries, and the live inspector (ljos run --mcp and ljos attach) for inspecting and driving a running application.Both servers use the same addressing model as screen readers and behaviour tests: accessible roles and names,
objectName, QML id and snapshot references.Start the authoring server over standard input and output:
By default,
ljos mcp is read-only and confined to the --project directory (symbolic links pointing outside the project directory are refused with path_denied). Grant --caps fs to let the agent write formatted files, apply fixes or scaffold components, and --caps run to let it execute test targets and feature scenarios:The authoring server also exposes resources (
ljos://types/{module}/{type}, ljos://ledger[/{module}/{type}], ljos://docs/{path}, ljos://features/{path}, ljos://features/steps, ljos://lints, ljos://project/qml-files) and workflow prompts (write-component, port-from-qtquick, add-accessibility, design-review, localise, write-feature, test-app, embed-in-rust).The same workflows ship as Agent Skills in the repository's
skills/ directory, one directory per skill, so that an agent picks one by what you ask for instead of you naming a prompt:A skill calls the authoring server's tools, so it needs the
ljos command on PATH and the server connected under the name ljos. To install the skills for Claude Code in one project, copy the directories into the project's .claude/skills/:Copy them into
~/.claude/skills/ instead to have them in every project. Other agents that read Agent Skills take the same directories; see where your agent looks for them.Start your application with
--mcp to enable the live inspector:Passing
--mcp with no value enables inspect only, where every offered tool is read-only. Each capability unlocks a group of actions:inspect: Read application status, accessibility snapshots, object trees, properties, binding graphs, screenshots, logs, metrics, processes, mailboxes, models, traces, wakes and design audits.input: Synthesise clicks, typing, key presses, scrolling, touch gestures, window resizing, appearance changes and virtual clock advances (app_advance, on hosts with a virtual clock).mutate: Set property values, edit writable model cells, invoke methods or signals, trigger a hot reload (app_reload), and import a module from another directory (app_alias).eval: Run JavaScript expressions in the context of an object (app_eval) or bind a property to a live JavaScript expression (app_set_property with binding).When the application starts, it binds a loopback HTTP listener (or a Unix socket with
--mcp-socket <PATH>) and writes the address and a bearer token to target/ljos/mcp-<pid>.json (mode 0600). Only local clients that present this bearer token are answered; requests without the current token receive HTTP 401.ljos run --headless runs the application with no window and needs no display, so an agent can drive it on a server, in a container or in CI:The root is laid out at
--size WxH, or else at its own size, and every inspector tool works as it does on a window: app_screenshot returns the scene's picture, input acts on the scene, app_resize sets the size of the next picture, and --watch applies saves and keeps the application's state. Timers and animations run on the real clock, and the process sleeps when nothing is due. The inspector line is written to standard error as usual. There is no system clipboard, file dialog, URL opener or screen reader, and a Window is an item of the scene, not a platform window. A run with neither --mcp nor --watch lasts until the application calls Qt.quit().Most coding agents start MCP servers as stdio subprocesses. Point your agent's MCP configuration at
ljos attach:ljos attach finds the newest target/ljos/mcp-<pid>.json under the directory, relays JSON-RPC messages over stdio to the running application, and re-reads the token file on every message so it automatically follows the application across restarts.Every tool that takes a
target accepts:Snapshot refs (
e3 or ref=e3): Short identifiers from the latest app_snapshot. If the object was destroyed, the tool returns stale_ref.Playwright-style locators: Durable across hot reloads, such as
role=button[name="Delete"], text=Save, #objectName (which also matches a QML id when no object has that objectName, such as #app on the root window), chained with >>, nth= (nth=-1 is the last, except after at=, which counts from the topmost) and name~=regex.Object handles (
@12.3): Generation-tagged handles returned by app_objects, app_inspect and app_processes that name any object, including non-visual Timers, models and animations.Fields with a hidden echo mode (such as
TextInput { echoMode: TextInput.Password }) have their text, displayText, selectedText and preeditText masked as <redacted> automatically. If that secret string appears inside another property, an objectName, a QML id, a window title, a log line, a fault, a compiler warning or a script return value, the inspector masks it there too, and paints over the item's bounds in app_screenshot. The inspector remembers at most 1024 secrets, so it can forget old ones. A compiler warning it has already sent stays masked. Once it has forgotten a secret that a warning quoted, it withholds any warning it has not sent before and counts it in warnings_omitted. Starting ljos run with --mcp-redact masks all editable text fields and disables app_eval and script invocation completely.