Tauri Hasgard

v0.8.4
io.github.nyssance/tauri-hasgard Checked 3 days ago Published 10 days ago

Inspect and drive a running Tauri app's native webviews: snapshot, click, type, screenshot.

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

hasgard.assert_checked

Assert that a checkbox or radio target is checked.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.assert_contains

Assert that target text contains a substring.

ParameterTypeDescription
expected *stringExpected value or substring.
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.assert_count

Assert the number of elements matching a selector.

ParameterTypeDescription
expected *integerExpected element count.
selector *stringCSS selector to count.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.assert_hidden

Assert that an element target is hidden.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.assert_text

Assert exact text content for an element target.

ParameterTypeDescription
expected *stringExpected value or substring.
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.assert_url

Assert that the current URL contains a substring.

ParameterTypeDescription
expected *stringExpected value or substring.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.assert_value

Assert an input, textarea, or select value.

ParameterTypeDescription
expected *stringExpected value or substring.
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.assert_visible

Assert that an element target is visible.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.attrs

Get all HTML attributes for an element target.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.blur

Remove keyboard focus from an element target.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.bounding_box

Get an element's position and size in viewport pixels.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.check

Set a checkbox or radio element. Pass `checked` to drive it to a state (idempotent); omit it to toggle.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
checkedbooleanDrive the box to this state instead of toggling. Idempotent, so a retry cannot invert it.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.checked

Report whether a checkbox or radio is checked.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.clear

Empty an input, firing the same events as fill.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.click

Click an element target by ref, selector, or coordinates, with optional modifiers, button, click count, and in-element position.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
buttonstringWhich button. right raises contextmenu and middle raises auxclick; neither raises click.
clickCountintegerPresses in one gesture. 2 also raises a single dblclick.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
modifiersarrayModifiers held for the whole gesture. Meta is Command on macOS.
positionobjectOffset from the element's top-left corner. Defaults to its centre.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.clipboard

Read or write the system clipboard's text, to check a copy action or prepare a paste. The clipboard is shared with the user of the machine.

ParameterTypeDescription
action *stringread returns the text, or null when there is none; write replaces it.
textstringText to place on the clipboard, for write.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.cookies

Read, set or delete cookies in the webview's own store, HttpOnly cookies included. Use it to start signed in or to assert on a session cookie.

ParameterTypeDescription
action *stringget lists, set writes one cookie, clear deletes.
domainstringCookie domain: for set when no url is given, a filter for clear.
expiresintegerExpiry for set, in seconds since the Unix epoch. A session cookie when omitted.
http_onlybooleanHide the cookie from page script, for set.
namestringCookie name: required for set, a filter for get and clear.
pathstringCookie path for set. Defaults to /.
same_sitestringSameSite policy for set.
securebooleanSend only over https, for set. Defaults to true for an https url.
urlstringFor set, supplies the domain, the path / and secure for https. For get and clear, limits to the cookies a request to this URL would carry.
valuestringCookie value, for set.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.count

Count the elements a CSS selector matches.

ParameterTypeDescription
selector *stringCSS selector to count matches of.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.dblclick

Double-click an element target by ref, selector, or coordinates.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.dialog

Inspect or set how modal dialogs (alert/confirm/prompt) are answered. The policy is standing, not per-dialog, and defaults to dismiss.

ParameterTypeDescription
action *stringOne of: accept, dismiss, list, clear.
prompt_textstringText submitted to a prompt when action is accept.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.diff

Compare the current webview to the previous or supplied snapshot.

ParameterTypeDescription
depthintegerMaximum traversal depth.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
interactivebooleanOnly include interactive elements.
referenceOptional prior snapshot object to compare against.
selectorstringCSS selector to scope the new snapshot.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.disabled

Report whether an element is disabled, by property or aria-disabled.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.downloads

The files a webview downloads. wait answers with a finished download no earlier wait answered with, and the path it was saved to; it may be called after the action that downloads. One nobody waited for answers the next wait: clear first to start fresh. On CEF call set_directory first. Available where the application passes Hasgard's observer to its download hook.

ParameterTypeDescription
action *stringWhat to do.
pathstringFor set_directory: an absolute directory for later downloads. Omit to reset.
since_idintegerFor wait: only a download started after this id.
timeoutintegerFor wait: how long, in milliseconds. Defaults to 10000.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.drag

Drag an element to another target or by an offset.

ParameterTypeDescription
source *stringSource element ref, selector, or coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
offsetOptional offset object such as {"x": 0, "y": 100}.
targetstringDestination element ref, selector, or coordinates.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.event

Tauri events. emit delivers one to the application, as its backend would; listen starts recording an event the application emits, and list shows what was recorded.

