tauri-mcp-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTauri MCP CLI
Tauri MCP CLI
Use this skill for the entire CLI workflow. The package intentionally ships a single bundled skill so agents do not need to pick between overlapping domain-specific skills.
使用该技能完成完整的CLI工作流。本包特意提供了一个捆绑的单一技能,因此Agent无需在重叠的领域特定技能中进行选择。
Prerequisites
前提条件
- The app is running in development mode, usually with .
cargo tauri dev - The plugin is installed and registered.
tauri-plugin-mcp-bridge - sets
src-tauri/tauri.conf.json.withGlobalTauri: true
- 应用处于开发模式运行,通常使用命令。
cargo tauri dev - 已安装并注册插件。
tauri-plugin-mcp-bridge - 中设置
src-tauri/tauri.conf.json。withGlobalTauri: true
Core Rule
核心规则
Start or verify a driver session before calling almost any other tool:
bash
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session status --jsondriver-session startconnected: true在调用几乎所有其他工具之前,先启动或验证驱动会话:
bash
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session status --json即使无法连接到应用,也可能执行成功,因此务必检查状态输出中的。
driver-session startconnected: trueSession and Daemon Lifecycle
会话与守护进程生命周期
bash
undefinedbash
undefinedStart a session
启动会话
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session start --port 9223
Run one or more commands in separate shell invocations
在单独的Shell调用中运行一个或多个命令
tauri-mcp webview-screenshot --file before.png
tauri-mcp webview-interact --action click --selector "#submit-btn"
tauri-mcp webview-screenshot --file after.png
tauri-mcp webview-screenshot --file before.png
tauri-mcp webview-interact --action click --selector "#submit-btn"
tauri-mcp webview-screenshot --file after.png
End the session
结束会话
tauri-mcp driver-session stop
The CLI uses MCPorter keep-alive mode, so the background daemon preserves session state across separate `tauri-mcp ...` commands.
Use daemon commands only when the background process itself is unhealthy:
```bash
tauri-mcp daemon status
tauri-mcp daemon restart
tauri-mcp driver-session start --port 9223tauri-mcp driver-session stop
CLI使用MCPorter保活模式,因此后台守护进程会在多个独立的`tauri-mcp ...`命令之间保留会话状态。
仅当后台进程本身出现异常时,才使用守护进程命令:
```bash
tauri-mcp daemon status
tauri-mcp daemon restart
tauri-mcp driver-session start --port 9223UI Interaction
UI交互
bash
undefinedbash
undefinedClick or focus an element
点击或聚焦元素
tauri-mcp webview-interact --action click --selector "#submit-btn"
tauri-mcp webview-interact --action focus --selector "#search"
tauri-mcp webview-interact --action click --selector "#submit-btn"
tauri-mcp webview-interact --action focus --selector "#search"
Type into a field
在输入框中输入内容
tauri-mcp webview-keyboard --action type --selector "#email" --text "hello@example.com"
tauri-mcp webview-keyboard --action type --selector "#email" --text "hello@example.com"
Wait before interacting with async UI
等待异步UI加载完成后再交互
tauri-mcp webview-wait-for --type selector --value "#success-msg" --timeout 5000
tauri-mcp webview-interact --action click --selector "#success-msg"
tauri-mcp webview-wait-for --type selector --value "#success-msg" --timeout 5000
tauri-mcp webview-interact --action click --selector "#success-msg"
Keyboard shortcuts and scrolling
快捷键与滚动操作
tauri-mcp webview-keyboard --action press --key "s" --modifiers '["Control"]'
tauri-mcp webview-interact --action scroll --selector ".content" --scroll-y 300
All CLI flags are kebab-case, not camelCase. For example, use `--window-id`, not `--windowId`.tauri-mcp webview-keyboard --action press --key "s" --modifiers '["Control"]'
tauri-mcp webview-interact --action scroll --selector ".content" --scroll-y 300
所有CLI参数均使用短横线命名法(kebab-case),而非驼峰命名法(camelCase)。例如,使用`--window-id`而非`--windowId`。Inspection and Capture
检查与捕获
bash
undefinedbash
undefinedScreenshots always write files to disk
截图始终将文件写入磁盘
tauri-mcp webview-screenshot --file shot.png
tauri-mcp webview-screenshot --format jpeg --quality 80 --file shot.jpg
tauri-mcp webview-screenshot --json
tauri-mcp webview-screenshot --file shot.png
tauri-mcp webview-screenshot --format jpeg --quality 80 --file shot.jpg
tauri-mcp webview-screenshot --json
Run JavaScript in the webview
在webview中运行JavaScript代码
tauri-mcp webview-execute-js --script "document.title"
tauri-mcp webview-execute-js --script "(() => { return document.querySelectorAll('li').length; })()"
tauri-mcp webview-execute-js --script "document.title"
tauri-mcp webview-execute-js --script "(() => { return document.querySelectorAll('li').length; })()"
Find elements and inspect styles
查找元素并检查样式
tauri-mcp webview-find-element --selector "#hero"
tauri-mcp webview-get-styles --selector "#hero" --properties '["color","font-size"]'
tauri-mcp webview-find-element --selector "#hero"
tauri-mcp webview-get-styles --selector "#hero" --properties '["color","font-size"]'
Read logs and inspect windows
读取日志并检查窗口
tauri-mcp read-logs --source console --filter "error" --lines 100
tauri-mcp manage-window --action list --json
If content is off-screen, scroll it into view before taking a screenshot. The CLI does not return base64 image data on stdout.tauri-mcp read-logs --source console --filter "error" --lines 100
tauri-mcp manage-window --action list --json
如果内容不在屏幕可视区域内,请先将其滚动到视图中再截图。CLI不会在标准输出中返回base64格式的图片数据。IPC and Backend
IPC与后端
bash
undefinedbash
undefinedVerify the bridge plugin is active
验证桥接插件是否激活
tauri-mcp driver-session status --json
tauri-mcp driver-session status --json
Run backend commands
运行后端命令
tauri-mcp ipc-execute-command --command "greet" --args '{"name":"World"}'
tauri-mcp ipc-get-backend-state --json
tauri-mcp ipc-execute-command --command "greet" --args '{"name":"World"}'
tauri-mcp ipc-get-backend-state --json
Capture IPC traffic around an interaction
捕获交互过程中的IPC流量
tauri-mcp ipc-monitor --action stop
tauri-mcp ipc-monitor --action start
tauri-mcp webview-interact --action click --selector "#refresh"
tauri-mcp ipc-get-captured --json
tauri-mcp ipc-monitor --action stop
tauri-mcp ipc-monitor --action stop
tauri-mcp ipc-monitor --action start
tauri-mcp webview-interact --action click --selector "#refresh"
tauri-mcp ipc-get-captured --json
tauri-mcp ipc-monitor --action stop
Emit synthetic events
触发合成事件
tauri-mcp ipc-emit-event --event-name "user-action" --payload '{"action":"button-clicked"}'
If `driver-session status --json` returns `identifier: null`, treat that as a missing or inactive bridge plugin.tauri-mcp ipc-emit-event --event-name "user-action" --payload '{"action":"button-clicked"}'
如果`driver-session status --json`返回`identifier: null`,则表示桥接插件缺失或未激活。Mobile and Remote Devices
移动与远程设备
bash
undefinedbash
undefinedList targets
列出目标设备
tauri-mcp list-devices --json
tauri-mcp list-devices --json
Android emulator or iOS simulator
Android模拟器或iOS模拟器
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session start --port 9223
Real Android device
真实Android设备
adb reverse tcp:9223 tcp:9223
tauri-mcp driver-session start --port 9223
adb reverse tcp:9223 tcp:9223
tauri-mcp driver-session start --port 9223
Real iOS device or direct network connection
真实iOS设备或直接网络连接
tauri-mcp driver-session start --host 192.168.1.101 --port 9223
tauri-mcp driver-session start --host 192.168.1.101 --port 9223
Mobile logs
移动设备日志
tauri-mcp read-logs --source android --filter "com.myapp"
tauri-mcp read-logs --source ios --filter "MyApp"
For real Android devices, do not assume localhost works without `adb reverse` or an explicit `--host`.tauri-mcp read-logs --source android --filter "com.myapp"
tauri-mcp read-logs --source ios --filter "MyApp"
对于真实Android设备,请勿假设无需`adb reverse`或显式指定`--host`即可使用localhost连接。High-Value Failure Modes
常见高风险故障场景
No active session
无活跃会话
bash
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session status --jsonbash
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session status --jsonStale daemon or app restart
守护进程过期或应用重启
bash
tauri-mcp daemon restart
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session status --jsonbash
tauri-mcp daemon restart
tauri-mcp driver-session start --port 9223
tauri-mcp driver-session status --jsonWrong port
端口错误
bash
tauri-mcp driver-session start --port 9225bash
tauri-mcp driver-session start --port 9225Screenshot misuse
截图使用错误
bash
undefinedbash
undefinedWrong: captures a file path string, not image bytes
错误:捕获的是文件路径字符串,而非图片字节
IMG=$(tauri-mcp webview-screenshot)
IMG=$(tauri-mcp webview-screenshot)
Right
正确做法
tauri-mcp webview-screenshot --file shot.png
undefinedtauri-mcp webview-screenshot --file shot.png
undefinedJavaScript return shape
JavaScript返回格式错误
bash
undefinedbash
undefinedWrong: returns null
错误:返回null
tauri-mcp webview-execute-js --script "() => { return document.title; }"
tauri-mcp webview-execute-js --script "() => { return document.title; }"
Right
正确做法
tauri-mcp webview-execute-js --script "document.title"
undefinedtauri-mcp webview-execute-js --script "document.title"
undefinedMissing selector for typed input
输入操作缺少选择器
bash
undefinedbash
undefinedWrong
错误
tauri-mcp webview-keyboard --action type --text "hello"
tauri-mcp webview-keyboard --action type --text "hello"
Right
正确做法
tauri-mcp webview-keyboard --action type --selector "#email" --text "hello"
undefinedtauri-mcp webview-keyboard --action type --selector "#email" --text "hello"
undefinedDecision Checklist
操作前检查清单
Before acting, verify:
- The app is running.
- shows
driver-session status --json.connected: true - The command uses kebab-case flags.
- Screenshot commands write to explicit file paths when the result matters.
- Mobile workflows specify the correct connection path and log source.
执行操作前,请验证以下内容:
- 应用正在运行。
- 显示
driver-session status --json。connected: true - 命令使用短横线命名法(kebab-case)的参数。
- 当截图结果重要时,截图命令需指定明确的文件路径。
- 移动设备工作流指定了正确的连接路径和日志来源。