tauri-plugin-mcp
tauri-plugin-mcp
MCP (Model Context Protocol) を介したクロスプラットフォームTauriテスト自動化プラグイン。
ClaudeのようなAIアシスタントが、テストや自動化のためにTauriデスクトップアプリと対話できるようにします。
Claude Codeプラグイン
このリポジトリはClaude Codeプラグインとしても機能します。これをインストールすると、MCPサーバー、QAエージェント、スキル、検証フックを一度に取得できます:
# 1. Add the marketplace source
claude plugin marketplace add DaveDev42/tauri-plugin-mcp
# 2. Install the plugin
claude plugin install tauri-mcp --scope projectまたは、Claude Codeセッション内で実行します:
/plugin marketplace add DaveDev42/tauri-plugin-mcp
/plugin install tauri-mcp --scope projectインストール中に、以下を求められます:
Tauriアプリディレクトリ: プロジェクトルートからの相対パス(例:単一アプリリポジトリの場合は
.、モノレポの場合はapps/desktop)
これにより、MCPサーバー、QAエージェント、スキル、検証フックが自動的に設定されます。手動での .mcp.json 設定は不要です。
含まれるもの:
コンポーネント | 説明 |
MCPサーバー | 自動設定される |
| QAオーケストレーション -- テストシナリオの準備、QAエージェントへの委任、結果の検証 |
| Tauri v2プロジェクトへのtauri-plugin-mcpインストールに関するステップバイステップガイド |
| 一般的なMCPセッションの問題に対する診断デシジョンツリー |
| MCPツールを使用してテストシナリオを実行するテストエージェント(haiku) |
QA検証フック | QAのPASS結果に実際のツール呼び出しの証拠が含まれていることを確認 |
Related MCP server: MCP Server Tauri
特徴
クロスプラットフォーム: Windows (名前付きパイプ) + macOS/Linux (Unixソケット)
CDP依存関係なし: macOS WKWebViewを含むすべてのWebViewバックエンドで動作
MCP統合: Claude Codeおよびその他のMCPクライアントとの直接統合
マルチウィンドウサポート: ラベルで任意のウィンドウをターゲット可能。自動ブリッジインジェクション
統合ログ: フィルタリング機能付きのビルド、ランタイム、コンソール、ネットワークログ
動的ポート割り当て: 競合を避けるための自動ランダムポート割り当て
前提条件
Node.js >= 18
Tauri v2.x
pnpm (推奨) または npm
Rust (cargoを含む)
クイックスタート
[ ]
src-tauri/Cargo.tomlにRustプラグインを追加[ ] npmパッケージをインストール:
pnpm add github:DaveDev42/tauri-plugin-mcp#main[ ]
src-tauri/src/lib.rsにプラグインを登録[ ]
mcp:default権限を追加[ ]
main.tsxでブリッジを初期化[ ] Claude Code用に
.mcp.jsonを作成
インストール
1. Rustプラグイン (src-tauri/Cargo.toml)
[dependencies]
tauri-plugin-mcp = { git = "https://github.com/DaveDev42/tauri-plugin-mcp" }2. フロントエンドAPI (package.json)
pnpm add github:DaveDev42/tauri-plugin-mcp#main3. MCPサーバー
MCPサーバーバイナリ (tauri-mcp) はインストール後に自動的に利用可能になります。追加の設定は不要です。
セットアップ
1. プラグインの登録 (src-tauri/src/lib.rs)
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_mcp::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}2. 権限の追加
オプションA: tauri.conf.json または config/*.json5 内 (推奨)
{
"security": {
"capabilities": [{
"identifier": "main-capability",
"windows": ["main"],
"permissions": ["core:default", "mcp:default"]
}]
}
}オプションB: 別ファイル (src-tauri/capabilities/default.json)
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"windows": ["main"],
"permissions": ["core:default", "mcp:default"]
}3. ブリッジの初期化 (main.tsx)
// Initialize MCP bridge for E2E testing (dev mode only)
if (import.meta.env.DEV) {
import('tauri-plugin-mcp').then(({ initMcpBridge }) => {
initMcpBridge().catch(err => {
console.warn('[MCP] Bridge initialization failed:', err);
});
});
}本番環境向けの安全なセットアップ (オプションの依存関係)
上記の基本的なセットアップでは、すべてのビルドにMCPが含まれます。本番アプリでは、MCPを開発時のみに使用し、リリースバイナリからは完全に削除したい場合が多いでしょう。
このアプローチでは、Cargoのオプション依存関係機能を使用して、明示的に要求された場合にのみプラグインがコンパイルされるようにします。
1. Cargoのオプション依存関係 (src-tauri/Cargo.toml)
[features]
default = []
dev-tools = ["dep:tauri-plugin-mcp"]
[dependencies]
tauri-plugin-mcp = { git = "https://github.com/DaveDev42/tauri-plugin-mcp", optional = true }2. 条件付きプラグイン登録 (src-tauri/src/lib.rs)
pub fn run() {
let mut builder = tauri::Builder::default();
#[cfg(feature = "dev-tools")]
{
builder = builder.plugin(tauri_plugin_mcp::init());
}
builder
.run(tauri::generate_context!())
.expect("error while running tauri application");
}3. Capabilitiesファイルの分割
mcp:default を独自のcapabilityファイルに分離し、ビルド時に切り替えられるようにします。
capabilities/default.json — 常にアクティブ、MCP権限なし:
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"windows": ["main"],
"permissions": ["core:default"]
}capabilities/.dev-tools.json.disabled — MCP権限テンプレート (git管理):
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "dev-tools",
"windows": ["main"],
"permissions": ["mcp:default"]
}capabilities/dev-tools.json — .gitignore に追加 (ビルド時に生成):
# Dev-tools capability (generated from .disabled at build time)
src-tauri/capabilities/dev-tools.json4. build.rs — 条件付きcapabilities管理
build.rs は、機能が有効な場合にテンプレートをコピーし、それ以外の場合は削除します:
fn main() {
let dev_tools_cap = std::path::Path::new("capabilities/dev-tools.json");
let source_path = std::path::Path::new("capabilities/.dev-tools.json.disabled");
if std::env::var("CARGO_FEATURE_DEV_TOOLS").is_ok() {
// Copy .disabled → active (skip if already identical to avoid rebuild churn)
let should_copy = if dev_tools_cap.exists() {
std::fs::read(source_path).ok() != std::fs::read(dev_tools_cap).ok()
} else {
true
};
if should_copy {
std::fs::copy(source_path, dev_tools_cap)
.expect("Failed to copy dev-tools capability file");
}
} else if dev_tools_cap.exists() {
std::fs::remove_file(dev_tools_cap).ok();
}
tauri_build::try_build(
tauri_build::Attributes::default()
).expect("Failed to build tauri");
}5. 開発スクリプト (package.json)
{
"scripts": {
"dev": "tauri dev --features dev-tools"
}
}これで pnpm dev はMCPを有効にし、tauri build (機能なし) はMCPコードを含まないクリーンなリリースを生成します。
注: 基本セットアップ のフロントエンドブリッジガード (
import.meta.env.DEV) は引き続き適用されます。これにより、実行時にプラグインが存在していたとしてもブリッジが初期化されるのを防ぎます。
MCPサーバー設定
注: Claude Codeプラグイン をインストールした場合、MCPサーバーはすでに自動的に設定されています。プラグインはインストール中にTauriアプリディレクトリを尋ねます。このセクションはプラグインなしで手動設定する場合のものです。
プロジェクトルートの .mcp.json に以下を追加します:
{
"mcpServers": {
"tauri-mcp": {
"command": "npx",
"args": ["tauri-mcp"],
"env": {
"TAURI_APP_DIR": "."
}
}
}
}注: pnpmユーザーは
pnpx tauri-mcpまたはpnpm exec tauri-mcpも使用できます。
モノレポ設定
Tauriアプリがサブディレクトリ(例:apps/desktop)にある場合は、TAURI_APP_DIR を設定します:
{
"mcpServers": {
"tauri-mcp": {
"command": "npx",
"args": ["tauri-mcp"],
"env": {
"TAURI_APP_DIR": "./apps/desktop"
}
}
}
}複数のTauriアプリ
複数のTauriアプリを持つモノレポの場合、アプリごとに個別のMCPサーバーインスタンスを実行します:
{
"mcpServers": {
"tauri-desktop": {
"command": "npx",
"args": ["tauri-mcp"],
"env": { "TAURI_APP_DIR": "./apps/desktop" }
},
"tauri-kiosk": {
"command": "npx",
"args": ["tauri-mcp"],
"env": { "TAURI_APP_DIR": "./apps/kiosk" }
}
}
}ツールはサーバー名で名前空間化されます:mcp__tauri-desktop__snapshot, mcp__tauri-kiosk__snapshot など。
利用可能なツール
セッションライフサイクル
ツール | パラメータ | 説明 |
|
| セッション(アプリ)の状態を確認。 |
|
| セッションを開始( |
| - | セッションを停止(アプリのプロセスツリーを終了) |
ウィンドウ管理
ツール | パラメータ | 説明 |
| - | ラベル、タイトル、フォーカス状態、ブリッジ状態を含むすべての開いているウィンドウをリスト化 |
|
| ラベルで特定のウィンドウにフォーカス |
インタラクション
すべてのインタラクションツールは、特定のウィンドウをターゲットにするためのオプションの window パラメータを受け入れます(デフォルトはフォーカスされているウィンドウ)。
ツール | パラメータ | 説明 |
|
|
|
|
| 参照またはCSSセレクターで要素をクリック |
|
| 入力フィールドを埋める |
|
| キーボードキーを押す(例: "Enter", "Tab") |
|
| URLに移動 |
|
| ネイティブOSキャプチャ経由でスクリーンショットを撮影 |
|
| WebViewでJavaScriptを実行 |
可観測性
ツール | パラメータ | 説明 |
|
| ソース/レベルフィルタリング付きの統合ログアクセス(ビルド、ランタイム、コンソール、ネットワーク) |
|
|
Available Tools
14 toolsclickC
Click element by ref or selector
Inputs: ref, selector, window.
evaluate_scriptC
Run JS in webview
Inputs: script (required), window.
fillC
Fill input by ref or selector
Inputs: value (required), ref, selector, window.
focus_windowB
Focus a specific window by label
Inputs: window (required).
get_logsC
Get application logs with filtering. Filters can be combined (e.g., ["build", "error"] for build errors only).
Inputs: filter, limit, clear, window.
get_restart_eventsA
Get recent app restart/reload events with the files that triggered them. Includes Rust rebuilds (backend) and HMR updates (frontend).
Inputs: limit, clear, window.
get_session_statusA
Check session (app) status. Use probe_bridge to verify bridge health per window.
Inputs: probe_bridge.
list_windowsA
List all open windows with their labels, titles, and focus state
Inputs: no named parameters.
press_keyD
Press key
Inputs: key (required), window.
screenshotC
Take screenshot
Inputs: window.
snapshotA
Get accessibility tree (returns ref numbers for click/fill)
Inputs: window.
start_sessionC
Start session (launch Tauri app)
Inputs: wait_for_ready, timeout_secs, features, devtools.
stop_sessionB
Stop session (kill app)
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool targets a distinct action or information source: UI interactions (click, fill, press_key), scripting (evaluate_script), navigation (navigate), visual capture (screenshot), accessibility (snapshot), window management (list_windows, focus_window), session lifecycle (start/stop_session), and diagnostics (get_logs, get_restart_events, get_session_status). No two tools have overlapping purposes.
All tool names follow a clear verb_noun pattern using lowercase with underscores (e.g., get_logs, focus_window, start_session). Even single-word names like click, fill, navigate are consistent with the imperative style. No mixed conventions or inconsistent verbs.
14 tools is well-scoped for a Tauri testing/MCP server. It covers all major aspects: session control, window management, UI interaction, scripting, diagnostics, and capture. The count is neither too sparse (missing essential features) nor bloated.
The tool surface covers the full lifecycle of a Tauri app test: start/stop sessions, manage windows, interact via clicks/keys/scripts, navigate, capture screenshots and accessibility trees, and retrieve logs/events. No obvious gaps for typical automation tasks, making it a self-contained toolset.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Run, debug, and triage tests from your IDE using natural language, no dashboard switching, no manual data transfers. The TestMu AI (formerly LambdaTest) MCP Server is a single remote server exposing four tool suites: HyperExecute — analyze your project, generate YAML configs and test runner commands, then monitor jobs and sessions. Automation — pull a TestID's details plus command, network, and console logs into one chat for instant root-cause analysis. Includes mobile app upload. SmartUI — explain pixel, layout, DOM, and perceptual changes in a visual regression run, with context-aware React/HTML/CSS fixes. Accessibility — audit any public URL or a local React app against WCAG and get ready-to-apply remediation steps. Connects over https://mcp.lambdatest.com/mcp using OAuth 2.1 — no API keys in your config. One-click install in Cursor; works with Claude, GitHub Copilot, Cline, and any MCP client. Tests execute on the TestMu AI cloud: 3,000+ browsers and 10,000+ real devices.
Write, run and check natural-language browser tests of your web app from your AI assistant.
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables AI-driven testing and automation of Tauri desktop applications through natural language, allowing users to interact with UI elements, capture screenshots, execute commands, and test application flows without manual clicking or complex scripts.98MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to build, test, and debug Tauri v2 applications with UI automation, IPC monitoring, mobile device management, and real-time access to screenshots, DOM state, and console logs.19338MIT
- FlicenseNot gradedqualityDmaintenanceA Tauri plugin that enables AI agents to interact with Tauri applications through screenshots, DOM inspection, and input simulation via the Model Context Protocol. It allows agents to perform actions like clicking, typing, and executing JavaScript within the application's webview context.1-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with and debug Tauri desktop applications, providing tools for window management, user input simulation, and storage operations.MIT