ParameterTypeDescription
action *stringWhat to do.
eventstringEvent name. Required for emit, listen and unlisten; a filter for list.
payloadFor emit: the payload, any JSON value.
since_idintegerFor list: only events recorded after this id.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.fill

Clear and fill an input target with a value.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
value *stringValue to set.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.focus

Give keyboard focus to an element target.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.forms

Dump all form fields in the webview document or inside a selector.

ParameterTypeDescription
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
selectorstringOptional CSS selector.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.heap_snapshot

Write a JavaScript heap snapshot of the target webview after a full GC: JavaScriptCore inspector JSON on macOS, V8 .heapsnapshot on Windows.

ParameterTypeDescription
output_path *stringAbsolute output path; its directory must exist. Replaced if present.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.hover

Move the pointer over an element target.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.html

Get inner HTML for an element target, or the full webview document if target is omitted.

ParameterTypeDescription
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
targetstringOptional element ref, CSS selector, or x,y coordinates.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.logs

Read or clear captured console logs.

ParameterTypeDescription
clearbooleanClear the log buffer instead of reading it.
lastintegerReturn only the last N log entries.
levelstringOptional log level filter.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.native_dialog

Answer the dialog plugin's native open, save and message dialogs in advance, since nothing can click an operating-system dialog. Set the policy before the action that opens one. The default, manual, leaves them on screen.

ParameterTypeDescription
action *stringaccept and dismiss answer every later native dialog; manual stops answering; list shows what was answered; clear forgets the record.
buttonstringFor accept: the message dialog button to press, by its label.
pathsarrayFor accept: what an open or save dialog returns. Several for an open dialog that allows them.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.navigate

Navigate the WebView to a URL.

ParameterTypeDescription
url *stringURL to navigate to.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.network

Read or clear captured network requests.

ParameterTypeDescription
clearbooleanClear the request buffer instead of reading it.
failedbooleanOnly return failed requests.
filterstringOptional URL substring filter.
lastintegerReturn only the last N requests.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.ping

Check connectivity with the running Tauri app.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.press

Press a keyboard key.

ParameterTypeDescription
key *stringNative keyboard key to press; respects the active input method.
completionstringwebview waits for trusted keyup (default); native confirms OS posting only for native shortcuts or navigation.
timeoutintegerPostcondition timeout in milliseconds; requires wait_for.
wait_forstringJavaScript postcondition to await before another native press may focus a window.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.query

Find elements by text, label, placeholder, test id, alt, or title. Matches against the live DOM, so each naming source is searchable independently rather than through the single collapsed `name` a snapshot reports.

ParameterTypeDescription
by *stringDimension to match: text, label, placeholder, testid, alt, title, or role. role reports what a snapshot would for that role without resetting snapshot refs.
value *stringValue to match against the chosen dimension; the role itself for by: role.
exactbooleanRequire a full, case-sensitive match. Test ids are always exact regardless.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
namestringWith by: role, keep elements whose accessible name contains this text (case-sensitive), or equals it with exact.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.record_start

Start recording app interactions.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.record_status

Get recorder status.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.record_stop

Stop recording and return recorded entries.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.replay

Replay or export a recorded tauri-hasgard session file.

ParameterTypeDescription
path *stringPath to a recording JSON file.
exportstringExport format instead of replaying.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.route

Shape what the page's own fetch and XHR requests receive, without a real backend. Rules match a URL glob in registration order, first match wins.

ParameterTypeDescription
action *stringWhat to do.
bodystringResponse body for fulfill.
content_typestringResponse content type for fulfill. Defaults to text/plain.
methodstringRestrict to one HTTP verb. Any verb matches when omitted.
patternstringURL glob, required for fulfill and abort. `*` stays inside one path segment, `**` crosses separators, and the pattern must match the whole URL.
statusintegerHTTP status for fulfill. Defaults to 200.
timesintegerStop matching after this many requests, letting later ones through.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.run_scenario

Run TOML scenario steps against this application; failures are tool errors. No [connect] overrides.

ParameterTypeDescription
toml *stringTOML scenario with one or more [[step]] entries.
fail_fastbooleanOverride scenario fail_fast.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.screenshot

Capture the full webview document or an element selector. Returns the PNG as image content.

ParameterTypeDescription
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
selectorstringOptional CSS selector.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.screenshot_native

Write a PNG of rendered pixels to `output_path`: the routed webview via WebKit when `window_id` is omitted, or the on-screen window with that id. Returns path + metadata; never inlines bytes.

ParameterTypeDescription
output_path *stringAbsolute path where the PNG is written. The parent directory must already exist; the file is written atomically via a temp + rename.
formatstringImage format. v1 accepts only "png".
windowstringOptional Tauri window label overriding the MCP server default.
window_idintegerNative window id (e.g. `CGWindowID` on macOS) to capture a whole window. Omit to render the routed webview through WebKit (exact pixels, scrolled content included, no screen-recording permission). Mus…

