使用说明
Tauri插件:模型上下文协议(MCP)
一个全面的Tauri插件和MCP服务器,将AI代理(Claude Code、Cursor、Cline等)与您的Tauri桌面应用程序连接起来,实现智能调试、测试和自动化功能。
概述
模型上下文协议(MCP)是一种开放协议,规范了人工智能助手与外部系统的交互方式。此插件为Tauri应用程序实现了MCP,允许AI代理:
- 可视化调试 通过截图和分析UI状态
- 自动化测试 通过模拟用户交互
- 检查应用程序状态 通过DOM访问和存储检查
- 执行JavaScript 在高级调试的应用程序上下文中
- 控制窗口 用于多窗口测试场景的编程
为什么要使用这个插件?
传统的调试需要手动重现问题和目视检查。使用此MCP插件,AI代理可以:
- 看看你看到了什么 -截取屏幕截图以了解视觉错误
- 做你所做的 -模拟点击、打字和导航
- 知道里面是什么 -访问DOM、本地存储和应用程序状态
- 自主修复 -执行JavaScript以实时测试修复
这在以下方面尤其强大:
- 调试视觉回归 -AI可以比较更改前后的屏幕截图
- 自动化UI测试 -生成并执行测试场景
- 跨平台验证 -验证不同操作系统窗口之间的行为
- 状态检查 -通过检查存储和DOM结构诊断问题
关于本项目
此插件基于原始 tauri插件mcp 由P3GLEG,并已 经过大量修改和改进 与:
主要增强功能
- 控制台和错误跟踪:用于捕获控制台日志和异常的新工具
- 综合文档:
- 完整的快速入门指南
- 刀具参数参考
- 带有调试工作流的AI代理使用指南
- 详细的开发工作流程指南
- 常见的调试模式和最佳实践
- 增强的开发人员体验:
- 提交前检查表
- 添加新工具的分步指南
- Rust和TypeScript的代码模板
- 测试策略和示例
- 生产准备就绪:广泛的故障排除指南和错误处理
- 更好的组织:具有清晰示例的结构化文档
归因
原创作品: P3GLEG/tauri插件mcp 许可证:麻省理工学院(见 许可证)
我们感谢P3GLEG为这个插件奠定了基础。这个分叉旨在为人工智能代理和人类开发人员提供一个更全面、生产就绪的解决方案,并提供大量文档。
📚 文档
MCP新手? 从我们的综合指南开始:
在......下面 主要README的快速参考。有关分步说明,请参阅上面的指南。
快速开始
想立即开始吗?以下是最低限度的设置:
# 1. Add to your Tauri app's Cargo.toml
tauri-plugin-mcp = { path = "../.tauri-plugin-mcp" }
# 2. Register in src-tauri/src/main.rs (debug builds only!)
#[cfg(debug_assertions)]
{
use tauri_plugin_mcp::PluginConfig;
builder = builder.plugin(tauri_plugin_mcp::init_with_config(
PluginConfig::new("YourApp".to_string())
.start_socket_server(true)
.socket_path("/tmp/tauri-mcp.sock") // macOS/Linux
));
}
# 3. Build the MCP server
cd .tauri-plugin-mcp/mcp-server-ts
pnpm install && pnpm build
# 4. Configure your AI agent (Claude Code/Cursor/Cline)
# Add to ~/.config/claude/claude_code_config.json:
{
"mcpServers": {
"tauri-mcp": {
"command": "node",
"args": ["/absolute/path/to/.tauri-plugin-mcp/mcp-server-ts/build/index.js"]
}
}
}
# 5. Start your Tauri app and test!
pnpm run tauri dev
现在AI代理可以调试你的应用程序了!看 入门指南 详细设置。
可用的MCP工具-快速参考
| 工具 | 目的 | 常见用例 |
|---|---|---|
| take_screenshot | 捕获窗口或元素图像 | 视觉回归测试、错误报告 |
| get_dom | 检索HTML结构 | 调试动态内容,状态检查 |
| execute_js | 在webview中运行JavaScript | 状态检查、API调用、框架访问 |
| get_element_position | 查找元素坐标 | 准备鼠标点击、布局调试 |
| inject_console_capture | 启用控制台日志收集 | 捕获console.log/error/warn消息 |
| get_sole_log | 检索捕获的日志 | 调试运行时错误,日志分析 |
| inject_error_tracker | 启用异常跟踪 | 捕获未处理的错误、承诺拒绝 |
| get_exceptions | 检索跟踪的错误 | 了解崩溃原因、错误模式 |
| local_storage_get | 读取本地存储项 | 会话调试、身份验证令牌检查 |
| local_storage_set | 写入localStorage项 | 测试状态持久性,设置测试数据 |
| local_storage_remove | 删除本地存储项 | 清理,测试删除流程 |
| local_storage_clear | 清除所有本地存储 | 重置为干净状态 |
| local_storage_get_all | 检索所有存储 | 完成状态检查 |
| 管理窗口 | 控制窗口属性 | 多窗口测试、定位、聚焦 |
| 健康检查 | 验证插件连接 | 连接诊断、启动验证 |
| 拼 | 简单连接测试 | 基本健康检查 |
看 特性 了解每个工具的详细文档。
建筑
┌─────────────────────────────────────────────────────────────┐
│ AI Agent (Claude/Cursor) │
│ (MCP Client via stdio/SSE) │
└───────────────────────────┬─────────────────────────────────┘
│
│ MCP Protocol
│ (JSON-RPC)
│
┌───────────────────────────▼─────────────────────────────────┐
│ MCP Server (TypeScript - Node.js) │
│ • Implements MCP protocol │
│ • Exposes tools to AI agents │
│ • Manages socket connection lifecycle │
└───────────────────────────┬─────────────────────────────────┘
│
│ IPC Socket or TCP
│ (JSON commands)
│
┌───────────────────────────▼─────────────────────────────────┐
│ Tauri Plugin (Rust - Socket Server) │
│ • Listens on Unix socket/Named pipe/TCP │
│ • Processes JSON commands │
│ • Executes Tauri API calls │
└───────────────────────────┬─────────────────────────────────┘
│
│ Tauri IPC
│
┌───────────────────────────▼─────────────────────────────────┐
│ Your Tauri Application │
│ • Frontend (React/Vue/Svelte/etc.) │
│ • Webview rendering │
│ • Application logic │
└─────────────────────────────────────────────────────────────┘
部件分解
1. Tauri插件(Rust)
- 套接字服务器 (
socket_server.rs):通过IPC或TCP管理持久连接 - 工具实施 (
src/tools/*.rs):每个功能都有单独的Rust模块 - Tauri集成:连接到Tauri的窗口和webview API
2. MCP服务器(TypeScript)
- 客户端连接 (
client.ts):连接到Tauri插件的插槽 - 工具注册表 (
src/tools/*.ts):将MCP工具调用映射到套接字命令 - 协议处理器:实现用于AI代理通信的MCP规范
3. 通信流
AI Request → MCP Server → Socket → Tauri Plugin → Tauri API → App
← ← ← ← ←
AI Response JSON Rust Handler Result Effect
特性
窗口交互
屏幕截图
以像素完美的精度捕获任何Tauri窗口的高质量图像。
使用案例:
- 视觉回归测试
- 带上下文的Bug报告
- UI状态验证
- 自动生成文档
能力:
- 配置JPEG质量(1-100)
- 指定精确尺寸或使用窗口大小
- 在多窗口应用程序中定位特定窗口
- Base64或文件输出
例子: AI可以截图,分析UI,并告诉你“提交按钮向右偏移了3px。”
窗口管理
对窗口生命周期和属性进行完全编程控制。
能力:
- 位置:设置x、y坐标
- 大小:调整宽度和高度
- 状态:最小化、最大化、恢复、聚焦
- 多窗口:按标签定位特定窗口
- 可见性:显示、隐藏、带到前面
使用案例:
- 多窗口测试场景
- 车窗定位测试
- 焦点管理调试
- 屏幕布局自动化
DOM访问
从任何Web视图中检索完整的HTML结构和内容。
能力:
- 完整DOM树提取
- JavaScript评估上下文
- 元件检查
- 计算样式和属性(通过JS执行)
使用案例:
- 调试动态内容
- 正在验证数据绑定
- 分析生成的标记
- 无DevTools的状态检查
例子: AI可以读取DOM,通过选择器查找特定元素,并验证其内容或属性。
用户输入模拟
鼠标移动
以像素完美的精度模拟逼真的鼠标交互。
能力:
- 点击:左、右、中键点击
- 双击和三次单击
- 运动:绝对和相对定位
- 滚动:使用增量控制进行垂直和水平滚动
- 按住和拖动操作
使用案例:
- 自动化UI测试
- 点击流验证
- 悬停状态测试
- 拖放测试
例子: AI可以点击按钮,通过屏幕截图验证结果,并继续多步骤的工作流程。
文本输入
通过键盘模拟将文本编程输入到焦点元素中。
能力:
- 在任何焦点输入/文本区域中键入
- 模拟键盘事件
- 特殊字符和修饰符
- 粘贴大文本块
使用案例:
- 表单填写自动化
- 输入验证测试
- 搜索功能测试
- 文本编辑器交互
例子: AI可以填写表单,提交表单,并验证提交成功。
执行JavaScript
直接在应用程序的webview上下文中运行任意JavaScript代码。
能力:
- 完全访问窗口范围
- 将值返回给插件
- 异步/等待支持
- 错误处理和报告
使用案例:
- 高级状态检查
- 动态测试场景
- 直接API调用
- 特定于框架的交互(React状态、Vue存储等)
例子: AI可以执行 window.store.getState() 以检查Redux状态或直接调用应用程序方法。
数据和存储
本地存储管理
在浏览器localStorage上完成CRUD操作。
能力:
- 获取:检索单个项目或所有条目
- 设置:添加或更新键值对
- 删除:删除特定密钥
- 清除:擦除所有存储
使用案例:
- 状态持久性测试
- 缓存调试
- 用户偏好检查
- 会话数据验证
例子: AI可以检查localStorage的身份验证令牌,验证过期时间,并测试刷新流。
拼
简单的连接测试,以验证插件是否响应。
使用案例:
- 连接健康监测
- 启动验证
- 调试连接问题
- 集成测试
刀具参数参考
每个MCP工具的详细参数规格:
屏幕截图工具
take_screenshot
{
quality?: number; // JPEG quality 1-100 (default: 90)
width?: number; // Target width in pixels (optional)
height?: number; // Target height in pixels (optional)
window_label?: string; // Target window (default: main window)
}
DOM和检查工具
get_dom
{
window_label?: string; // Target window (default: main window)
}
get_element_position
{
selector: string; // CSS selector (required)
window_label?: string; // Target window (default: main window)
}
execute_js
{
script: string; // JavaScript code to execute (required)
window_label?: string; // Target window (default: main window)
}
控制台和错误跟踪
inject_console_capture
{
window_label?: string; // Target window (default: main window)
}
get_sole_log
{
level?: "log" | "warn" | "error" | "info" | "debug"; // Filter by level
since?: number; // Unix timestamp - only logs after this time
limit?: number; // Max number of logs to return
window_label?: string; // Target window
}
inject_error_tracker
{
window_label?: string; // Target window (default: main window)
}
get_exceptions
{
since?: number; // Unix timestamp - only errors after this time
limit?: number; // Max number of errors to return
window_label?: string; // Target window
}
存储工具
local_storage_get
{
key: string; // Storage key (required)
window_label?: string; // Target window
}
local_storage_set
{
key: string; // Storage key (required)
value: string; // Value to store (required)
window_label?: string; // Target window
}
local_storage_remove
{
key: string; // Storage key (required)
window_label?: string; // Target window
}
local_storage_clear
{
window_label?: string; // Target window
}
local_storage_get_all
{
window_label?: string; // Target window
}
窗口管理
管理窗口
{
action: "resize" | "move" | "focus" | "minimize" | "maximize" | "restore";
window_label?: string; // Target window (default: main window)
x?: number; // X position for move action
y?: number; // Y position for move action
width?: number; // Width for resize action
height?: number; // Height for resize action
}
诊断
健康检查
{} // No parameters required
拼
{} // No parameters required
入门指南
先决条件
- 锈 (最新稳定):用于Tauri开发
- Node.js 18+:用于MCP服务器
- pnpm (推荐)或npm:包管理
- Tauri CLI:
cargo install tauri-cli
步骤1:构建插件
首先,构建Rust插件和TypeScript MCP服务器:
# Install dependencies
pnpm install
# Build the Rust plugin and TypeScript server
pnpm run build && pnpm run build-plugin
这将:
- 编译Rust插件(
tauri-plugin-mcp) - 构建TypeScript MCP服务器(
mcp-server-ts/build/)
第二步:集成到您的Tauri应用程序中
2.1添加依赖关系
如果你还没有Tauri应用程序,请关注 Tauri的快速入门指南.
在您的应用程序中 src-tauri/Cargo.toml,添加插件依赖关系:
[dependencies]
tauri-plugin-mcp = { path = "../path/to/tauri-plugin-mcp" }
# Or from a git repository:
# tauri-plugin-mcp = { git = "https://github.com/yourusername/tauri-plugin-mcp" }
在您的应用程序中 package.json,添加来宾绑定:
{
"dependencies": {
"tauri-plugin-mcp": "file:../path/to/tauri-plugin-mcp"
}
}
2.2注册插件
重要安全提示: 仅在开发版本中启用MCP。此插件提供对应用程序的深度访问,绝不应包含在生产中。
在你的 src-tauri/src/main.rs (或 lib.rs 移动设备):
use tauri_plugin_mcp;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let mut builder = tauri::Builder::default();
// Only enable MCP in development builds
#[cfg(debug_assertions)]
{
use tauri_plugin_mcp::PluginConfig;
builder = builder.plugin(tauri_plugin_mcp::init_with_config(
PluginConfig::new("YourAppName".to_string()) // Must match your app's window name
.start_socket_server(true)
// Choose ONE connection mode:
// Option 1: IPC Socket (Default - Recommended)
.socket_path("/tmp/tauri-mcp.sock") // macOS/Linux
// .socket_path("\\\\.\\pipe\\tauri-mcp") // Windows
// Option 2: TCP Socket (Useful for Docker/Remote debugging)
// .tcp("127.0.0.1".to_string(), 4000)
));
log::info!("MCP plugin enabled for development");
}
builder
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
配置选项:
PluginConfig::new(app_name):用于标识窗口的应用程序名称(必须与您的tauri.conf.json标题).start_socket_server(true):启用套接字服务器(必需).socket_path(path):IPC套接字位置(macOS/Linux上的Unix套接字,Windows上的命名管道).tcp(host, port):TCP套接字配置(IPC的替代方案)
特定于平台的套接字路径:
- macOS/Linux:
/tmp/tauri-mcp.sock(或任何路径/tmp) - 视窗:
\\\\.\\pipe\\tauri-mcp(命名管道格式)
步骤3:为您的AI代理配置MCP服务器
MCP服务器充当AI代理(Claude Code、Cursor、Cline)和Tauri应用程序之间的桥梁。
3.1构建MCP服务器
cd mcp-server-ts
pnpm install
pnpm build
这创造了 mcp-server-ts/build/index.js,人工智能代理的切入点。
3.2配置您的AI代理
将MCP服务器添加到AI代理的配置文件中:
克劳德代码 (~/.config/claude/claude_code_config.json 或 claude_desktop_config.json):
对于光标 (.cursor/mcp-config.json):
对于克莱恩 (VSCode设置):
{
"mcpServers": {
"tauri-mcp": {
"command": "node",
"args": ["/absolute/path/to/tauri-plugin-mcp/mcp-server-ts/build/index.js"]
}
}
}
替换 /absolute/path/to/ 使用系统上的实际路径。
配置模式
模式1:IPC插座(默认-推荐)
最适合当地发展,开销最低。使用特定于平台的进程间通信。
默认配置(不需要环境变量):
{
"mcpServers": {
"tauri-mcp": {
"command": "node",
"args": ["/path/to/mcp-server-ts/build/index.js"]
}
}
}
自定义套接字路径:
{
"mcpServers": {
"tauri-mcp": {
"command": "node",
"args": ["/path/to/mcp-server-ts/build/index.js"],
"env": {
"TAURI_MCP_IPC_PATH": "/custom/path/to/socket"
}
}
}
}
平台特定默认值:
- macOS/Linux:
/tmp/tauri-mcp.sock - 窗户:
\\\\.\\pipe\\tauri-mcp
模式2:TCP套接字
在以下情况下使用TCP:
- 在Docker中运行Tauri应用程序
- 跨网络远程调试
- IPC套接字权限问题
- 从多台机器进行测试
配置:
{
"mcpServers": {
"tauri-mcp": {
"command": "node",
"args": ["/path/to/mcp-server-ts/build/index.js"],
"env": {
"TAURI_MCP_CONNECTION_TYPE": "tcp",
"TAURI_MCP_TCP_HOST": "127.0.0.1",
"TAURI_MCP_TCP_PORT": "4000"
}
}
}
}
对应Tauri插件配置:
#[cfg(debug_assertions)]
{
builder = builder.plugin(tauri_plugin_mcp::init_with_config(
PluginConfig::new("YourApp".to_string())
.start_socket_server(true)
.tcp("127.0.0.1".to_string(), 4000) // Must match MCP server config
));
}
安全警告: TCP套接字将您的应用程序暴露于网络连接。使用 127.0.0.1 (localhost)以防止外部访问。从不使用 0.0.0.0 在类似生产的环境中。
环境变量引用
| 变量 | 默认值 | 描述 |
|---|---|---|
TAURI_MCP_CONNECTION_TYPE |
ipc |
连接方式: ipc 或 tcp |
TAURI_MCP_IPC_PATH |
平台特定 | 自定义IPC套接字路径 |
TAURI_MCP_TCP_HOST |
127.0.0.1 |
TCP服务器主机(仅TCP模式) |
TAURI_MCP_TCP_PORT |
3000 |
TCP服务器端口(仅TCP模式) |
工作原理:沟通流程
了解通信流有助于调试和扩展插件。
请求/响应周期
1. AI Agent sends MCP request
↓
2. MCP Server receives tool call (e.g., "take_screenshot")
↓
3. MCP Server constructs JSON command
{
"action": "take_screenshot",
"params": { "quality": 80 }
}
↓
4. Socket Client sends command to Socket Server (IPC or TCP)
↓
5. Socket Server (Rust) receives JSON command
↓
6. Router dispatches to appropriate tool handler
↓
7. Tool handler calls Tauri API
(e.g., window.screenshot())
↓
8. Result returned as JSON
{
"success": true,
"data": { "image": "base64..." }
}
↓
9. Socket Client receives response
↓
10. MCP Server formats response per MCP protocol
↓
11. AI Agent receives result
组件详细信息
套接字服务器(Rust- socket_server.rs)
责任:
- 创建和管理套接字侦听器(IPC或TCP)
- 接受具有持久支持的传入连接
- 从客户端反序列化JSON命令
- 将命令路由到适当的工具处理程序
- 将响应序列化回JSON
- 处理错误和连接生命周期
主要特点:
- 持久连接:支持每个连接的多个请求
- 并发客户端:同时处理多个AI代理
- 错误恢复:妥善处理格式错误的请求
- 类型安全:强类型的命令/响应结构
实施:
// Simplified example
match command.action.as_str() {
"take_screenshot" => {
let params: ScreenshotParams = serde_json::from_value(command.params)?;
let result = tools::take_screenshot(&app, params).await?;
Ok(json!({ "success": true, "data": result }))
}
// ... other actions
}
套接字客户端(TypeScript- client.ts)
责任:
- 建立与套接字的连接(IPC或TCP)
- 发送JSON序列化命令
- 等待并反序列化响应
- 实现连接失败的重试逻辑
- 管理连接池/重用
主要特点:
- 基于承诺的API:异步/等待支持
- 自动重新连接:重试失败的连接
- 超时处理:防止挂起请求
- 类型定义:所有命令的TypeScript接口
实施:
// Simplified example
async function sendCommand(action: string, params: any): Promise<any> {
const command = { action, params };
await socket.write(JSON.stringify(command) + '\n');
const response = await socket.readLine();
return JSON.parse(response);
}
MCP服务器(TypeScript- mcp-server-ts/)
责任:
- 实施MCP协议规范
- 用描述注册可用工具
- 将MCP工具调用转换为套接字命令
- 根据MCP模式格式化响应
- 处理与AI代理的stdio通信
工具注册示例:
server.registerTool({
name: "take_screenshot",
description: "Capture a screenshot of the Tauri window",
inputSchema: {
type: "object",
properties: {
quality: { type: "number", minimum: 1, maximum: 100 }
}
}
});
故障排除
诊断步骤
在深入探讨具体问题之前,请遵循以下诊断清单:
-
验证Tauri应用程序是否在调试模式下运行
pnpm run tauri dev # Look for log: "MCP plugin enabled for development" -
检查套接字文件是否存在 (仅IPC模式)
# macOS/Linux ls -l /tmp/tauri-mcp.sock # Windows PowerShell Get-ChildItem \\.\pipe\ | Select-String tauri-mcp -
测试插座连接 (仅TCP模式)
# macOS/Linux nc -zv 127.0.0.1 4000 # Windows Test-NetConnection -ComputerName 127.0.0.1 -Port 4000 -
检查MCP服务器日志
- AI代理日志通常显示MCP服务器stdout/stderr
- 查找连接尝试和错误
常见问题
问题1:“连接被拒绝”或“ECONNREFUSED”
症状: MCP服务器无法连接到Tauri插件。
原因和解决方案:
- Tauri应用程序未运行:使用启动应用程序
pnpm run tauri dev - 套接字服务器已禁用:验证
.start_socket_server(true)在插件配置中 - 连接模式不匹配:确保MCP服务器和Tauri插件使用相同的模式(IPC或TCP)
- 端口不匹配(TCP):验证端口号是否完全匹配:
// Tauri: .tcp("127.0.0.1".to_string(), 4000) // MCP Server env: TAURI_MCP_TCP_PORT=4000
调试命令:
# Check if socket server is listening (TCP mode)
lsof -i :4000 # macOS/Linux
netstat -an | findstr :4000 # Windows
# Check Tauri app logs
# Look for: "Socket server started on..."
问题2:“找不到套接字文件”(IPC模式)
症状: 提到套接字路径不存在时出错。
原因和解决方案:
-
套接字未创建:Tauri应用程序可能无法启动套接字服务器
- 检查Tauri日志中的套接字创建错误
- 验证路径是否具有写入权限(尝试
/tmp在Unix上)
-
插座路径错误:确保路径完全匹配:
// Tauri .socket_path("/tmp/tauri-mcp.sock")// MCP Server (if custom path) "env": { "TAURI_MCP_IPC_PATH": "/tmp/tauri-mcp.sock" } -
重新启动时清除路径:
/tmp可能会在系统重新启动时清除- 重新启动Tauri应用程序以重新创建插槽
解决方法: 切换到不使用文件系统的TCP模式。
问题3:“权限被拒绝”(IPC模式)
症状: 套接字文件存在,但无法访问。
原因和解决方案:
-
文件权限:检查套接字文件权限
ls -l /tmp/tauri-mcp.sock # Should be readable/writable by your user -
SELinux/AppArmor(Linux):安全模块可能会阻止套接字访问
# Temporary disable SELinux (for testing only) sudo setenforce 0 -
Windows命名管道权限:确保管道名称格式正确
.socket_path("\\\\.\\pipe\\tauri-mcp") // Correct format
解决方法: 使用TCP模式以避免文件系统权限。
问题4:每次请求后连接中断
症状: 每次工具调用都需要重新连接;反应缓慢。
原因和解决方案:
- 过时的插件版本:确保您使用的是具有持久连接支持的最新版本
- 短暂超时:增加客户端超时设置
- 服务器端错误:检查Tauri日志,查看是否有可能导致连接中断的恐慌或错误
修复:
cd tauri-plugin-mcp
git pull
pnpm run build && pnpm run build-plugin
问题5:“找不到工具”或工具调用失败
症状: AI代理表示该工具不存在或返回错误。
原因和解决方案:
-
未构建MCP服务器:重建MCP服务器
cd mcp-server-ts pnpm build -
工具未注册:检查
mcp-server-ts/src/tools/index.ts包括工具 -
架构不匹配:确保工具参数与预期架构匹配
调试:
# List available tools using MCP Inspector
cd mcp-server-ts
npx @modelcontextprotocol/inspector node build/index.js
# Click "List Tools" to see registered tools
问题6:屏幕截图为黑色或空白
症状: 截图工具返回空白或全黑图像。
原因和解决方案:
-
窗口名称错误:应用程序名称必须与窗口标题匹配
PluginConfig::new("ExactAppName".to_string()) // Must match tauri.conf.json -
窗口未聚焦/可见:确保窗口可见且未最小化
-
Webview未加载:等待应用程序完全加载后再进行截图
-
macOS权限:授予您的终端/IDE屏幕录制权限
- 系统首选项→ 安全与隐私→ 屏幕录制
问题7:JavaScript执行失败
症状: execute_js 工具返回错误或未定义。
原因和解决方案:
- Webview未就绪:确保在执行JS之前加载DOM
- 语法错误:验证JavaScript语法
- CSP限制:内容安全策略可能会阻止内联脚本
- 返回值序列化:确保返回的值是JSON可序列化的
例子:
// Bad: Returns DOM element (not serializable)
execute_js({ script: "document.getElementById('app')" })
// Good: Returns serializable data
execute_js({ script: "document.getElementById('app').textContent" })
测试您的设置
使用MCP检查器
官方的MCP检查器提供了一个GUI来测试您的服务器:
cd mcp-server-ts
# IPC mode (default)
npx @modelcontextprotocol/inspector node build/index.js
# TCP mode
TAURI_MCP_CONNECTION_TYPE=tcp \
TAURI_MCP_TCP_HOST=127.0.0.1 \
TAURI_MCP_TCP_PORT=4000 \
npx @modelcontextprotocol/inspector node build/index.js
# Windows (TCP mode)
set TAURI_MCP_CONNECTION_TYPE=tcp&& set TAURI_MCP_TCP_HOST=127.0.0.1&& set TAURI_MCP_TCP_PORT=4000&& npx @modelcontextprotocol/inspector node build\index.js
检查员允许您:
- 列出所有可用工具
- 查看工具模式和描述
- 使用自定义参数执行工具
- 查看实时请求/响应日志
手动测试
直接测试插座连接:
# Test TCP socket
echo '{"action":"ping","params":{}}' | nc 127.0.0.1 4000
# Test Unix socket (macOS/Linux)
echo '{"action":"ping","params":{}}' | nc -U /tmp/tauri-mcp.sock
预期响应:
{"success":true,"data":"pong"}
获取帮助
如果你在尝试这些解决方案后仍然停滞不前:
- 检查日志:从Tauri应用程序和MCP服务器收集日志
- 最小繁殖:创建一个最小的Tauri应用程序来重现这个问题
- 打开一个问题:包括:
- 操作系统和版本
- Tauri版本(
cargo tauri info) - 连接方式(IPC或TCP)
- 完整的错误消息和堆栈跟踪
- 配置文件(插件配置和MCP服务器配置)
AI代理使用指南
本节为AI代理(如Claude Code、Cursor、Cline)提供了如何有效地使用此插件调试Tauri应用程序的指导。
推荐的调试工作流程
调试Tauri应用程序时,请遵循以下系统方法:
1. 验证连接
始终从验证插件是否可访问开始:
// Step 1: Health check
await health_check({});
// Step 2: Ping test
await ping({});
检查内容:
- 插件已加载并响应
- 插座连接正常
- MCP服务器可以与Tauri应用程序通信
2. 设置监控
在调查问题之前,请设置对运行时错误和日志的监控:
// Enable console log capture
await inject_console_capture({});
// Enable error tracking
await inject_error_tracker({});
为什么这很重要:
- 捕获调查过程中出现的错误
- 日志提供有关应用程序正在做什么的上下文
- 防止丢失重要诊断信息
3. 了解视觉状态
截图以了解用户看到的内容:
// Capture current visual state
const screenshot = await take_screenshot({ quality: 80 });
// Analyze the screenshot to understand:
// - Is the UI rendered correctly?
// - Are there visual errors?
// - Which elements are visible?
使用屏幕截图:
- 视觉回归检测
- 确认操作前后的UI状态
- 识别布局问题
- 记录错误
4. 检查DOM结构
检查HTML结构以了解应用程序状态:
// Get full DOM
const dom = await get_dom({});
// Or find specific elements
const buttonPos = await get_element_position({
selector: "button.submit"
});
寻找:
- 缺失或意外元素
- 不正确的属性或类
- 动态内容问题
- 特定于框架的数据属性
5. 检查应用程序状态
使用JavaScript执行检查应用程序状态:
// Check React state (if using React)
const state = await execute_js({
script: `
const app = document.getElementById('root');
const fiber = app._reactRootContainer?._internalRoot?.current;
// Return serializable state information
JSON.stringify({ /* state data */ });
`
});
// Check localStorage for session data
const storage = await local_storage_get_all({});
// Check specific configuration
const config = await execute_js({
script: "JSON.stringify(window.__APP_CONFIG__ || {})"
});
常见状态源:
- 冗余存储:
window.store?.getState() - 状态 :
window.useStore?.getState() - 发件人:
window.app?.$store?.state - 本地/会话存储
- 全局配置对象
6. 查看运行时日志
检查控制台日志和错误以获取诊断信息:
// Get recent error messages
const errors = await get_exceptions({
since: Date.now() - 60000, // Last minute
limit: 50
});
// Get console logs
const logs = await get_console_logs({
level: "error",
since: Date.now() - 60000
});
// Analyze patterns:
// - Are there recurring errors?
// - What was the sequence of events?
// - Are there unhandled promise rejections?
7. 形式和检验假设
根据收集到的信息,形成假设并对其进行检验:
// Example: Testing if a specific function exists
const hasFunction = await execute_js({
script: "typeof window.myFunction === 'function'"
});
// Example: Testing if data loaded
const dataLoaded = await execute_js({
script: `
const data = window.myData;
JSON.stringify({
exists: !!data,
length: data?.length || 0,
isEmpty: !data || data.length === 0
});
`
});
// Example: Testing localStorage state
const authState = await local_storage_get({ key: "auth_token" });
AI代理的最佳实践
注意事项
-
始终先验证连接 -使用
health_check()或ping()在尝试其他操作之前 -
尽早设置监控 -呼叫
inject_console_capture()和inject_error_tracker()在调试会话开始时 -
在操作前后进行截图 -记录视觉变化以了解影响
-
对复杂查询使用execute_js -将多个检查批处理到一个JavaScript执行中,以减少往返
-
每次重大行动后检查日志 -使用
get_console_logs()和get_exceptions()立即捕捉错误 -
清理测试数据 -使用
local_storage_clear()或local_storage_remove()在测试之间重置状态 -
具体使用选择器 -在中使用精确的CSS选择器
get_element_position()避免歧义 -
优雅地处理错误 -在try-catch中封装工具调用,并在操作失败时提供有用的上下文
不应该做的
-
不要想当然地认为插件总是可用的 -始终验证连接,特别是在新会话中
-
不要跳过视觉验证 -屏幕截图提供了日志无法提供的关键上下文
-
不执行不受信任的代码 -只运行您已验证安全的JavaScript
-
不要忽略TypeScript类型 -使用《工具参数参考》中定义的参数类型
-
不要被要求压倒 -尽可能进行批量操作以减少开销
-
不要忘记多窗口应用程序 -使用
window_label针对特定窗口的参数 -
不要假设同步执行 -所有操作都是异步的;正确使用wait
-
不要在生产中启用监控 -控制台/错误跟踪仅用于调试
常见调试模式
模式1:调试表单提交问题
// 1. Verify form is visible
const screenshot = await take_screenshot({});
// 2. Check form state
const formData = await execute_js({
script: `
const form = document.querySelector('form');
const formData = new FormData(form);
const obj = {};
formData.forEach((value, key) => obj[key] = value);
JSON.stringify({
action: form.action,
method: form.method,
data: obj
});
`
});
// 3. Check for validation errors
const logs = await get_console_logs({ level: "error" });
// 4. Check network-related errors (if applicable)
const exceptions = await get_exceptions({});
模式2:调试状态管理问题
// 1. Inspect current state
const currentState = await execute_js({
script: "JSON.stringify(window.store?.getState() || {})"
});
// 2. Check localStorage for persisted state
const persistedState = await local_storage_get({ key: "redux_state" });
// 3. Compare expected vs actual
// 4. Check for state update errors in logs
const logs = await get_console_logs({ level: "warn" });
模式3:调试视觉渲染问题
// 1. Take screenshot
const screenshot = await take_screenshot({});
// 2. Get DOM to check element attributes
const dom = await get_dom({});
// 3. Check element positioning
const position = await get_element_position({
selector: ".problematic-element"
});
// 4. Check computed styles
const styles = await execute_js({
script: `
const el = document.querySelector('.problematic-element');
const styles = window.getComputedStyle(el);
JSON.stringify({
display: styles.display,
visibility: styles.visibility,
opacity: styles.opacity,
position: styles.position,
zIndex: styles.zIndex
});
`
});
模式4:调试API集成问题
// 1. Check for network errors in console
const logs = await get_console_logs({ level: "error" });
// 2. Check application state for API responses
const apiState = await execute_js({
script: `
JSON.stringify({
baseURL: window.API_BASE_URL,
lastResponse: window.__lastAPIResponse__,
pendingRequests: window.__pendingRequests__?.length || 0
});
`
});
// 3. Check localStorage for tokens
const authToken = await local_storage_get({ key: "auth_token" });
// 4. Verify token format and expiration
const tokenInfo = await execute_js({
script: `
try {
const token = localStorage.getItem('auth_token');
if (!token) throw new Error('No token');
const parts = token.split('.');
const payload = JSON.parse(atob(parts[1]));
JSON.stringify({
isExpired: payload.exp * 1000 < Date.now(),
expiresAt: new Date(payload.exp * 1000).toISOString()
});
} catch (e) {
JSON.stringify({ error: e.message });
}
`
});
AI代理的错误处理
当工具调用失败时,系统地处理错误:
try {
const result = await some_tool({ params });
} catch (error) {
// 1. Check if it's a connectivity issue
try {
await ping({});
} catch (pingError) {
// Plugin is not accessible - inform user
// Suggest: Check if Tauri app is running
// Suggest: Verify socket configuration
return;
}
// 2. Check if it's a parameter validation issue
if (error.message.includes('validation')) {
// Review parameter types in Tool Parameters Reference
// Provide corrected parameters
}
// 3. Check if it's a window-specific issue
if (error.message.includes('window')) {
// Verify window_label is correct
// Check if window still exists
}
// 4. Provide helpful context to user
// Include: What you were trying to do
// Include: The specific error message
// Include: Suggested next steps
}
性能提示
-
批处理JavaScript执行:
// Good: Single execution const allData = await execute_js({ script: ` JSON.stringify({ title: document.title, url: location.href, userCount: document.querySelectorAll('.user').length, isLoggedIn: !!localStorage.getItem('auth_token') }); ` }); // Bad: Multiple round trips const title = await execute_js({ script: "document.title" }); const url = await execute_js({ script: "location.href" }); const userCount = await execute_js({ script: "document.querySelectorAll('.user').length" }); -
使用适当的屏幕截图质量:
- 使用
quality: 60-70用于快速检查 - 使用
quality: 90-100进行详细分析 - 质量较低=传输速度更快,尺寸更小
- 使用
-
限制日志检索:
- 使用
limit避免检索数千条日志的参数 - 使用
since仅获取最近日志的参数 - 筛选依据
level专注于错误
- 使用
-
如果多次分析,则缓存DOM:
- 获取DOM一次,并在代码中多次分析它
- 仅当您对应用程序进行了更改时才重新获取
使用示例
示例1:视觉回归测试
让AI代理自动检测UI更改:
提示AI:
“截取主窗口的屏幕截图,然后单击“主题”按钮并截取另一个屏幕截图。比较两者并告诉我视觉上发生了什么变化。”
发生了什么:
- AI进行初始截图
- AI模拟鼠标点击主题按钮
- AI再次截图
- AI分析图像并报告差异(颜色、布局等)
示例2:自动表单测试
测试表格验证和提交:
提示AI:
“用无效数据填写注册表,并验证错误消息是否正确显示。”
发生了什么:
- AI使用
text_input在表单字段中键入 - AI使用
mouse_movement单击“提交”按钮 - AI使用
take_screenshot捕获错误状态 - AI使用
get_dom验证DOM中的错误消息 - AI报告验证是否正常工作
示例3:状态检查
在不打开DevTools的情况下调试应用程序状态:
提示AI:
“检查当前的Redux存储状态,并告诉我用户是否经过身份验证。”
发生了什么:
- AI使用
execute_js运行:window.store.getState() - AI检查返回的状态对象
- AI报告身份验证状态和相关数据
示例4:多窗口测试
测试多窗口场景:
提示AI:
“打开设置窗口,将主题更改为深色,截取屏幕截图,然后切换回主窗口并验证主题是否也更改了。”
发生了什么:
- AI使用
window_manager聚焦设置窗口 - AI与主题控件交互
- AI对设置窗口进行截图
- AI通过以下方式切换到主窗口
window_manager - AI验证跨窗口的主题一致性
示例5:本地存储调试
检查和修改存储的数据:
提示AI:
“检查localStorage中存储的内容,并清除所有过期的会话令牌。”
发生了什么:
- AI使用
local_storage_get_all检索所有条目 - AI检查令牌到期日期
- AI使用
local_storage_remove清除过期的令牌 - AI确认清理成功
安全考虑
仅供开发使用
关键: 此插件为您的应用程序提供了强大的访问权限,应该 永不 包含在生产构建中。
始终将插件注册封装在调试断言中:
#[cfg(debug_assertions)]
{
builder = builder.plugin(tauri_plugin_mcp::init_with_config(...));
}
为什么这很重要
该插件允许:
- 任意JavaScript执行 在您的网络视图中
- 完全DOM访问 包括敏感数据
- 屏幕截图 潜在的敏感用户界面
- 存储访问 包括令牌和凭证
- 输入模拟 这可能会引发意想不到的行动
生产构建保护
验证插件是否已从生产中排除:
# Build for production
pnpm run tauri build
# Check the binary doesn't include MCP symbols (Linux/macOS)
nm -a ./target/release/myapp | grep -i mcp
# Should return nothing if properly excluded
# Or check Cargo features
cargo tree --features | grep mcp
网络安全(TCP模式)
使用TCP模式时:
-
仅绑定到本地主机:切勿使用
0.0.0.0.tcp("127.0.0.1".to_string(), 4000) // Safe .tcp("0.0.0.0".to_string(), 4000) // DANGEROUS -
防火墙保护:确保防火墙阻止外部访问MCP端口
# macOS - block external access sudo pfctl -e -
改用IPC:首选无法远程访问的IPC插座
数据暴露风险
请注意,AI代理可以访问:
- 用户凭据 在本地存储/会话存储中
- API令牌 处于应用程序状态
- 个人数据 显示在UI中
- 业务逻辑 通过JavaScript执行
缓解措施:
- 仅与受信任的AI代理一起使用该插件
- 执行前查看AI代理提示
- 清除开发环境中的敏感数据
- 使用测试帐户,而不是生产凭据
高级主题
扩展插件
根据您的特定需求添加自定义工具:
1.创建Rust工具处理程序
创建 src/tools/custom_tool.rs:
use tauri::{AppHandle, Runtime};
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
pub struct CustomToolParams {
pub param1: String,
}
#[derive(Serialize)]
pub struct CustomToolResult {
pub result: String,
}
pub async fn custom_tool<R: Runtime>(
app: &AppHandle<R>,
params: CustomToolParams,
) -> Result<CustomToolResult, String> {
// Your custom logic here
Ok(CustomToolResult {
result: format!("Processed: {}", params.param1),
})
}
2.在路由器中注册
在 src/tools/mod.rs:
pub mod custom_tool;
// In the command router
match action {
"custom_tool" => {
let params = serde_json::from_value(command.params)?;
let result = custom_tool::custom_tool(&app, params).await?;
Ok(json!({ "success": true, "data": result }))
}
// ... other actions
}
3.添加TypeScript绑定
在 mcp-server-ts/src/tools/custom_tool.ts:
export const customToolDefinition = {
name: "custom_tool",
description: "Your custom tool description",
inputSchema: {
type: "object",
properties: {
param1: {
type: "string",
description: "Parameter description"
}
},
required: ["param1"]
}
};
export async function customTool(params: { param1: string }) {
return await client.sendCommand("custom_tool", params);
}
4.在MCP服务器中注册
在 mcp-server-ts/src/tools/index.ts:
import { customToolDefinition, customTool } from './custom_tool';
server.registerTool(customToolDefinition, customTool);
性能优化
屏幕截图压缩
减小屏幕截图大小以加快传输速度:
PluginConfig::new("App".to_string())
.screenshot_quality(60) // Lower quality = smaller size
连接池
该插件支持持久连接。确保您的客户端重用连接:
// Good: Reuse connection
const client = await createClient();
await client.sendCommand("ping", {});
await client.sendCommand("take_screenshot", {});
// Bad: New connection each time
await (await createClient()).sendCommand("ping", {});
await (await createClient()).sendCommand("take_screenshot", {});
批量操作
如果可能,将批处理操作转换为单个JavaScript执行:
// Good: Single JS execution
execute_js({
script: `
const data = {
title: document.title,
url: window.location.href,
userCount: document.querySelectorAll('.user').length
};
JSON.stringify(data);
`
});
// Bad: Multiple roundtrips
execute_js({ script: "document.title" });
execute_js({ script: "window.location.href" });
execute_js({ script: "document.querySelectorAll('.user').length" });
跨平台注意事项
窗口名称匹配
不同的平台可能会以不同的方式报告窗口标题:
// macOS: Usually exact match
PluginConfig::new("MyApp".to_string())
// Windows: May include additional decorations
PluginConfig::new("MyApp - Window Name".to_string())
// Linux: Depends on window manager
// Test with: wmctrl -l
套接字路径
特定于平台的默认路径:
#[cfg(target_os = "macos")]
const DEFAULT_SOCKET: &str = "/tmp/tauri-mcp.sock";
#[cfg(target_os = "linux")]
const DEFAULT_SOCKET: &str = "/tmp/tauri-mcp.sock";
#[cfg(target_os = "windows")]
const DEFAULT_SOCKET: &str = "\\\\.\\pipe\\tauri-mcp";
权限差异
- macOS:需要屏幕录制权限才能进行屏幕截图
- 视窗:某些窗口操作可能需要管理员权限
- Linux:取决于X11/Wayland和窗口管理器权限
贡献
欢迎投稿!以下是如何开始:
开发设置
# Clone the repository
git clone https://github.com/yourusername/tauri-plugin-mcp
cd tauri-plugin-mcp
# Install dependencies
pnpm install
# Build plugin and server
pnpm run build && pnpm run build-plugin
# Run tests
cargo test
cd mcp-server-ts && pnpm test
开发工作流程
1.设置开发环境
所需工具:
- Rust工具链(最新稳定版)
- Node.js 18+和pnpm
- Tauri测试应用程序
- MCP测试检验员:
npx @modelcontextprotocol/inspector
IDE设置(推荐):
- VS Code 带扩展名:
- 锈蚀分析仪
- 涛瑞
- 埃斯林特
- 更漂亮
- IntelliJ IDEA/RustRover 使用Rust和Tauri插件
2.进行更改
对于Rust更改(插件核心):
# 1. Make changes in src/
vim src/tools/my_tool.rs
# 2. Run format and lint
cargo fmt
cargo clippy
# 3. Build
cargo build
# 4. Test
cargo test
# 5. Test in real app
cd ../your-tauri-app
pnpm run tauri dev
对于TypeScript更改(MCP服务器):
cd mcp-server-ts
# 1. Make changes in src/
vim src/tools/my_tool.ts
# 2. Run format and lint
pnpm run lint
pnpm run format
# 3. Build
pnpm build
# 4. Test
pnpm test
# 5. Test with MCP Inspector
npx @modelcontextprotocol/inspector node build/index.js
3.测试您的更改
单元测试:
# Rust unit tests
cargo test
# TypeScript unit tests
cd mcp-server-ts && pnpm test
集成测试:
-
使用插件启动Tauri测试应用程序:
cd your-test-app pnpm run tauri dev -
使用MCP检查器测试工具:
cd mcp-server-ts npx @modelcontextprotocol/inspector node build/index.js -
或者与您的AI代理(Claude Code、Cursor、Cline)进行测试
手动插座测试:
# Test ping command
echo '{"action":"ping","params":{}}' | nc -U /tmp/tauri-mcp.sock
# Test health check
echo '{"action":"health_check","params":{}}' | nc -U /tmp/tauri-mcp.sock
4.调试
Rust调试:
在测试应用程序中启用详细日志记录:
#[cfg(debug_assertions)]
{
env_logger::init(); // Add this
builder = builder.plugin(tauri_plugin_mcp::init_with_config(...));
}
然后运行:
RUST_LOG=debug pnpm run tauri dev
TypeScript调试:
添加调试日志 mcp-server-ts/src/client.ts:
console.error('[MCP] Sending command:', command);
console.error('[MCP] Received response:', response);
使用节点调试运行:
node --inspect build/index.js
5.预提交检查表
- []代码格式(
cargo fmt,pnpm run format) - []过梁(
cargo clippy,pnpm run lint) - []测试通过(
cargo test,pnpm test) - []在真实Tauri应用程序中测试的更改
- []文档已更新(README,文档注释)
- []CHANGELOG.md已更新(如适用)
添加新工具
添加新MCP工具的完整工作流程:
第一步:规划工具
定义:
- 目的:它解决了什么问题?
- 参数:它需要什么投入?
- 传回型别:它返回什么数据?
- 用例AI代理何时会使用它?
例子:
Tool: get_network_requests
Purpose: Retrieve all network requests made by the app
Parameters: { since?: timestamp, filter?: regex }
Returns: Array of { url, method, status, headers, body, timing }
Use Case: Debugging API integration issues, analyzing performance
步骤2:实现Rust处理程序
创建 src/tools/my_tool.rs:
use tauri::{AppHandle, Runtime};
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
pub struct MyToolParams {
pub param1: String,
pub optional_param: Option<i32>,
}
#[derive(Serialize)]
pub struct MyToolResult {
pub data: String,
}
pub async fn my_tool<R: Runtime>(
app: &AppHandle<R>,
params: MyToolParams,
) -> Result<MyToolResult, String> {
// Implementation here
Ok(MyToolResult {
data: format!("Processed: {}", params.param1),
})
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_my_tool() {
// Add unit tests
}
}
步骤3:在路由器中注册
增添 src/tools/mod.rs:
pub mod my_tool;
// In the command router match statement
"my_tool" => {
let params = serde_json::from_value(command.params)?;
let result = my_tool::my_tool(&app, params).await?;
Ok(json!({ "success": true, "data": result }))
}
步骤4:添加TypeScript绑定
创建 mcp-server-ts/src/tools/my_tool.ts:
import { client } from './client';
export const myToolDefinition = {
name: "my_tool",
description: "Clear description of what the tool does",
inputSchema: {
type: "object",
properties: {
param1: {
type: "string",
description: "Parameter description"
},
optional_param: {
type: "number",
description: "Optional parameter"
}
},
required: ["param1"]
}
};
export async function myTool(params: {
param1: string;
optional_param?: number;
}) {
return await client.sendCommand("my_tool", params);
}
步骤5:在MCP服务器中注册
增添 mcp-server-ts/src/tools/index.ts:
import { myToolDefinition, myTool } from './my_tool';
// In the setup function
server.registerTool(myToolDefinition, myTool);
第6步:编写测试
锈蚀试验:
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_my_tool_success() {
// Test implementation
}
#[tokio::test]
async fn test_my_tool_validation() {
// Test error cases
}
}
TypeScript测试:
// mcp-server-ts/tests/my_tool.test.ts
import { myTool } from '../src/tools/my_tool';
describe('myTool', () => {
it('should process valid input', async () => {
// Test implementation
});
});
步骤7:更新文档
添加到README:
- 在快速参考表中添加条目
- 添加到工具参数参考
- 在用法示例部分添加示例用法
代码的风格
- 锈:关注
rustfmt和clippy建议- 运行:
cargo fmt && cargo clippy - 提交前修复所有剪贴警告
- 运行:
- TypeScript:使用ESLint和Prettier配置
- 运行:
pnpm run lint && pnpm run format
- 运行:
- 提交:使用常规提交格式
feat:对于新功能fix:用于修复错误docs:用于文件编制refactor:用于代码重构test:用于添加测试
测试
# Rust tests
cargo test
# TypeScript tests
cd mcp-server-ts
pnpm test
# Integration tests with MCP Inspector
cd mcp-server-ts
npx @modelcontextprotocol/inspector node build/index.js
# Integration tests with real app
cd examples/test-app
pnpm run tauri dev
# Then test with your AI agent
常见开发任务
更改后重建:
# Full rebuild
pnpm run build && pnpm run build-plugin
# Rust only
cargo build
# TypeScript only
cd mcp-server-ts && pnpm build
运行详细日志记录:
# Tauri app with debug logs
RUST_LOG=debug pnpm run tauri dev
# MCP server with debug logs
DEBUG=* node build/index.js
测试插座连接:
# Check if socket exists
ls -l /tmp/tauri-mcp.sock
# Test with netcat
echo '{"action":"ping","params":{}}' | nc -U /tmp/tauri-mcp.sock
许可证
[在此处指定您的许可证,例如MIT、Apache 2.0等。]
致谢
资源
文档
外部链接
- Tauri文件: https://tauri.app/v2/
- MCP规范: https://spec.modelcontextprotocol.io/
- 原始插件: https://github.com/P3GLEG/tauri-plugin-mcp
- 克劳德代码: https://claude.com/claude-code
