MCP server
fleetest-mcp is a stdio MCP server that exposes device
operations, scenario execution and scenario authoring as ft_* tools for AI assistants.
It is the same functionality as the CLI and VSCode extension, called by an agent instead of a
human.
Setup
The fleetest server is registered during installation (install.sh / /fleetest-setup).
For Claude Code it is written into your work folder's .mcp.json with the clone's absolute path,
so it starts the same way wherever you open the agent (the first call triggers a build). To add
just the MCP server to a different project — without the VSCode extension or project scaffolding —
see Claude Code skills (/fleetest-mcp).
Any other agent works too (Codex, Cline, …). fleetest-mcp is a plain stdio MCP server, so
any MCP-capable client can register it. Follow that client's own configuration format and give it
this launch command (<ABS_TOOL_ROOT> is the absolute path of the clone; the TOML form and how to
hand over the runbooks are in AI assistants other than Claude Code):
"fleetest": {
"command": "bash",
"args": ["-c", "exec \"<ABS_TOOL_ROOT>/Scripts/mcp-server.sh\""],
"env": { "FT_TOOL_ROOT": "<ABS_TOOL_ROOT>" }
}
bash -c is enough: mcp-server.sh itself prepends /opt/homebrew/bin:/usr/local/bin to PATH, so the
server finds the Swift/Xcode toolchain even when the client starts it with a minimal PATH. Do not use
-l (a login shell): any echo in ~/.bash_profile lands on stdout and breaks the JSON-RPC handshake. FT_TOOL_ROOT points at the bridge assets, which is a
different location from the working directory (your test package).
Common arguments
Every device tool accepts the same targeting arguments:
| Argument | Meaning |
|---|---|
platform |
ios (default) or android |
project |
Test project name |
profile |
Run profile name (profiles/runs/<name>) — drives the same device as ft_run_scenario (iOS is always XCUITest) |
udid |
iOS device UDID — Simulator or physical (from ft_list_devices) |
serial |
Android device serial |
port |
iOS bridge port (normally leave it out and pass udid; with neither, a session that has not named a device uses the running bridge) |
allowVersionSkew |
Operate even when the bridge's protocol version does not match the tool's (default off = refused). Pass it on every call that should go through: a later call without it is re-checked against the bridge and refused while the mismatch remains; each response that goes through carries a warning. On Android it also lets you use a newer bridge already on the device as-is (no install or uninstall) |
Once a call names a device explicitly (udid / port / serial, or profile), the server remembers it for later calls
that omit all of these; naming a second device (including through profile) requires future calls to be explicit again.
Tools
| Tool | Description |
|---|---|
ft_status |
Connection check — reports the target device and whether the app session is still in the foreground. On Android with several devices connected and serial omitted, it lists all of them instead of failing |
ft_doctor |
Foundation Models (FM), Vision and OCR availability — only with fmAndVision: true (MCP does not use them by default, so it does not touch them otherwise); when FM is unavailable, lists which features are disabled (screenLooksLike, text visibility check). Self-healing does not use FM and is unaffected |
ft_launch / ft_terminate |
Launch or terminate the app |
ft_install |
Install the app from a package file (.app on iOS, .apk or a split .apks bundle on Android) |
ft_snapshot |
Element list snapshot (compressed, set-of-mark style); waitFor waits for a selector to appear. Warns at the top when the target app is not in the foreground. Elements stranded outside a scroll container (ghosts) are named with ⚠️scroll-leftover (a different thing may be drawn at their coordinates). Scroll containers carry a scroll mark (usable as scrollFrame:), but no mark does not mean it does not scroll (Compose / Flutter in-app trees are self-drawn and cannot declare it). A swarm of same-id elements (map POIs and the like: 20 or more non-interactive leaves) is folded into one line (expandBulk: true unfolds it; folded elements can still be hit by selector or ref). When the element cap drops elements, the top says how many (dropped elements are found by neither waitFor nor ft_scroll_to, and scrolling never brings them back; raise the cap with maxElements and read again). interactiveOnly: true hides layout-only lines (refs and frames unchanged; hidden lines can still be hit by selector or ref). When one label or id matches several elements, a selector you can write instead is shown per match (for items only an index could name, a relative form anchored on text in the same row is shown). The #ids in every tree an ft_* tool returns (this one, an action's snapshotAfter, ft_scroll_to, ft_batch, …) accumulate in <project>/.fleetest/selector-inventory.json, which ft_dry_run uses to check for typos |
ft_tap / ft_type / ft_swipe / ft_long_press |
Screen operations — tap, type (pressEnter: true sends Enter/IME after typing; ft_type with replace: true replaces the text, with a read-back, cheaper than the two steps ft_clear_input + ft_type), swipe, long press. Prefer selector (the same syntax and resolution as a scenario line, matched on a fresh tree). It is taken by ft_tap, ft_type, ft_long_press, ft_double_tap and ft_clear_input; ft_swipe does not take it (its container is scrollFrame). It survives redraws that make refs stale, and the step becomes a scenario line as written. It is exclusive with ref and x/y; with no match the call is refused and nothing is sent (an alert in front of the app is named), and several matches act on the one a scenario line would pick (the reply says so; on iOS it is counted in the XCUITest tree, so an unscoped [n] or the first of several matches can be a different element in a scenario run in the default inapp-boost mode). A ref is re-checked against a fresh tree just before the action (moved: retargeted to its current position; gone: refused with the reason; a scroll leftover is hit with a warning). An operation by ref returns the selector that reproduces it (tap [40] done (selector: #btn_add); a ref is a session-only number that cannot go into a scenario; with no stable selector it says so). Operation tools take snapshotAfter: true to return the resulting element list too (pass waitFor as well to wait until the selector you want appears; use waitForChange: true for a screen that refreshes in place). ft_tap takes linkText to press a link inside a paragraph, like tap(selector, linkText:) in a scenario (text that is not its own element in the tree is found by OCR, only with fmAndVision: true). The hold time of a long press is holdSeconds |
ft_scroll_to |
Scroll a container until a selector appears, then return the refreshed element list. scrollFrame: takes the selector of a container marked scroll, or the ref of any element (its frame becomes the swipe area — for Compose chip rows and carousels) |
ft_batch |
Run several operation/scroll steps in one call under a single approval |
ft_rotate |
Rotate the device and return the element list in the new orientation. Refs from before the rotation no longer resolve. Unlike the scenario rotateTo(), it does not restore the orientation at the end, so rotate back yourself before handing over |
ft_fold |
Fold / unfold a foldable device (state "fold" / "unfold", or hinge degrees) |
ft_navigate |
Back / Home / app switcher |
ft_hide_keyboard |
Close the soft keyboard (Android sends back; iOS taps an empty spot above the keyboard and fails if that does not close it — it never sends Return) |
ft_open_url |
Deliver a deep link without restarting the app (ft_launch, by contrast, always restarts it). Delivery is asynchronous, so snapshotAfter: true waits for the screen to change before reading (waitFor for something only the destination has, waitForChange: false to read at once) |
ft_clear_input |
Clear a text field, named by selector or ref (default: the focused one) (ft_type appends, so clear first to replace) |
ft_clear_app_data |
Reset app data and permissions (on a physical iOS device it falls back to uninstall + install, using the path from ft_install or packagePath:). Apple apps (com.apple.*) are wiped on an iOS Simulator only (the data container and its app group containers; the reply lists what was and was not wiped); it is refused on a physical iPhone, for SpringBoard, and when the target cannot be confirmed as a Simulator (pass udid) |
ft_dsl_commands |
DSL command index (names and signatures), for checking a command exists before writing it |
ft_double_tap / ft_pinch / ft_drag |
Double tap (by selector, ref or x/y), pinch, and arbitrary-direction drag. MCP always drives iOS through XCUITest, so a double tap on a Compose iOS app does not take effect from MCP (it does in a scenario run in inapp-boost mode). Use ft_pinch when the goal is zooming in (gestures). ft_drag can also be written with fromRef (from the element's centre) and dx/dy (travel), e.g. to expand a half-open bottom sheet by pulling its grabber up. ft_pinch targets a ref or x/y (a map is not an element in the tree; with no target the fingers spread over the whole screen and a sheet in front may be grabbed instead) |
ft_gesture |
Replay several fingers' timed paths as one continuous touch sequence (fingers never lift between segments) — for a pattern-lock swipe, a long-press that then drags, or a custom multi-finger gesture; absolute coordinates only, no ref/selector form |
ft_screenshot |
Screenshot image, for visual inspection |
ft_capture_element |
Saves an element as a sample image of an image classifier and reports the training check (samples for checkIsON / imageIs; see imageIs). With variant (the name of a variant the run profile declares; needs profile and selector, ref is refused; appearance and text size only) it puts the device in that variant's display settings, waits for the screen to settle, finds the element again by selector, saves the crop as <date>-variant-<name>.png, and returns the device to its starting values and reads them back (a failure to return is reported in the response). It cannot be used for a variant that has an orientation (a top-level orientation in the profile is inherited by every variant, so then it cannot be used), and it cannot be combined with name. When nothing was saved (the screen does not settle, the element is not found, and so on) the response gives the reason. Use it only to add an image for a variant that has none yet |
ft_list_scenarios / ft_run_scenario |
List scenarios / run deterministically (auto-builds; compile errors are returned as-is). With a profile that declares variants, variant takes one name; omitted, it runs once under the first declared variant and the response says so (refused for a profile without variants). A class name as id runs every scenario of the class except @Deleted/@Draft, like fleetest run. profile: cannot be combined with port/serial/platform/udid. Unlike fleetest run it does not run the profile's setup/teardown scripts, send the device home first, or record into results/, and on iOS it always runs through the XCUITest bridge (fleetest run uses the profile's mode, inapp-boost by default), so a step whose result depends on the mode, such as a double tap in a Compose Multiplatform app, can differ; the response says so (use the CLI for a full run). It installs the app only on iOS with a profile: whose app has autoInstall (copied into the workspace, then installed when the installed copy is out of date); otherwise install it with ft_install. A failure comes back as isError with the failing step, the element list and screenshot at the moment of failure (first failed scenario only), and the report path. By default it runs without Foundation Models and Vision (no text visibility check, screenLooksLike steps skipped, checkIsON reads the tree only); pass fmAndVision: true to use them. heal overrides fingerprint matching (default: the profile's value, otherwise false). It does not start the services of scripts/compose.yaml (bring them up first with ft_services) |
ft_start_run / ft_run_status / ft_stop_run |
The real run, same as fleetest run --profile. ft_start_run starts it in the background and returns at once (profile required; scenario / folder are arrays (scenario also takes Class.method@variant for one variant unit); variant is an array of variant names; failed, broadcast, and runner to send this run to another machine — a registered machine name or local); ft_run_status returns progress and the result (runID, pass/fail, reports of failed scenarios, the tail of the log). Stop it with ft_stop_run (SIGTERM). Includes result history (results/), recordings and the setup/teardown scripts. It runs inside the MCP server, so agents whose shell is sandboxed (such as Codex by default) can use it too. One run at a time per server. If another run is already running on this Mac, the run exits at once by default (a Mac runs one run at a time) — pass waitLockSeconds (how long to wait, in seconds; the same as fleetest run --wait-lock) to queue behind it. ft_stop_run also stops a run that is still waiting. Like ft_run_scenario, it runs without Foundation Models and Vision unless fmAndVision: true (it turns the four profile switches off with --set) |
ft_services |
Starts, stops and inspects the services that scripts/compose.yaml declares, for exploring and Live Control (the same as fleetest services up / down / status). action: up / down / status; profile (can be omitted when every run profile uses the same workspace); project; physical; androidSerials (an array of strings). Asks for approval like ft_start_run (see below). Details: Services the app depends on |
ft_results |
The run-results history, same text as fleetest results <query> (no JSON). query is required: list, summary, flaky, trend (needs scenario), devices, slow, insights or log (a run's per-scenario execution log; runId, default latest). Optional: since (default 90d; not for log), scenario, limit (list / slow), minRuns (flaky). Reads files only, so it works for agents whose shell is sandboxed (such as Codex by default) |
ft_dry_run |
Device-free validation: fails (isError) on selector syntax errors; flags assertion-less expectations and unknown #ids as ⚠️ lines (warnings, not failures). For a scenario that declares no platform, platform: (default ios) picks the ios { } / android { } branch and the #id ledger |
ft_list_projects |
List test projects and their run profiles |
ft_draft_scenario |
Turn a recorded exploration into a Swift scenario draft (not written to disk). Steps taken by selector are written with the selector you passed; steps taken by ref or x/y use the selector MCP recommended. Steps that could not be resolved stay as TODO comments. Expectations come out as empty skeletons (ft_dry_run makes you fill in the assertions). The reply numbers the steps it used, so drop detours with drop: [n, ...] or lastN: k before adopting it (the range is since the last ft_launch; all: true for everything). scenes: [9, 13] splits it into scenes, and className: / title: set the @TestClass name and the @Test title |
ft_list_devices / ft_list_apps / ft_logs |
Device / app / log inventory. ft_list_devices's profile: narrows the list to that run profile's devices; devices that live on another machine are named but not listed. ft_list_apps lists user apps only by default, so preinstalled (system) apps such as Maps or a browser do not appear; pass filter: (substring of id or display name) to search system apps too, or includeSystem: true to list all with [system] marks. Display names appear on iOS only. An iOS device with no bridge is marked "no bridge" and cannot be driven from MCP |
ft_release_device |
Lets go of a device you are done driving. While an MCP session has driven a device, fleetest bridge down (and other stops) refuse to stop it until the session ends or you pass --force; this drops that hold and the session's memory of the device (snapshots, refs, launched app, default target — afterwards a call naming no target goes to another device this session still remembers, or is refused if none is left; a session that never named a target falls back to the running bridge as usual). It does not stop the bridge, the app or the device, and works even after the bridge is gone. Only this session's own hold is removed; if another session holds the device, the reply says so. Any later call that reaches the device takes the hold again. Takes the usual device target (udid / serial / port / profile) |
Physical devices
Screen-operation tools work the same way on a physical iPhone or Android device. Simulator/
Emulator-only operations are routed automatically: ft_install uses devicectl instead of
simctl on a physical iOS device, and ft_clear_app_data wipes the data by uninstall + install
(using the path from the last ft_install, or packagePath:) on a physical iOS device (Android's
pm clear still works on a physical device). Apple apps (com.apple.*) are never wiped on a physical iPhone. An iOS system alert (a location permission prompt, for
example) can be answered in one call with ft_tap alertButton: "Don't Allow" — it presses that button and
returns to the app (the alert note lists the button names). Passed together with an ft_tap selector, or on
ft_type / ft_batch, alertButton presses the alert first and then does the rest of the call. While a system alert is up, the app's element
list is left out of every tree response (nothing in it can be reached); an alert drawn by the app itself is
returned on its own, without the screen behind it. After dismissing a system alert on SpringBoard,
ft_launch bundleId: <app> resume: true returns to the app without terminating it.
iOS mode selection
MCP always drives iOS through the XCUITest bridge. You never need to choose a mode. Name the device with
udid and leave port out — the server uses that device's XCUITest bridge.
- Passing
profilestill drives iOS through XCUITest (the profile'siosModeis not used by MCP); the profile still decides which device is used. - If you connect to an in-app bridge's port, the server switches to the XCUITest bridge of the same device. When no XCUITest bridge can be prepared, it reports an error instead of falling back to in-app.
- Other apps (Maps, for example), SpringBoard and system alerts can be driven as they are.
Differences when copying into a scenario
When you copy an operation you confirmed with ft_* into a scenario (DSL), adjust it for these differences.
| MCP | DSL | How to copy it |
|---|---|---|
ft_tap has no scroll: |
tap("#id", scroll: .down) |
While exploring, bring it into view with ft_scroll_to, then ft_tap. In the scenario, write the single line tap(..., scroll:) |
ft_type with pressEnter: true |
type has no Enter argument |
Put pressEnter() on the line after type("#id", "text") |
| A target under the keyboard | A target under the keyboard | Both close the keyboard without sending Enter and then press it (MCP refuses if it cannot close it) |
Installing the app automatically (autoInstall) |
As the run profile says | In MCP only an iOS profile's autoInstall takes effect. On Android install it with ft_install. When the installed app differs from appPath, it is not reinstalled (that would lose the screen being explored); the first response for the profile carries a note instead. To explore the current build, use ft_install |
waitFor / waitForChange and waitSeconds |
Each command's waitSeconds: |
In MCP waitSeconds only bounds the waitFor / waitForChange wait and does nothing on its own. On an action tool, pass waitFor together with snapshotAfter: true. In the scenario, write waitSeconds: on the command that waits |
waitFor also matches at once an element that already had the same text before the action (so it did not wait for the
action's result). The response says so in a note; wait for the new value itself, or use waitForChange: true.
Role split
The tools intentionally do not include an "explore" tool: exploration and judgment stay with the
calling agent (it already has a snapshot and operation primitives to explore with), while
fleetest supplies determinism — operate, replay, verify.
Sandbox and approval
The MCP server runs outside the agent's shell sandbox. Tools that build and run
(ft_list_scenarios, ft_dry_run, ft_run_scenario, ft_start_run) execute the project's scenarios (.swift)
as arbitrary Swift code (a dry-run executes them too), and ft_services starts the containers the project declares
in scripts/compose.yaml.
-
Scenarios always run inside fleetest's sandbox (macOS Seatbelt), whether they are started from MCP, the CLI or the extension. Where a scenario can write, what it cannot read, where it can connect, and the settings for all of this (
sandboxin this Mac's~/.config/fleetest/config.json) are in Sandbox defaults. What the sandbox does not stop (services on localhost, other devices' bridges and so on) is in Notes and limitations. -
Choose what to approve by what runs outside the sandbox.
Tools that ask for approval Convenience What goes past a human none never interrupted nothing (assumes a repository and app you trust) ft_start_run,ft_services(recommended)once, when you ask for a test run or to start the services starting and stopping services, setup / teardown scripts, sending a run to another machine ft_list_scenarios,ft_dry_run,ft_run_scenario,ft_start_run,ft_servicesasked at every compile and check while writing scenarios every scenario execution For Claude Code, the installer writes "allow the fleetest tools (
mcp__fleetest), ask only beforeft_start_runandft_services(ask)" into the work folder's.claude/settings.json(the recommended shape; remove it fromaskif you do not want the prompt, and later updates will not put it back). It also makes the fleetest clone read-only (reading is allowed, editing is denied); this is skipped when the work folder is inside the clone. In Auto mode, the AI decides on its own whether to ask, but it judges the tool call, not the contents of the scenarios. For Codex, see AI assistants other than Claude Code (default_tools_approval_modefor the whole server,approval_modeunder[mcp_servers.fleetest.tools.<tool name>]per tool).writes, which skips approval only for read-only tools, also counts screen operations (taps, typing) as writes, so exploring a screen means dozens of approvals. -
Each tool declares what it does through MCP annotations. Clients that decide approval from them treat the tools accordingly.
Declared as Tools Read-only ( readOnlyHint: true)ft_status,ft_list_devices,ft_list_apps,ft_list_projects,ft_snapshot,ft_screenshot,ft_logs,ft_results,ft_run_status,ft_dsl_commands,ft_doctor,ft_draft_scenarioChanges the device's screen or the app's state taps, typing, swipes and other operations, ft_launch,ft_terminate,ft_open_url,ft_batch,ft_capture_element(writes a sample into the project)Changes only this session's own hold and memory ( readOnlyHint: false,destructiveHint: false)ft_release_deviceCannot be undone ( destructiveHint: true)ft_clear_app_data,ft_install,ft_stop_runRuns the project's code ( destructiveHint: true,openWorldHint: true)ft_list_scenarios,ft_dry_run,ft_run_scenario,ft_start_run,ft_services -
Check the contents of scenarios you receive from others before running them. The sandbox protects this Mac, but it does not stop what Notes and limitations lists, nor operations on the app under test or its accounts (deleting, purchasing and so on).
-
ft_start_run'srunneraccepts only registered machine names andlocal. Raw destinations such asuser@hostare refused, so scenarios and profiles are never sent to a machine the user has not registered. Register machines withfleetest remote machines add. The CLI'sfleetest run --runneraccepts raw destinations too. -
ft_stop_run/ft_run_statusonly handle runs that this server started withft_start_run. -
ft_start_runpasses checked arguments as an array to a fixed command (fleetest run); no shell is involved, so no arbitrary command can be injected through the arguments. Values ofprofile,runner,scenarioandfolderthat start with-are refused (fleetest runwould read them as options, which could get around therunnerrestriction above). -
ft_servicesworks the same way: it passes checked arguments as an array to a fixed command (fleetest services), and values ofprofile,projectandandroidSerialsthat start with-are refused.
Structured output (opt-in)
Set FT_MCP_STRUCTURED_CONTENT=1 in the server's environment (the env of its MCP entry) to have
ft_run_scenario, ft_dry_run and ft_list_scenarios also return structuredContent — a JSON
summary (per-scenario pass/fail and report path, or the scenario list). It is only sent when the
client negotiated MCP 2025-06-18 or later. Leave it off for Claude Code: Claude Code shows the
model only structuredContent when it is present, so the text notes and the failure screenshot would
no longer reach it.