hasgard.scroll

Scroll the webview document or an element ref.

ParameterTypeDescription
amountnumberPixels to scroll. 300 when omitted.
directionstringDirection to scroll.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
refstringOptional element ref, with or without @.
targetstringScroll this element instead of the document: ref, CSS selector, or x,y.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.select

Select an option in a select element, or a set of options in a multiple one.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
valuestringThe option to select, by its value or visible label.
valuesarrayFor a multiple select: exactly this set becomes selected. Use instead of value.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.set_input_files

Attach local files to an <input type="file">. An empty list clears the selection.

ParameterTypeDescription
files *arrayLocal file paths to attach. Empty clears the selection.
target *stringThe <input type="file"> ref, selector, or coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.snapshot

Capture an accessibility snapshot of the WebView.

ParameterTypeDescription
depthintegerMaximum traversal depth.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
interactivebooleanOnly include interactive elements.
selectorstringCSS selector to scope the snapshot.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.state

Get webview URL, title, viewport, and scroll state.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.storage_clear

Clear localStorage or sessionStorage.

ParameterTypeDescription
sessionbooleanUse sessionStorage instead of localStorage.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.storage_get

Read a localStorage or sessionStorage key.

ParameterTypeDescription
key *stringStorage key.
sessionbooleanUse sessionStorage instead of localStorage.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.storage_list

List localStorage or sessionStorage entries.

ParameterTypeDescription
sessionbooleanUse sessionStorage instead of localStorage.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.storage_set

Set a localStorage or sessionStorage key.

ParameterTypeDescription
key *stringStorage key.
value *stringStorage value.
sessionbooleanUse sessionStorage instead of localStorage.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.text

Get text content for an element target.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.title

Get the current webview title.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.type

Type text into an element target without clearing it first.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
text *stringText to type.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.url

Get the current webview URL.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.value

Get an input, textarea, or select value.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.video_start

Start bounded native window MP4 recording on macOS; requires ffmpeg and Screen Recording permission.

ParameterTypeDescription
output_path *stringAbsolute .mp4 output path; must not exist.
fpsinteger
max_duration_msinteger
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.video_status

Read native video session status.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.video_stop

Stop recording and return the published MP4; propagates capture/encoder failures.

ParameterTypeDescription
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.visible

Report whether an element is visible. Unlike assert_visible, a hidden element is an answer, not a failure.

ParameterTypeDescription
target *stringElement ref, CSS selector, or x,y coordinates.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.wait

Wait for an element or condition.

ParameterTypeDescription
expressionstringJavaScript expression to poll until it returns a truthy value, which is then returned. Catches conditions that flip without a DOM mutation. Cannot be combined with selector or gone.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
gonebooleanWait for the element to disappear.
loadstringWait for a load state: load or domcontentloaded. Combines with url.
pollintegerHow often to re-evaluate `expression`, in milliseconds.
selectorstringCSS selector to wait for.
targetstringElement ref, CSS selector, or x,y coordinates.
timeoutintegerTimeout in milliseconds.
urlstringWait until the window is at this URL instead of waiting for an element. A glob: `*` stays within a path segment, `**` crosses them. Holds across the navigation that gets there.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.watch

Watch for DOM mutations until the webview document is stable.

ParameterTypeDescription
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
require_mutationbooleanDefer the stability timer until at least one DOM mutation occurs. Rejects on timeout when nothing changed.
selectorstringCSS selector to scope observation.
stableintegerStability window in milliseconds.
timeoutintegerTimeout in milliseconds.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.wheel

Scroll by wheel, letting the page cancel it as a real wheel would. Omit target to scroll the page.

ParameterTypeDescription
delta_xnumberHorizontal scroll delta in pixels.
delta_ynumberVertical scroll delta in pixels.
framearrayScope to a same-origin iframe: one CSS selector per nesting level, outermost first. Cross-origin frames are unreachable.
targetstringScrollport ref or selector. Omit to scroll the page.
windowstringOptional Tauri window label overriding the MCP server default.

hasgard.window

Read or change the native window: state, resize, move, minimize, maximize, restore, close. Sizes and positions are logical pixels.

ParameterTypeDescription
action *stringstate reports position, size and flags; the others change the window and report its state.
heightnumberContent height for resize.
widthnumberContent width for resize.
windowstringOptional Tauri window label overriding the MCP server default.
xnumberLeft edge for move, from the screen origin.
ynumberTop edge for move, from the screen origin.

hasgard.windows

List all open Tauri windows.