@hypothesi/tauri-plugin-mcp-bridge 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/LICENSE +39 -0
- package/README.md +260 -0
- package/dist-js/index.d.ts +50 -0
- package/dist-js/index.d.ts.map +1 -0
- package/dist-js/index.js +43 -0
- package/guest-js/index.ts +74 -0
- package/guest-js/package.json +8 -0
- package/guest-js/tsconfig.json +15 -0
- package/package.json +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.2] - 2025-11-26
|
|
11
|
+
|
|
12
|
+
_No changes to this package._
|
|
13
|
+
|
|
14
|
+
## [0.1.1] - 2025-11-26
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Improve `execute_js` error handling with better JSON parse error logging
|
|
18
|
+
- Add `__TAURI__` availability check before emitting script results
|
|
19
|
+
- Catch unhandled promise rejections in executed scripts
|
|
20
|
+
- Double-wrap script execution to catch both parse and runtime errors
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
- Initial release of tauri-plugin-mcp-bridge
|
|
24
|
+
- IPC monitoring capabilities
|
|
25
|
+
- Window information retrieval
|
|
26
|
+
- Backend state inspection
|
|
27
|
+
- Custom event emission
|
|
28
|
+
- WebSocket server for real-time event streaming
|
package/LICENSE
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Fireside Development, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Apache License, Version 2.0
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2025 Fireside Development, LLC
|
|
28
|
+
|
|
29
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
30
|
+
you may not use this file except in compliance with the License.
|
|
31
|
+
You may obtain a copy of the License at
|
|
32
|
+
|
|
33
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
+
|
|
35
|
+
Unless required by applicable law or agreed to in writing, software
|
|
36
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
37
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
38
|
+
See the License for the specific language governing permissions and
|
|
39
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Tauri MCP Bridge Plugin
|
|
2
|
+
|
|
3
|
+
[](https://crates.io/crates/tauri-plugin-mcp-bridge)
|
|
4
|
+
[](https://docs.rs/tauri-plugin-mcp-bridge)
|
|
5
|
+
[](https://github.com/hypothesi/mcp-server-tauri)
|
|
6
|
+
|
|
7
|
+
A Tauri plugin that bridges the Model Context Protocol (MCP) with Tauri applications, enabling deep inspection and interaction with Tauri's IPC layer, backend state, and window management.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
The MCP Bridge plugin extends MCP servers with direct access to Tauri internals. It provides real-time IPC monitoring, window state inspection, backend state access, and event emission capabilities.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
Add this to your `Cargo.toml`:
|
|
16
|
+
|
|
17
|
+
```toml
|
|
18
|
+
[dependencies]
|
|
19
|
+
tauri-plugin-mcp-bridge = "0.1"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
Register the plugin in your Tauri application:
|
|
25
|
+
|
|
26
|
+
```rust
|
|
27
|
+
use tauri_plugin_mcp_bridge;
|
|
28
|
+
|
|
29
|
+
fn main() {
|
|
30
|
+
tauri::Builder::default()
|
|
31
|
+
.plugin(tauri_plugin_mcp_bridge::init())
|
|
32
|
+
.run(tauri::generate_context!())
|
|
33
|
+
.expect("error while running tauri application");
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Custom Configuration
|
|
38
|
+
|
|
39
|
+
By default, the plugin binds to `0.0.0.0` (all interfaces) to support remote device development. For localhost-only access:
|
|
40
|
+
|
|
41
|
+
```rust
|
|
42
|
+
use tauri_plugin_mcp_bridge::Builder;
|
|
43
|
+
|
|
44
|
+
fn main() {
|
|
45
|
+
tauri::Builder::default()
|
|
46
|
+
.plugin(Builder::new().bind_address("127.0.0.1").build())
|
|
47
|
+
.run(tauri::generate_context!())
|
|
48
|
+
.expect("error while running tauri application");
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
### 1. IPC Monitoring
|
|
55
|
+
|
|
56
|
+
Monitor all Tauri IPC calls in real-time with timing and argument capture:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// Start monitoring
|
|
60
|
+
await invoke('plugin:mcp-bridge|start_ipc_monitor');
|
|
61
|
+
|
|
62
|
+
// Execute some commands to generate IPC traffic
|
|
63
|
+
await invoke('greet', { name: 'World' });
|
|
64
|
+
|
|
65
|
+
// Get captured events
|
|
66
|
+
const events = await invoke('plugin:mcp-bridge|get_ipc_events');
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 2. Window Information
|
|
70
|
+
|
|
71
|
+
Get detailed window state:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const windowInfo = await invoke('plugin:mcp-bridge|get_window_info');
|
|
75
|
+
// Returns: { width, height, x, y, title, focused, visible }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 3. Backend State
|
|
79
|
+
|
|
80
|
+
Inspect application backend state:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
const state = await invoke('plugin:mcp-bridge|get_backend_state');
|
|
84
|
+
// Returns: { app: { name, identifier, version }, tauri: { version },
|
|
85
|
+
// environment: { debug, os, arch, family }, windows: [...], timestamp }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 4. Event Emission
|
|
89
|
+
|
|
90
|
+
Trigger custom events for testing:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
await invoke('plugin:mcp-bridge|emit_event', {
|
|
94
|
+
eventName: 'custom-event',
|
|
95
|
+
payload: { data: 'test' }
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## MCP Server Integration
|
|
100
|
+
|
|
101
|
+
This plugin is part of the larger MCP Server for Tauri, which provides **23 total MCP tools** for comprehensive Tauri development and testing. The plugin specifically enables the following tools:
|
|
102
|
+
|
|
103
|
+
### Project Management Tools (4)
|
|
104
|
+
|
|
105
|
+
1. **tauri_run_command** - Run any Tauri CLI command with full flexibility
|
|
106
|
+
2. **tauri_read_config** - Read Tauri configuration files (including platform-specific configs)
|
|
107
|
+
3. **tauri_write_config** - Write to Tauri configuration files with validation
|
|
108
|
+
4. **tauri_get_docs** - Get Tauri documentation (LLM Cheat Sheet) for the detected project version
|
|
109
|
+
|
|
110
|
+
### Mobile Development Tools (2)
|
|
111
|
+
|
|
112
|
+
1. **tauri_list_devices** - List connected Android devices and iOS simulators
|
|
113
|
+
2. **tauri_launch_emulator** - Launch an Android AVD or iOS Simulator
|
|
114
|
+
|
|
115
|
+
### UI Automation & WebView Tools (11)
|
|
116
|
+
|
|
117
|
+
Tools for UI automation and webview interaction via the plugin's WebSocket connection:
|
|
118
|
+
|
|
119
|
+
1. **tauri_driver_session** - Manage automation session (start or stop)
|
|
120
|
+
2. **tauri_webview_find_element** - Find an element in the webview
|
|
121
|
+
3. **tauri_driver_get_console_logs** - Get console logs from the webview
|
|
122
|
+
4. **tauri_read_platform_logs** - Read platform logs (Android logcat, iOS device logs, system logs)
|
|
123
|
+
5. **tauri_webview_interact** - Perform gestures (click, double-click, long-press, swipe, scroll)
|
|
124
|
+
6. **tauri_webview_screenshot** - Take screenshots of the entire webview
|
|
125
|
+
7. **tauri_webview_keyboard** - Type text or simulate keyboard events with optional modifiers
|
|
126
|
+
8. **tauri_webview_wait_for** - Wait for element selectors, text content, or IPC events
|
|
127
|
+
9. **tauri_webview_get_styles** - Get computed CSS styles for element(s)
|
|
128
|
+
10. **tauri_webview_execute_js** - Execute arbitrary JavaScript code in the webview context
|
|
129
|
+
11. **tauri_webview_focus_element** - Focus on a specific element in the webview
|
|
130
|
+
|
|
131
|
+
### IPC & Plugin Tools (6)
|
|
132
|
+
|
|
133
|
+
Tools that directly use the MCP Bridge plugin's Rust backend:
|
|
134
|
+
|
|
135
|
+
1. **tauri_plugin_execute_ipc** - Execute any Tauri IPC command with the MCP bridge plugin
|
|
136
|
+
2. **tauri_plugin_get_window_info** - Get detailed information about the current window
|
|
137
|
+
3. **tauri_plugin_ipc_monitor** - Manage IPC monitoring (start or stop)
|
|
138
|
+
4. **tauri_plugin_ipc_get_events** - Retrieve all captured IPC events with optional filtering
|
|
139
|
+
5. **tauri_plugin_emit_event** - Emit custom Tauri events for testing event handlers
|
|
140
|
+
6. **tauri_plugin_get_backend_state** - Get backend application state and metadata
|
|
141
|
+
|
|
142
|
+
## Architecture
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
MCP Server (Node.js)
|
|
146
|
+
│
|
|
147
|
+
├── Native IPC (via plugin) ────> Tauri App Webview (DOM/UI)
|
|
148
|
+
│ │
|
|
149
|
+
└── Plugin Client ──────────────────────┼──> Plugin Commands
|
|
150
|
+
(WebSocket port 9223) │
|
|
151
|
+
│
|
|
152
|
+
mcp-bridge Plugin
|
|
153
|
+
(Rust Backend)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## WebSocket Communication
|
|
157
|
+
|
|
158
|
+
The plugin runs a WebSocket server on port 9223 (or next available in range 9223-9322) for real-time communication with the MCP server.
|
|
159
|
+
|
|
160
|
+
### Remote Device Development
|
|
161
|
+
|
|
162
|
+
By default, the WebSocket server binds to `0.0.0.0` (all network interfaces), enabling connections from:
|
|
163
|
+
|
|
164
|
+
- **iOS devices** on the same network
|
|
165
|
+
- **Android devices** on the same network or via `adb reverse`
|
|
166
|
+
- **Emulators/Simulators** via localhost
|
|
167
|
+
|
|
168
|
+
#### Connecting from MCP Server
|
|
169
|
+
|
|
170
|
+
The MCP server supports connecting to remote Tauri apps via the `tauri_driver_session` tool:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
// Connect to a Tauri app on a remote device
|
|
174
|
+
tauri_driver_session({ action: 'start', host: '192.168.1.100' })
|
|
175
|
+
|
|
176
|
+
// Or use environment variables:
|
|
177
|
+
// MCP_BRIDGE_HOST=192.168.1.100 npx mcp-server-tauri
|
|
178
|
+
// TAURI_DEV_HOST=192.168.1.100 npx mcp-server-tauri (same as Tauri CLI uses)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### Connection Strategy
|
|
182
|
+
|
|
183
|
+
The MCP server uses a fallback strategy:
|
|
184
|
+
1. Try `localhost:{port}` first (most reliable for simulators/emulators/desktop)
|
|
185
|
+
2. If localhost fails and a remote host is configured, try `{host}:{port}`
|
|
186
|
+
3. Auto-discover apps on localhost if specific connection fails
|
|
187
|
+
|
|
188
|
+
## Development
|
|
189
|
+
|
|
190
|
+
### Building the Plugin
|
|
191
|
+
|
|
192
|
+
From the plugin directory:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
cd packages/tauri-plugin-mcp-bridge
|
|
196
|
+
cargo build
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Or from the workspace root:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npm run build:plugin
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Documentation
|
|
206
|
+
|
|
207
|
+
View the comprehensive Rust API documentation:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
npm run docs:rust
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Or directly:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
cd packages/tauri-plugin-mcp-bridge
|
|
217
|
+
cargo doc --open --no-deps
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Testing
|
|
221
|
+
|
|
222
|
+
Run the MCP server tests which include plugin integration tests:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
npm test
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Permissions
|
|
229
|
+
|
|
230
|
+
The plugin requires the following permissions to be configured in your Tauri capabilities:
|
|
231
|
+
|
|
232
|
+
- `execute_command`
|
|
233
|
+
- `get_window_info`
|
|
234
|
+
- `get_backend_state`
|
|
235
|
+
- `emit_event`
|
|
236
|
+
- `start_ipc_monitor`
|
|
237
|
+
- `stop_ipc_monitor`
|
|
238
|
+
- `get_ipc_events`
|
|
239
|
+
|
|
240
|
+
These are typically auto-configured when using the plugin.
|
|
241
|
+
|
|
242
|
+
## API Documentation
|
|
243
|
+
|
|
244
|
+
For detailed API documentation, including:
|
|
245
|
+
|
|
246
|
+
- Complete function signatures and parameters
|
|
247
|
+
- Rust examples for backend integration
|
|
248
|
+
- TypeScript examples for frontend usage
|
|
249
|
+
- Architecture and design details
|
|
250
|
+
|
|
251
|
+
Visit the [docs.rs documentation](https://docs.rs/tauri-plugin-mcp-bridge) or build locally with `npm run docs:rust`.
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
This project is licensed under either of:
|
|
256
|
+
|
|
257
|
+
- MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
|
258
|
+
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
259
|
+
|
|
260
|
+
at your option.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface WindowInfo {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
title: string;
|
|
7
|
+
focused: boolean;
|
|
8
|
+
visible: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface BackendState {
|
|
11
|
+
status: string;
|
|
12
|
+
windows: number;
|
|
13
|
+
}
|
|
14
|
+
export interface IPCEvent {
|
|
15
|
+
timestamp: number;
|
|
16
|
+
command: string;
|
|
17
|
+
args: unknown;
|
|
18
|
+
result?: unknown;
|
|
19
|
+
error?: string;
|
|
20
|
+
duration_ms?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Execute an arbitrary Tauri command
|
|
24
|
+
*/
|
|
25
|
+
export declare function executeCommand(command: string, args?: unknown): Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Get information about the current window
|
|
28
|
+
*/
|
|
29
|
+
export declare function getWindowInfo(): Promise<WindowInfo>;
|
|
30
|
+
/**
|
|
31
|
+
* Get backend application state
|
|
32
|
+
*/
|
|
33
|
+
export declare function getBackendState(): Promise<BackendState>;
|
|
34
|
+
/**
|
|
35
|
+
* Emit a custom event for testing
|
|
36
|
+
*/
|
|
37
|
+
export declare function emitEvent(eventName: string, payload?: unknown): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Start IPC monitoring - captures all invoke() calls
|
|
40
|
+
*/
|
|
41
|
+
export declare function startIPCMonitor(): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Stop IPC monitoring
|
|
44
|
+
*/
|
|
45
|
+
export declare function stopIPCMonitor(): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Get all captured IPC events
|
|
48
|
+
*/
|
|
49
|
+
export declare function getIPCEvents(): Promise<IPCEvent[]>;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../guest-js/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEtF;AAED;;GAEG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,CAEzD;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAE7D;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAErF;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAEvD;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAEtD;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAExD"}
|
package/dist-js/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { invoke } from '@tauri-apps/api/core';
|
|
2
|
+
/**
|
|
3
|
+
* Execute an arbitrary Tauri command
|
|
4
|
+
*/
|
|
5
|
+
export async function executeCommand(command, args) {
|
|
6
|
+
return await invoke('plugin:mcp-bridge|execute_command', { command, args });
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get information about the current window
|
|
10
|
+
*/
|
|
11
|
+
export async function getWindowInfo() {
|
|
12
|
+
return await invoke('plugin:mcp-bridge|get_window_info');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get backend application state
|
|
16
|
+
*/
|
|
17
|
+
export async function getBackendState() {
|
|
18
|
+
return await invoke('plugin:mcp-bridge|get_backend_state');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Emit a custom event for testing
|
|
22
|
+
*/
|
|
23
|
+
export async function emitEvent(eventName, payload) {
|
|
24
|
+
return await invoke('plugin:mcp-bridge|emit_event', { eventName, payload });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Start IPC monitoring - captures all invoke() calls
|
|
28
|
+
*/
|
|
29
|
+
export async function startIPCMonitor() {
|
|
30
|
+
return await invoke('plugin:mcp-bridge|start_ipc_monitor');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Stop IPC monitoring
|
|
34
|
+
*/
|
|
35
|
+
export async function stopIPCMonitor() {
|
|
36
|
+
return await invoke('plugin:mcp-bridge|stop_ipc_monitor');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get all captured IPC events
|
|
40
|
+
*/
|
|
41
|
+
export async function getIPCEvents() {
|
|
42
|
+
return await invoke('plugin:mcp-bridge|get_ipc_events');
|
|
43
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { invoke } from '@tauri-apps/api/core';
|
|
2
|
+
|
|
3
|
+
export interface WindowInfo {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
title: string;
|
|
9
|
+
focused: boolean;
|
|
10
|
+
visible: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BackendState {
|
|
14
|
+
status: string;
|
|
15
|
+
windows: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface IPCEvent {
|
|
19
|
+
timestamp: number;
|
|
20
|
+
command: string;
|
|
21
|
+
args: unknown;
|
|
22
|
+
result?: unknown;
|
|
23
|
+
error?: string;
|
|
24
|
+
duration_ms?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Execute an arbitrary Tauri command
|
|
29
|
+
*/
|
|
30
|
+
export async function executeCommand(command: string, args?: unknown): Promise<unknown> {
|
|
31
|
+
return await invoke('plugin:mcp-bridge|execute_command', { command, args });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get information about the current window
|
|
36
|
+
*/
|
|
37
|
+
export async function getWindowInfo(): Promise<WindowInfo> {
|
|
38
|
+
return await invoke('plugin:mcp-bridge|get_window_info');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get backend application state
|
|
43
|
+
*/
|
|
44
|
+
export async function getBackendState(): Promise<BackendState> {
|
|
45
|
+
return await invoke('plugin:mcp-bridge|get_backend_state');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Emit a custom event for testing
|
|
50
|
+
*/
|
|
51
|
+
export async function emitEvent(eventName: string, payload?: unknown): Promise<string> {
|
|
52
|
+
return await invoke('plugin:mcp-bridge|emit_event', { eventName, payload });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Start IPC monitoring - captures all invoke() calls
|
|
57
|
+
*/
|
|
58
|
+
export async function startIPCMonitor(): Promise<string> {
|
|
59
|
+
return await invoke('plugin:mcp-bridge|start_ipc_monitor');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Stop IPC monitoring
|
|
64
|
+
*/
|
|
65
|
+
export async function stopIPCMonitor(): Promise<string> {
|
|
66
|
+
return await invoke('plugin:mcp-bridge|stop_ipc_monitor');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get all captured IPC events
|
|
71
|
+
*/
|
|
72
|
+
export async function getIPCEvents(): Promise<IPCEvent[]> {
|
|
73
|
+
return await invoke('plugin:mcp-bridge|get_ipc_events');
|
|
74
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"moduleResolution": "bundler",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"target": "ES2021",
|
|
6
|
+
"lib": ["ES2021"],
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": true,
|
|
9
|
+
"outDir": "../dist-js",
|
|
10
|
+
"rootDir": ".",
|
|
11
|
+
"skipLibCheck": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["*.ts"],
|
|
14
|
+
"exclude": ["node_modules"]
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hypothesi/tauri-plugin-mcp-bridge",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "JavaScript bindings for @hypothesi/tauri-plugin-mcp-bridge - MCP Bridge plugin for Tauri",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist-js/index.js",
|
|
7
|
+
"types": "./dist-js/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist-js/index.js",
|
|
11
|
+
"types": "./dist-js/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc --project guest-js/tsconfig.json",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist-js",
|
|
20
|
+
"guest-js",
|
|
21
|
+
"README.md",
|
|
22
|
+
"CHANGELOG.md",
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"package.json"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/hypothesi/mcp-server-tauri.git",
|
|
29
|
+
"directory": "packages/tauri-plugin-mcp-bridge"
|
|
30
|
+
},
|
|
31
|
+
"author": "hypothesi",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"keywords": [
|
|
34
|
+
"tauri",
|
|
35
|
+
"tauri-plugin",
|
|
36
|
+
"mcp",
|
|
37
|
+
"ipc",
|
|
38
|
+
"monitoring"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@tauri-apps/api": "^2.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"typescript": "^5.6.3"
|
|
45
|
+
},
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
}
|
|
49
|
+
}
|