mcp

v0.4.0
@toets/mcp Checked 4 days ago Published 5 days ago

toets MCP server: let AI agents drive TV apps (web, Android TV, tvOS) and search the toets docs with the same primitives tests use.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

launch Launch app

Start (or restart) the app under test on a TV target, like `app.launch()` at the start of a test. Call this first: every other device tool needs a running app. Each launch starts clean: the previous instance is terminated and you are back on the start screen. With the toets SDK enabled it waits for the app to connect. Returns the platform, the SDK status and the focused element; call `snapshot` next to see the screen.

ParameterTypeDescription
clearDatabooleanClear app data/storage before launching.
deepLinkstringStart the app from this deep link instead of its launcher entry (a cold start), e.g. `myapp://details/42`: the app's own canonical link, the same on every platform. The platform's `deepLink` mapper in…
flagsobjectApp feature flags for this launch. Needs `app.state`.
statestringNamed app state to launch into. Needs the `app.state` capability (toets SDK in the app, `sdk` on in the config).
targetstringConfigured target name (see `capabilities`), e.g. a test project name. Default: the current or default target.

capabilities Target capabilities

Describe a TV target: platform, capabilities, which remote keys work (after the configured key overrides), SDK and mocking status, and the configured targets. Check it before pressing anything beyond the D-pad and SELECT, or relying on media or app state. Tests gate on the same capability names with `requires`. Starts the target if needed, without launching the app.

ParameterTypeDescription
targetstringConfigured target name. Default: the current one.

press Press remote keys

Press TV remote keys in order, like a user. This is the only way to interact: there is no click, tap, hover, type or scroll. UP/DOWN/LEFT/RIGHT move focus, SELECT activates the focused element, BACK goes back. Other keys depend on the platform (see `capabilities`); key overrides from the config apply, as in tests. Every key is checked before the first press. Returns where focus landed once it settled, and the matching test code. To reach a known element prefer `press_until_focused` (or `navigate_to`); use `press` for single steps and SELECT. Press a key that changes the screen alone: tvOS drop…

ParameterTypeDescription
keys *arrayKeys to press in order, e.g. ["DOWN", "DOWN", "SELECT"].
holdMsintegerHold each key this long (long press). Needs `key.longpress`.
snapshotbooleanAlso return a text snapshot of the screen after pressing.

press_until_focused Press a direction until an element is focused

Press one D-pad direction until an element (or one of its descendants) is focused, reading focus after every press: exactly `app.focus.pressUntilFocused(key, locator)` from a test. The preferred way to reach an element: the app decides where each press goes, toets only checks. The element may not exist yet (virtualized lists render items as focus approaches). Fails fast with FOCUS_STUCK when a press does not move focus, FOCUS_LOOP when focus comes back to an element it left, FOCUS_UNREACHABLE after maxPresses; the message lists the elements focus passed. Then `press` SELECT to activate the ele…

ParameterTypeDescription
key *stringThe direction to press, e.g. "RIGHT" along a rail, "DOWN" through a menu.
target *objectElement to act on, using the same selectors as tests (test ID and/or text).
maxPressesintegerGive up after this many presses. Default 50.

navigate_to Navigate focus to element

