MCP Usage (optics mcp)¶
optics mcp runs a Model Context Protocol server that exposes the optics-framework keyword engine to an LLM client (Claude Desktop, Claude Code, Cursor, …). The model starts a device or browser session, acts on the screen with tools, and reads device state through resources. It drives a live target the way optics live does, but under agent control.
The default toolset has eleven tools. Each screen comes back as short rows, and every row has a ref such as e7:
screen 21d99e · 7 rows
e1 h1 "Optics Store"
e3 input "Email" [tap,input] #email
e7 button "Sign in" [tap]
The agent picks a row by its ref, and the server turns the ref into a locator that matches only that element. Every action returns what changed on the screen and a verdict on the text the agent expected to see.
There are no record, save or replay tools. To turn a session into a suite, the agent reads the optics://session/{id}/steps resource and the optics://project-format resource, writes an optics CSV project, and runs it with optics execute. The MCP layer is driver- and device-agnostic: it never runs adb and does not assume a device type. It only calls the driver server that you give to start_session.
1. Prerequisites¶
- Python 3.12+ and optics-framework installed.
- A driver target that optics can reach — e.g. a local Appium server with a connected device/emulator, or a remote Appium hub. You provide its URL and capabilities to
start_session. For websites, Playwright launches its own browser, so there is nothing to run. - An MCP-capable client (Claude Desktop/Code, Cursor, or the
fastmcpPython client for scripting). - (Optional) extras for richer element location: text detection (
googlevision) and image detection (templatematch) require their own credentials/config, exactly as in a normal opticsconfig.yaml.
2. Install¶
The MCP server depends on fastmcp, shipped as the mcp extra. The installer always includes it, finds a Python 3.12+ on its own and puts optics on your PATH. Then add the engine for your target:
curl -fsSL https://optics-framework.org/install | sh # macOS, Linux
optics setup --install playwright # websites (also downloads Chromium), or: appium
With pip, Optics needs Python 3.12+ (an older Python fails or resolves an old release) and you add the extra yourself:
python3.12 -m venv .venv && source .venv/bin/activate
pip install 'optics-framework[mcp,playwright]' && playwright install chromium
# from source:
poetry install --extras mcp
If the extra is missing, optics mcp exits with a clear message telling you to install it — the rest of the CLI is unaffected.
3. Run the server¶
# stdio transport (default) — for local clients that spawn the process
optics mcp
# HTTP transport — for networked / multi-client use
optics mcp --transport http --host 127.0.0.1 --port 8090
| Flag | Default | Meaning |
|---|---|---|
--transport | stdio | stdio (local clients) or http |
--host | 127.0.0.1 | bind host (http only) |
--port | 8090 | bind port (http only) |
--toolset | core | core (eleven tools) or full (also one tool per keyword); see §6 |
An HTTP server has no authentication, so it applies the same limits as optics serve (see the CLI usage for the list). A session belongs to the client connection that started it. Another client cannot use that session or see its id.
| Environment variable | Default | Meaning |
|---|---|---|
OPTICS_MCP_TOOLSET | core | the toolset when --toolset is not given |
OPTICS_MCP_SESSION_IDLE_S | 900 | a session that is idle for longer is ended on the next call; 0 turns this off |
OPTICS_MCP_CALL_TIMEOUT_S | 100 | the longest a tool call can take before it returns a timeout |
OPTICS_MCP_ALLOW_COORDINATE_TAPS | off | 1 lets run_keyword reach press_by_coordinates, press_by_percentage and swipe |
Docker¶
Containerized MCP runs HTTP transport bound to 0.0.0.0:8090 (stdio is for local clients that spawn the process). Images live under Docker/mcp/ and install the [mcp] extra (fastmcp). Set OPTICS_ALLOWED_HOSTS to the host names clients use (the compose file sets localhost), so a request with any other Host header gets 421.
Docker Compose (from the repo root):
# Production image (PyPI) — host port 8090
docker compose -f Docker/docker-compose.yml up --build mcp
# Development image (local .whl) — host port 8091
docker compose -f Docker/docker-compose.yml up --build mcp-dev
Standalone build/run:
docker build -f Docker/mcp/prod/Dockerfile -t optics-mcp-prod .
docker run -d -p 8090:8090 --name optics-mcp-prod optics-mcp-prod
Connect your MCP client to the container:
Use port 8091 for the mcp-dev compose service. When start_session targets Appium on the host, set "url": "http://host.docker.internal:4723". See Docker/deployment.md for vision-backend build args, Google Vision credential mounts, and dev-wheel builds.
4. Connect an MCP client¶
stdio — the client launches the server itself. Add to your client's MCP config (e.g. Claude Desktop claude_desktop_config.json, or Claude Code .mcp.json):
In the Claude Code CLI, claude mcp add optics -- optics mcp writes the same entry.
If optics isn't on the client's PATH, use the absolute path (e.g. /path/to/.venv/bin/optics) or "command": "python", "args": ["-m", "optics_framework.helper.cli", "mcp"].
HTTP — start the server yourself (optics mcp --transport http) and point the client at the URL:
5. The expected journey¶
start_sessionopens a session and returns its id. Passapp(a URL on the web, a package or bundle id on a device) and the reply also holds the first screen as rows, in the text and instructuredContent.screen.rows. The launch is step 1 of the session.elements_sourcesdefault per driver, so adriveralone is enough. A device is named incapabilities(for exampledeviceNameorudid); the MCP needs noadbof its own. For a website that needs a sign-in, see Start signed in.- Act with
tap,type_text,scroll,press_keyandlaunch_app. Give a ref from the latest screen as thetarget. An exact visible label or a locator (css=,xpath=,text=, an id, an image file) also works, but a ref is safer: the server acts on it only through locators, never through fuzzy text or OCR. - Verify. Add
expect_presentandexpect_absentto an action, with text that you already know and that the action shows or removes. A value typed withtype_textor a typing keyword such asenter_textis not checked, because the rows often do not hold it.okonly means that the keyword ran; it does not mean that the step worked. An action waits up to 5 seconds for its expectations before it judges them, so a page that loads after a redirect still passes. Usecheckfor a verdict without an action. - Observe only when you need more than the change list:
observe(query=…)finds rows on a long screen, andobserve(screenshot=true)adds a JPEG. - Build a reusable suite (see below).
terminate_sessionreleases the driver when you are done.
session_id can be left out when only one session is open. With more than one open, the error lists their ids. A session that is idle for longer than the idle lease (15 minutes by default) is ended on the next call to the server. terminate_session is never refused as busy: it waits until a running keyword ends. An unknown or ended session_id gives an unknown_session error.
What an action returns¶
tap e7 "Sign in" -> ok (XPath) · verified: pass
check present "Welcome": met
screen 4436bc · changed (+2 -0 ~0)
+ e8 p "Welcome, a@b.c"
+ e9 a "Orders" [tap]
- The first line gives the target, the keyword result with the locator strategy that found it, and the verdict.
- One line follows for each expectation.
- The screen line is
unchanged,changedwith the added (+), removed (-) and changed (~) rows, ornew screenwith every row. Callobservefor every row. - A row shows what a control holds:
= "Paris"for the text in a web field or the selected option,(checked)or(unchecked)for a checkbox, radio button or switch, and(filled)for a password field. A password is never shown. On a device, a field's label is the text it holds. A typed value shows as a changed row, so there is no need to read the field back. - A device row shows the short class name and id (
Button,#search_button). - A change lists the changed (
~) rows first, then at most 40 added rows, controls before text, and at most 10 removed rows; a line counts the rest.observe(query=…)finds a row that is not listed. - When an action on a checkbox, switch or field leaves the screen unchanged, a note says that the control did not change, so the action may have missed it.
- After an action the server reads the screen until it stops changing. A screen with no rows counts as a page that is still loading, so a sign-in hop or a redirect is read again for up to 6 seconds. A read-only keyword or
execute_scriptthat leaves the screen as it was is read once. - A ref stays with its control when the text around it changes: a control with its own id, a field that gets text and the rows under a window title keep their refs. A line break in a field's text or in a keyword result shows as
\n. - A ref never moves to a different element. A ref that is gone from the screen is an error that lists the current rows.
(off-screen)marks a web row that is on the page but scrolled out of view. A tap on it scrolls it into view.
The verdict rule:
| Result | verified |
|---|---|
| the keyword failed | fail |
| no expectations | unknown |
every expectation met, and the screen changed or an expect_present that was not met before is met now | pass |
| an expectation not met, and the screen did not change | fail |
| an expectation not met, but the screen changed | unknown (the unmet checks are listed) |
| the screen could not be read after the action | unknown; the expectations are not checked |
Each acting tool also returns structuredContent:
{"ok": true, "verified": "pass", "verb": "tap", "keyword": "press_element",
"target": {"ref": "e7", "label": "Sign in", "ladder": ["xpath=//button[normalize-space()='Sign in']"], "strategy": "XPath"},
"checks": [{"text": "Welcome", "expect": "present", "met": true}],
"screen": {"digest": "4436bc", "changed": true, "new_screen": false,
"added": [{"ref": "e8", "label": "Welcome, a@b.c", "cls": "p", "act": []}],
"removed": [], "relabelled": []}}
error ({code, kind, message}) is set when the call failed, screen.rows holds every row on a new screen (with no added/removed lists) and after an error, and result holds the keyword's return value (for example from get_text through run_keyword).
An action can run three times in a row without progress. The fourth identical action is refused with a loop error, and the keyword does not run. Progress is a pass verdict or a screen change. observe, check or a different action resets the count. press_key, read-only keywords, press_keycode and sleep do not count.
Build a reusable suite (there is no save tool)¶
- Read
optics://session/{session_id}/steps: it lists the session's actions withmodules_csvandelements_csvrows for the steps that ran. Secrets come back as<redacted>, so put them back before you run the suite; seeoptics://project-formatfor the details. - Read
optics://project-formatfor the folder layout,config.yaml,${variables}and escaping rules. - Write the files. Parameterize by putting run-specific values in
elements.csvand referencing them as${name}. A cell that is exactly${name}tries each of its values in order;${name}inside a longer value is replaced by its first value. - For loops, branches, computed values or API calls, write the control-flow keywords (
Run Loop,Condition,Evaluate,Invoke Api, …) into the modules. They run underoptics execute, not as live tools. - Optionally lint the suite with the optics-framework-lsp language server:
optics-lsp lint <folder> --json. - Run it:
optics execute <folder>. Results go toexecution_output/. When a step fails,failed_steps_elements.jsonholds the compact element list of the screen it failed on.
start_session arguments¶
| Arg | Type | Notes |
|---|---|---|
driver | str | driver name, e.g. "appium" (default) |
app | str | optional URL or app id to open before the first screen is read |
url | str | driver/hub URL (e.g. local http://127.0.0.1:4723 or a remote hub) |
capabilities | object | driver capabilities (platform, device, app, auth…) |
elements_sources | list[str] | element sources to enable; optional — defaults to the driver's canonical set (see §8) |
text_detection | list[str] | optional OCR sources (e.g. ["googlevision"]) |
image_detection | list[str] | optional template sources (e.g. ["templatematch"]) |
project_path | str | optional project folder (loads bundled templates); stdio only, an HTTP server refuses it |
ai_self_heal | bool | optional per-session override of the server's OPTICS_AI_SELF_HEAL default (see below) |
llm_provider | str | optional per-session override of the server's OPTICS_LLM_PROVIDER default (see below) |
llm_model | str | optional per-session override of the server's OPTICS_LLM_MODEL default (see below) |
strict_element_match | bool | reject fuzzy text matches for labels and locators (default false) |
Example — local Appium + Android emulator:
{
"driver": "appium",
"url": "http://127.0.0.1:4723",
"capabilities": {
"platformName": "Android",
"appium:automationName": "UiAutomator2",
"appium:deviceName": "emulator-5554",
"appium:appPackage": "com.android.settings",
"appium:appActivity": ".Settings"
},
"elements_sources": ["appium_find_element", "appium_page_source", "appium_screenshot"]
}
Omit appPackage/appActivity to attach to whatever is already on screen. For a remote/managed hub, set url to the hub and include any hub-specific capabilities (auth token, device id) just as you would in config.yaml.
Example — a website with Playwright:
{
"driver": "playwright",
"capabilities": { "browser": "chromium", "headless": false },
"app": "https://www.saucedemo.com"
}
launch_app(app="<url>") later navigates the same browser. The capabilities are the Playwright driver's config.yaml capabilities (browser, channel, headless, viewport, profile, element_timeout_ms, …; see Configuration).
Desktop apps¶
Use the Appium driver with the desktop, automationName: Xa11y and the app. Run Appium with appium-xa11y-driver on the machine that shows the app.
{
"driver": "appium",
"url": "http://127.0.0.1:4723",
"app": "com.apple.TextEdit",
"capabilities": { "platformName": "Mac", "automationName": "Xa11y" }
}
app is a bundle id or .app path on macOS and an executable on Linux and Windows. press_key takes a chord: cmd+a on macOS, ctrl+a on Linux and Windows. launch_app opens another app in the same session.
Start signed in¶
When a web flow signs in, the agent reads optics://browser-profiles. It lists the Chrome and Edge profiles on the machine that runs optics mcp, with the account in each:
The agent shows the list to the user and asks which profile to use. Then it passes the profile's directory, name or email as capabilities.profile:
{
"driver": "playwright",
"capabilities": { "profile": "me@example.com" },
"app": "https://app.example.com"
}
The browser starts with that profile's sign-ins. If the user picks no profile, the agent asks the user for the credentials and types them with type_text. A profile that matches no profile, or several, fails with E0501 and lists them; pass channel (chrome, chrome-beta or msedge) to choose between browsers.
A profile carries the sign-ins of the person who runs the server, so only a stdio server lists and accepts profiles. An HTTP server (--transport http) and optics serve refuse profile, and every API session refuses user_data_dir; set those in a project's config.yaml instead. See Configuration for what a profile carries over.
AI self-heal¶
Self-heal has two layers. Whoever starts optics mcp (or optics serve) can set a server-level default once via environment variables, so a client that's already integrated inherits it with no start_session changes:
| Env var | Default | Meaning |
|---|---|---|
OPTICS_AI_SELF_HEAL | off | true/1/yes/on (case-insensitive) enables it |
OPTICS_LLM_PROVIDER | gemini | which llm_models entry to enable: gemini, openai or anthropic |
OPTICS_LLM_MODEL | gemini-2.5-flash for gemini | model name; required for openai and anthropic, which have no default |
Because a single serve/mcp process is multi-tenant, each of these is also a per-session override on start_session: ai_self_heal, llm_provider, and llm_model. A per-session value always wins over the matching env-var default, so a caller can opt in/out and pick its own model without being locked to the operator's choice; anything left unset falls back to the env default (and then to gemini). LLM credentials always come from the provider's own environment variables (GEMINI_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY) — never through start_session — so choosing a provider/model per session exposes no secrets. The same goes for the endpoint: to route the openai engine to OpenRouter or a local server, the operator sets OPENAI_BASE_URL; a caller cannot point the server's key at a URL of its choosing.
When self-heal recovers a keyword, the call still succeeds, and the result carries the recovery so a client can learn how it was fixed:
{
"result": null,
"healed": true,
"heal_summary": "AI self-heal recovered 'press_element' after 2 steps: scroll down; press_element Login",
"suggested_steps": [
{ "keyword": "scroll", "params": ["down"] },
{ "keyword": "press_element", "params": ["Login"] }
]
}
suggested_steps is the clean, replayable recovery sequence — only the steps that actually worked, curated to the minimal set that reproduces the goal. A platform can persist these to replace the failing step, so the next run passes without needing self-heal. optics serve's POST /v1/sessions/{session_id}/action returns the same shape under data. In the core toolset the same object is the result of the action. Un-healed calls return the bare result, unchanged.
6. Tools reference¶
Core toolset (default)¶
Every tool except start_session takes an optional session_id. The acting tools (tap, type_text, scroll, press_key, launch_app, batch, run_keyword) also take expect_present and expect_absent.
| Tool | Params | Does |
|---|---|---|
start_session | driver, app, url, capabilities, … (§5) | starts a session; with app, returns the first screen |
terminate_session | — | ends the session and releases the driver |
observe | query, screenshot, max_rows (1–300, default 80) | lists the screen as rows; issues refs |
tap | target, repeat (1–20) | taps an element |
type_text | target, text, clear_first | types into a field |
batch | steps (1–12), each {tool, target, text} with tool one of tap, type_text, press_key | runs the steps in order in one call, for example to fill a form. It stops at the first step that fails, and the reply lists each step and the screen change from before the first step. The expectations judge the last step. For press_key, target is the key |
scroll | direction (up/down/left/right), until, timeout_s (1–60) | scrolls; direction is the way the content moves, so down shows what is below. Left and right swipe on a device and scroll the page on a web driver; a step records them as Scroll. until works with up and down only |
press_key | key | back goes one screen back on every driver; otherwise a key name (Enter, Escape, esc, ArrowDown; case and a KEYCODE_ prefix do not matter on the web) or an Android KeyEvent number (such as 66). A ref is refused with a hint to use tap |
launch_app | app | opens a URL, a package or a bundle id; empty opens the configured app |
check | present, absent, timeout_s (0–60) | waits for the texts or refs, then gives a verdict (passed); a locator in present is checked with assert_presence. timeout_s is the limit for the whole check |
run_keyword | keyword, params | runs any other keyword; an element param can be the ref of a row that has a locator |
check is a verdict: it is an error only when the server cannot read the screen. run_keyword reaches every keyword in optics://keywords. That catalog leaves out the session and capture internals and the deprecated keywords. With a session open, it also leaves out the keywords that the session's driver and platform do not support (for example the swipe keywords on a TV); start_session names them and run_keyword refuses them as unsupported. When a call has one param name that the keyword does not have, and the keyword still needs exactly one param, run_keyword takes it as that param (script for script_or_json). Coordinate keywords (press_by_coordinates, press_by_percentage, swipe) need OPTICS_MCP_ALLOW_COORDINATE_TAPS=1, because a pixel guessed from a screenshot often hits the wrong element. Keyword timeout params are capped at 60 seconds. run_keyword is marked destructive because it reaches force_terminate_app, close_and_terminate_app and execute_script.
Errors¶
An error reply starts with the optics error code when there is one, then one line of fact and one Next: line:
| Kind | Example |
|---|---|
stale_ref | e3 ("Sign in" button) is not on the current screen. and the current rows |
unknown_ref | No e99; current refs are e1–e12. |
ambiguous | the label matches more than one row; the refs are listed |
not_found | [E0201] not found: tried <locators>. and the current rows |
invalid_params | what is wrong, the real params and one correct call |
unsupported | [E0105] <tool> is not supported on this platform. |
session_lost | [E0106] the driver session ended. The session is closed. |
silent_failure | [E0401] <keyword> reported an error: … and the screen change |
timeout | the call took longer than OPTICS_MCP_CALL_TIMEOUT_S |
no_locator | run_keyword got the ref of a row without a unique locator; pass a locator or the label |
busy | an earlier call that timed out is still running on the device |
unknown_session | no such session; the reply says when it ended after the idle lease |
session_required | more than one session is open and session_id was left out; the ids are listed |
loop | <action> ran 3 times in a row without progress; not run again. The fourth try did not run. |
For an invalid_params, unsupported or other failure, the Next: line ends with a link to the keyword reference or the error codes page. The server instructions end with a link to https://optics-framework.org/llms.txt, the index of every docs page as Markdown.
Full toolset (--toolset full)¶
The full toolset keeps the earlier surface for clients that call keywords by name: one string-typed tool per keyword of ActionKeyword, AppManagement and Verifier (each takes session_id and the keyword's params as strings), the screenshot tool, and the core start_session, terminate_session, observe, tap, type_text, press_key, check and run_keyword. The keyword tools scroll and launch_app replace the core tools with the same names. An element param of a keyword tool also accepts a ref from the latest observe.
7. Resources reference¶
| URI | Content |
|---|---|
optics://keywords | the keywords run_keyword accepts, as keyword, params and about; with one session open, only the keywords its driver and platform support |
optics://project-format | how optics stores a suite (CSV layout and ${var}) |
optics://browser-profiles | the Chrome and Edge profiles on this machine (channel, directory, name, email), for capabilities.profile |
optics://session/{session_id}/steps | the session's actions and modules_csv/elements_csv rows to replay them |
optics://session/{session_id}/screenshot | screen as raw PNG bytes |
optics://session/{session_id}/source | page source / UI hierarchy |
optics://session/{session_id}/elements | compact elements without refs; reading it has no side effect |
optics://session/{session_id}/screen_elements | deprecated: captured screen elements |
8. Element sources decide what works¶
The keywords you can use depend on which elements_sources (and detection sources) you enable in start_session — same rules as a normal optics project. When you omit elements_sources, start_session enables the driver's element sources automatically (appium → appium_find_element/appium_page_source/ appium_web/appium_screenshot; ble → camera_screenshot at the frame size when the server has WEBCAM_SCREENSHOT_URL set, else none). When start_session picks the server's camera this way, the session also gets the installed local OCR engine (easyocr, else pytesseract) and templatematch. Pass text_detection or image_detection to choose the engines, or an empty list for none. A camera_screenshot that you name in elements_sources gets the same engines, and the frame size when capabilities.frame has both width and height. With only one of them, the camera keeps its 1080 × 1920 default; a side outside 1 to 8192 stops start_session with a validation error. Pass elements_sources only to narrow or extend the defaults. An explicit empty list is passed through and disables element sources entirely (the session starts without the screen: position and key keywords run, and keywords that must see the screen stop with E0501) — omit the argument for the defaults:
| Capability | Needs |
|---|---|
Locate by xpath / text / id, tap, type | appium_find_element |
| Screenshots & image-based location | appium_screenshot |
Page source, observe, get_interactive_elements, source-based extraction | appium_page_source |
css= / DOM XPath in a mobile browser or debuggable WebView (Android and iOS), and that page's elements in get_interactive_elements | appium_web |
| OCR / locate visible text on screen | a text_detection source (e.g. googlevision) |
| Image template matching | an image_detection source (e.g. templatematch) |
If you enable only appium_find_element + appium_screenshot and then call get_interactive_elements, optics raises E0202: No interactive elements retrieved using available strategies — that's expected; enable appium_page_source (or a vision source) for that path.
When no element source lists elements, as with a camera, the screen rows come from OCR: each row is a text the text_detection engine reads, as e7 Text "Settings" [tap]. OCR cannot tell a button from a label, so every row offers tap, and you type with run_keyword enter_text_using_keyboard after you tap the field. A row keeps its ref while its letters and digits stay the same, so a moving camera frame does not give new refs, and a read that differs only by case or punctuation keeps the row's text. OCR can still split or misread a line between frames; that line then gets a new ref. When two rows hold the same text, a tap on the second one presses that text with index=1, and the steps record it so; other actions refuse such a row. The index follows the order in which easyocr and pytesseract read the screen. A tap on a row is found by OCR, so verified stays unknown; read the check lines.
9. Troubleshooting¶
- First
start_sessionis slow against a remote hub (~30–60 s to allocate and launch). Give your client a generous timeout (thefastmcpPython client takesClient(url, timeout=180)). No module named 'fastmcp'/ "mcp extra required" — installoptics-framework[mcp].- Sessions aren't shared with
optics serve/optics live. Each is a separate process with its own in-memory session store. Alwaysstart_sessionin this server before you use another tool; you cannot attach to a session created elsewhere. A session also ends after the idle lease (OPTICS_MCP_SESSION_IDLE_S). - Device busy / already allocated — if your hub reports the device as busy, free it through your device-orchestration API, then retry
start_session. observe/sourceerrors — usually a missing element source; see §8.- Errors are tool results with
isError: true. The text gives the optics error code, the fact and the next step (see §6, Errors). The full toolset's keyword tools still raise aToolErrorwith the optics code and message. - A tool call timed out, and the next call says the session is busy. The driver call is still running; it cannot be cancelled. Wait, then call
observe. RaiseOPTICS_MCP_CALL_TIMEOUT_Sif your client allows longer calls. start_sessionfailed with "Element source configuration must be set". You passed an explicit emptyelements_sources, or the driver name doesn't match any installed element-source modules (e.g. a typo — check the name against §8). Omitelements_sourcesto get the driver defaults, or name the sources per §8.- Where do suites live? Wherever you write them — the MCP has no workspace of its own. Author the CSV project (see
optics://project-format) at a path you choose and run it withoptics execute. - Setup errors (device unreachable, driver not running). The MCP only talks to the driver server at the
urlyou pass; make sure that server is up and can see the device (for Appium+Android that means its host has the Android SDK — the MCP itself needs none).optics doctoron that host diagnoses the toolchain.
10. How it works (pointer)¶
optics mcp is a thin in-process wrapper over common/expose_api.py. Each session is an AgentSession from common/agent_core.py. It turns a verb into keyword calls, runs them through the same execute_keyword path as the REST server, settles and judges the screen, and records the steps. common/screen_snapshot.py issues the refs, builds the locator ladders and computes the diff and the verdict. The MCP server only renders the replies. See optics_framework/helper/mcp_server.py and the "MCP server journey" section of CLAUDE.md for the internals.