mcp
v0.4.0toets 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.
| Parameter | Type | Description |
|---|---|---|
clearData | boolean | Clear app data/storage before launching. |
deepLink | string | Start 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… |
flags | object | App feature flags for this launch. Needs `app.state`. |
state | string | Named app state to launch into. Needs the `app.state` capability (toets SDK in the app, `sdk` on in the config). |
target | string | Configured target name (see `capabilities`), e.g. a test project name. Default: the current or default target. |
open_deep_link Open a deep link in the running app
Deliver a deep link to the running app, as the OS does when a link is opened while the app runs (home screen rows, voice, search): exactly `app.openDeepLink(url)`. The app is not restarted; it routes the link itself. `url` is the app's own canonical link (`myapp://details/42`); the platform's `deepLink` mapper translates it, and the output shows the translation. Needs `deeplink.open` (Android TV, tvOS; browsers have no OS deep links). To start the app from a link, use `launch` with `deepLink`. Fails with DEEPLINK_UNHANDLED when no app handles the link. Assert focus right after: landing with no…
| Parameter | Type | Description |
|---|---|---|
url * | string | Canonical deep link, an absolute URL. |
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.
| Parameter | Type | Description |
|---|---|---|
target | string | Configured 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…
| Parameter | Type | Description |
|---|---|---|
keys * | array | Keys to press in order, e.g. ["DOWN", "DOWN", "SELECT"]. |
holdMs | integer | Hold each key this long (long press). Needs `key.longpress`. |
snapshot | boolean | Also 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…
| Parameter | Type | Description |
|---|---|---|
key * | string | The direction to press, e.g. "RIGHT" along a rail, "DOWN" through a menu. |
target * | object | Element to act on, using the same selectors as tests (test ID and/or text). |
maxPresses | integer | Give 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.
| Parameter | Type | Description |
|---|---|---|
target * | object | Element to act on, using the same selectors as tests (test ID and/or text). |
text * | string | |
mask | boolean | Show 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).
| Parameter | Type | Description |
|---|---|---|
text * | string | |
mask | boolean | Show 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).
| Parameter | Type | Description |
|---|---|---|
count | integer | Characters. 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…
| Parameter | Type | Description |
|---|---|---|
target | object | Element 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`.
| Parameter | Type | Description |
|---|---|---|
target | object | Element 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).
| Parameter | Type | Description |
|---|---|---|
target * | object | Element 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…
| Parameter | Type | Description |
|---|---|---|
matcher * | string | |
count | integer | toHaveCount: expected match count. |
expected | string | toHaveText: full text; toContainText: substring; toHaveValue: value of a system text field; toMatchTextSnapshot: snapshot YAML; toHaveMediaState: a media state (playing, paused, buffering, ...). |
not | boolean | Negate the matcher, like `expect(x).not.toBeVisible()`. |
request | object | toHaveRequested: request filter. Default: any request. |
seconds | number | toHavePosition: playback position. |
target | object | Element to act on, using the same selectors as tests (test ID and/or text). |
timeoutMs | integer | How long to retry. Default: the target's expect timeout (config, or the test project's `expect.timeout`; 5000). |
times | integer | toHaveRequested: exact number of matching requests. Default: at least one. |
tolerance | number | toHavePosition: allowed difference in seconds. Default 1. |
docs_search Search toets docs
Search the toets documentation shipped with the installed @toets packages (test API, locators, matchers, keys, focus, capabilities, config, page objects, platforms, errors). Returns the best matching sections with their file paths. Use it before writing test code you are unsure about, and to look up an error code or hint. Works without a running app.
| Parameter | Type | Description |
|---|---|---|
query * | string | Keywords or an API name, e.g. "navigateTo", "long press", "page objects". |
limit | integer | Max sections. Default 5. |