Move focus to an element on screen with real D-pad presses and report the path: exactly `app.focus.navigateTo(locator)` from a test. Each press is aimed by element geometry and checked by reading focus; presses that do not move focus are learned and detoured around. Use it when the way there is not one direction; for one direction prefer `press_until_focused`, which fails faster and clearer. Then `press` SELECT to activate the element. Done when the element or one of its descendants is focused. Fails with the reason when the element is missing (TV lists are virtualized: use `press_until_focuse…

ParameterTypeDescription
target *objectElement to act on, using the same selectors as tests (test ID and/or text).
maxPressesintegerGive up after this many presses. Default 50.

fill Fill a text field

Replace a field's text like a user: focus moves to it with real D-pad presses, then its keyboard enters the text; exactly `locator.fill(text)` from a test. Never submits. The keyboard is a declared app keyboard listing the field in `fields` (opened with SELECT, typed key by key), else system text entry on a system text field (`text.input`). Fails with NO_KEYBOARD otherwise; see `capabilities` for the declared keyboards. Reports the keyboard used and the presses. Then `type`, `erase` or `submit` act on the same keyboard.

ParameterTypeDescription
target *objectElement to act on, using the same selectors as tests (test ID and/or text).
text *string
maskbooleanShow the text as •••• in this output and in step titles (PINs, passwords). Automatic for system password fields.

type Type on the open keyboard

Type text at the end of the field on the keyboard in use: exactly `app.keyboard.type(text)`. The keyboard is the declared app keyboard holding focus, else system text entry on the focused system text field, else the only declared keyboard on screen. On an app keyboard each character is a D-pad walk to its key and SELECT, switching layers with the declared toggles. Fails with NO_KEYBOARD, AMBIGUOUS_KEYBOARD or CHAR_NOT_ON_KEYBOARD (lists the layers seen).

ParameterTypeDescription
text *string
maskbooleanShow the text as •••• in this output and in step titles (PINs, passwords). Automatic for system password fields.

erase Erase characters

Delete characters before the caret with the keyboard's backspace key: exactly `app.keyboard.erase(count)`. App keyboards need a declared `backspace` key (KEYBOARD_ACTION_MISSING otherwise).

ParameterTypeDescription
countintegerCharacters. Default 1.

submit Submit the keyboard

Press the keyboard's submit key: exactly `app.keyboard.submit()`. System keyboards use their action key (Search, Go, Done); app keyboards need a declared `submit` key (KEYBOARD_ACTION_MISSING otherwise).

snapshot Text snapshot of the screen

Read the current screen as a YAML text snapshot, exactly what `app.snapshot()` returns in a test: one line per element in tree order, `testId "text" [states]`, nested by containment. States: focused, selected, busy, disabled, offscreen, editable, secure. System text fields show `value="..."` (masked when secure); a declared app keyboard collapses to one line, `osk [keyboard: search, layer: lower, focused: "m"]`. Use it to see what is on screen and where focus is before deciding what to press. Cheap and deterministic: prefer it over `screenshot`. Wrappers without a test ID, text, focusability o…

ParameterTypeDescription
targetobjectElement to act on, using the same selectors as tests (test ID and/or text).

screenshot Screenshot

PNG screenshot of the screen (`app.screenshot()`), or of one element cropped from it (`locator.screenshot()`). Use only for visual questions (layout, images, colors, how the focus ring looks). To read text, test IDs and focus use `snapshot`.

ParameterTypeDescription
targetobjectElement to act on, using the same selectors as tests (test ID and/or text).

query Find elements

Find elements by test ID and/or text; reports every match with its state and bounds, and the locator a test should use. Use it to check a selector before writing it into a test: a locator used in an action or assertion must match exactly one element. Reports the screen as it is now, without waiting (use `assert` to wait for something).

ParameterTypeDescription
target *objectElement to act on, using the same selectors as tests (test ID and/or text).

assert Assert like a test

Check a condition with the same matcher code `expect` runs in a toets test: it retries until the condition holds or the timeout passes (waiting for app idle first when the SDK has it), and fails with the same message a test would. Locator matchers (need `target`): toBeVisible, toBeInViewport, toBeFocused, toHaveFocusWithin, toBeEnabled, toBeDisabled, toBeSelected, toBeBusy, toHaveText / toContainText (`expected`), toHaveValue (`expected`, system text fields), toHaveCount (`count`). Keyboard: toBeOpen (`app.keyboard`, no target). Screen: toMatchTextSnapshot (`expected` YAML from `snapshot`; `ta…

ParameterTypeDescription
matcher *string
countintegertoHaveCount: expected match count.
expectedstringtoHaveText: full text; toContainText: substring; toHaveValue: value of a system text field; toMatchTextSnapshot: snapshot YAML; toHaveMediaState: a media state (playing, paused, buffering, ...).
notbooleanNegate the matcher, like `expect(x).not.toBeVisible()`.
requestobjecttoHaveRequested: request filter. Default: any request.
secondsnumbertoHavePosition: playback position.
targetobjectElement to act on, using the same selectors as tests (test ID and/or text).
timeoutMsintegerHow long to retry. Default: the target's expect timeout (config, or the test project's `expect.timeout`; 5000).
timesintegertoHaveRequested: exact number of matching requests. Default: at least one.
tolerancenumbertoHavePosition: allowed difference in seconds. Default 1.