tauri-plugin-mcp

tauri-plugin-mcp

An MCP server that allows AI agents to interact with and debug Tauri applications through screenshots, DOM access, input simulation, and more.

Category
访问服务器

README

Tauri Plugin: Model Context Protocol (MCP)

A Tauri plugin and MCP server that allow AI agents such as Cursor and Claude Code to interact with and debug your Tauri application through screenshots, DOM access, input simulation, and more.

Install

npm (guest-js bindings)

npm install tauri-plugin-mcp

MCP Server CLI

npm install -g tauri-plugin-mcp-server
# or run directly
npx tauri-plugin-mcp-server

Rust (Cargo)

Coming soon to crates.io. For now, use a git dependency:

[dependencies]
tauri-plugin-mcp = { git = "https://github.com/P3GLEG/tauri-plugin-mcp" }

Tools

The MCP server exposes 10 high-level tools to AI agents:

Tool Description
take_screenshot Captures a screenshot of an application window. Saves full image to disk with small thumbnail inline (optimized for token efficiency).
query_page Inspects the current page. Modes: map (structured element refs), html (raw DOM), state (URL/title/scroll/viewport), find_element (CSS pixel coordinates for clicking), app_info (app metadata, windows, monitors).
click Clicks at x/y coordinates or via selector (ref, id, class, tag, text). Selector-based clicks auto-resolve element position.
type_text Types text into the page. Supports a fields array for bulk form fill, selector targeting, or typing into the focused element. Works with inputs, textareas, contentEditable, React, Lexical, and Slate.
mouse_action Non-click mouse actions: hover, scroll (by direction/amount/to element/to top/bottom), drag (start to end coordinates).
navigate Webview navigation: goto (URL), back/forward (with optional delta), reload.
execute_js Runs arbitrary JavaScript in the webview. Returns the result of the last statement or promise.
manage_storage localStorage operations (get/set/remove/clear/keys) and cookie management (get/clear).
manage_window Window control (list/focus/minimize/maximize/close/position/size/fullscreen), zoom, devtools, and webview state management.
wait_for Waits for a condition: text appearing/disappearing, element visible/hidden/attached/detached. Useful after async content loads.

Setup

1. Register the plugin in your Tauri app

Only include the MCP plugin in development builds:

#[cfg(debug_assertions)]
{
    builder = builder.plugin(tauri_plugin_mcp::init_with_config(
        tauri_plugin_mcp::PluginConfig::new("APPLICATION_NAME".to_string())
            .start_socket_server(true)
            // IPC socket (default — recommended)
            .socket_path("/tmp/tauri-mcp.sock")
            // Or TCP socket
            // .tcp_localhost(4000)
            // For multi-webview apps where the webview label differs from the window label
            // .default_webview_label("preview".to_string())
            // Optional auth token for TCP connections
            // .auth_token("my-secret-token".to_string())
    ));
}

2. Configure your AI agent

IPC Mode (default, recommended)

{
  "mcpServers": {
    "tauri-mcp": {
      "command": "npx",
      "args": ["tauri-plugin-mcp-server"]
    }
  }
}

With a custom socket path:

{
  "mcpServers": {
    "tauri-mcp": {
      "command": "npx",
      "args": ["tauri-plugin-mcp-server"],
      "env": {
        "TAURI_MCP_IPC_PATH": "/custom/path/to/socket"
      }
    }
  }
}

TCP Mode

For Docker, remote debugging, or when IPC doesn't work:

{
  "mcpServers": {
    "tauri-mcp": {
      "command": "npx",
      "args": ["tauri-plugin-mcp-server"],
      "env": {
        "TAURI_MCP_CONNECTION_TYPE": "tcp",
        "TAURI_MCP_TCP_HOST": "127.0.0.1",
        "TAURI_MCP_TCP_PORT": "4000"
      }
    }
  }
}

Make sure your Tauri app uses the same connection mode:

.plugin(tauri_plugin_mcp::init_with_config(
    tauri_plugin_mcp::PluginConfig::new("MyApp".to_string())
        .tcp_localhost(4000)
))

Building from source

pnpm install
pnpm run build          # JS guest bindings
cargo build --release   # Rust plugin

# MCP server
cd mcp-server-ts
pnpm install && pnpm build

Architecture

AI Agent (Claude, Cursor, etc.)
    ↕ MCP protocol (stdio)
MCP Server (tauri-plugin-mcp-server)
    ↕ IPC socket or TCP
Tauri Plugin (Rust)
    ↕ Tauri events with correlation IDs
Guest JS (webview)
    ↕ DOM APIs
Your Application
  • Rust plugin (src/) — Async socket server, command routing, native input injection (macOS), screenshot capture
  • Guest JS (guest-js/) — DOM interaction, element resolution, form filling, event handling
  • MCP Server (mcp-server-ts/) — Translates MCP tool calls into socket commands

Security

  • Auth token support for TCP connections (constant-time comparison)
  • Token file written with 0o600 permissions, deleted on shutdown
  • Non-loopback TCP without auth token is rejected
  • Stale socket cleanup on startup

Platform notes

  • macOS: Native NSEvent injection — no Accessibility permissions needed
  • Windows/Linux: JS-based input fallback (isTrusted=false, ~80% coverage)
  • Screenshots: macOS/Windows use native capture; Linux uses xcap

Troubleshooting

  1. "Connection refused" — Ensure your Tauri app is running and the socket server started. Check that both sides use the same connection mode (IPC or TCP).

  2. "Socket file not found" (IPC) — Check that the socket path exists (look in /tmp on macOS/Linux). Try TCP mode as an alternative.

  3. "Permission denied" — On Unix, check file permissions for the socket. TCP mode avoids file permission issues.

  4. Testing your setup:

    npx @modelcontextprotocol/inspector npx tauri-plugin-mcp-server
    

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选