Skip to content

feat: add Tauri v2 provider for macOS WebKit testing via MCP#921

Open
coreyepstein wants to merge 3 commits intovercel-labs:mainfrom
coreyepstein:feature/tauri-provider
Open

feat: add Tauri v2 provider for macOS WebKit testing via MCP#921
coreyepstein wants to merge 3 commits intovercel-labs:mainfrom
coreyepstein:feature/tauri-provider

Conversation

@coreyepstein
Copy link

Summary

  • Add --provider tauri option to enable AI-driven testing of Tauri v2 desktop apps on macOS WebKit (WKWebView) — which does not support CDP
  • New TauriBackend implementing the BrowserBackend trait, connecting to a Tauri app's MCP server via HTTP+SSE
  • Follows the existing ios/safari provider pattern: special-cased in handle_launch, backend-specific dispatch in action handlers

How it works

The Tauri app runs tauri-plugin-agent-test which starts an MCP server on localhost:9876. The provider connects via SSE, sends JSON-RPC 2.0 requests, and translates agent-browser commands to MCP tool calls:

agent-browser action MCP tool Notes
snapshot snapshot Returns accessibility-tree-style DOM with @ref identifiers
click click Uses @ref (not CSS selector)
fill fill Uses @ref + value
screenshot screenshot Returns base64 PNG
navigate navigate Invalidates refs after navigation
close close Tears down MCP session

Usage

# Default port 9876
agent-browser --provider tauri

# Custom port
agent-browser --provider tauri --port 3000

# Via env var
AGENT_BROWSER_TAURI_PORT=3000 agent-browser --provider tauri

Files changed

  • cli/src/native/tauri_backend.rs — New file: TauriBackend + SSE transport + BrowserBackend impl + unit tests
  • cli/src/native/actions.rs — Add BackendType::Tauri, launch_tauri(), Tauri dispatch in handle_snapshot/click/fill/screenshot/navigate/close, skip auto-launch when Tauri active
  • cli/src/native/mod.rs — Register tauri_backend module
  • cli/Cargo.toml — Add stream feature to reqwest (already a dep)

Test plan

  • cargo check passes
  • cargo clippy -- -D warnings clean
  • cargo test — 492 passed, 0 failed
  • Tested manually: --provider tauri connects to a Tauri v2 app (indigo-hq-app), snapshot returns 24 interactive elements
  • CI should pass (no new deps, only feature flag addition)

Dependencies

Only addition: stream feature on existing reqwest dep. No new crates.

Add --provider tauri to enable AI-driven testing of Tauri desktop apps
on macOS WebKit (WKWebView) which does not support CDP.

The Tauri provider connects to a tauri-plugin-agent-test MCP server
running inside the Tauri app via HTTP+SSE and translates agent-browser
commands into MCP tool calls.

Supported actions: snapshot, click, fill, screenshot, navigate, close.
Unsupported (CDP/WebDriver-only) actions return clear error messages.

Implementation:
- New TauriBackend struct implementing BrowserBackend trait
- New BackendType::Tauri variant in DaemonState
- Tauri dispatch in handle_snapshot, handle_click, handle_fill,
  handle_screenshot, handle_navigate, handle_close
- Auto-launch skip when Tauri backend is active
- SSE event parser for MCP JSON-RPC 2.0 transport

Usage:
  agent-browser --provider tauri          # connects to localhost:9876
  AGENT_BROWSER_TAURI_PORT=3000 agent-browser --provider tauri

Requires tauri-plugin-agent-test in the Tauri app:
  https://github.com/coreyepstein/tauri-agent-browser

Only new dependency: reqwest "stream" feature (reqwest already a dep).
@vercel
Copy link
Contributor

vercel bot commented Mar 18, 2026

@coreyepstein is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

- Fix snapshot returning raw string instead of parsed JSON tree
  (consumers expect `response.snapshot` to be an object, not a string)
- Split send_rpc mutex into two scopes to eliminate deadlock risk
  (lock for POST URL, release, lock again for SSE read)
- Add type, press, evaluate to TAURI_UNSUPPORTED_ACTIONS
  (prevents confusing "Browser not launched" errors)
P1 fixes:
- Restrict Tauri provider to loopback hosts only (127.0.0.1, localhost,
  ::1) — plaintext MCP transport must not expose page content to remote
- Wire url/title/content commands through Tauri backend so they return
  gracefully instead of crashing with "Browser not launched"

P2 fixes:
- Fix unsupported action list to use actual dispatcher names
  (cookies_get/set/clear, storage_get/set/clear, not cookies/storage)
- Add back/forward/reload/cdp_url/inspect to unsupported list
- Add error_for_status() check on POST — prevents 30s hang on 4xx/5xx
- Expand test coverage for unsupported action name validation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant