@hypothesi/tauri-mcp-server 0.9.0 → 0.11.0
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/README.md +12 -0
- package/dist/api.d.ts +2 -0
- package/dist/api.js +2 -0
- package/dist/config.d.ts +35 -0
- package/dist/driver/app-discovery.d.ts +75 -0
- package/dist/driver/element-picker.d.ts +42 -0
- package/dist/driver/element-picker.js +6 -6
- package/dist/driver/plugin-client.d.ts +100 -0
- package/dist/driver/plugin-commands.d.ts +163 -0
- package/dist/driver/protocol.d.ts +128 -0
- package/dist/driver/script-manager.d.ts +91 -0
- package/dist/driver/script-manager.js +10 -10
- package/dist/driver/scripts/aria-api-loader.d.ts +17 -0
- package/dist/driver/scripts/html2canvas-loader.d.ts +25 -0
- package/dist/driver/scripts/index.d.ts +37 -0
- package/dist/driver/scripts/index.js +18 -2
- package/dist/driver/scripts/resolve-ref.js +27 -1
- package/dist/driver/session-manager.d.ts +76 -0
- package/dist/driver/webview-executor.d.ts +122 -0
- package/dist/driver/webview-executor.js +52 -28
- package/dist/driver/webview-interactions.d.ts +349 -0
- package/dist/driver/webview-interactions.js +7 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -119
- package/dist/logger.d.ts +16 -0
- package/dist/manager/mobile.d.ts +6 -0
- package/dist/monitor/logs.d.ts +32 -0
- package/dist/prompts-registry.d.ts +30 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +110 -0
- package/dist/tools-registry.d.ts +73 -0
- package/dist/tools-registry.js +1 -0
- package/dist/types/window.d.ts +30 -0
- package/dist/version.d.ts +15 -0
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -52,6 +52,18 @@ npx -y install-mcp @hypothesi/tauri-mcp-server --client claude-code
|
|
|
52
52
|
|
|
53
53
|
Supported clients: `claude-code`, `cursor`, `windsurf`, `vscode`, `cline`, `roo-cline`, `claude`, `zed`, `goose`, `warp`, `codex`
|
|
54
54
|
|
|
55
|
+
## Terminal CLI
|
|
56
|
+
|
|
57
|
+
If you want to call the same tools directly from a shell, install the companion CLI package:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm install -g @hypothesi/tauri-mcp-cli
|
|
61
|
+
tauri-mcp driver-session start --port 9223
|
|
62
|
+
tauri-mcp driver-session status --json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The CLI keeps the underlying MCP server warm in the background so stateful commands such as `driver_session` work across separate invocations.
|
|
66
|
+
|
|
55
67
|
## Multi-App Support
|
|
56
68
|
|
|
57
69
|
The MCP server supports connecting to multiple Tauri apps simultaneously. Each app runs on a unique port, and the most recently connected app becomes the "default" app.
|
package/dist/api.d.ts
ADDED
package/dist/api.js
ADDED
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the MCP Bridge connection.
|
|
3
|
+
*
|
|
4
|
+
* This module provides configuration options for connecting to Tauri apps,
|
|
5
|
+
* with support for environment variables and sensible defaults.
|
|
6
|
+
*/
|
|
7
|
+
export interface BridgeConfig {
|
|
8
|
+
host: string;
|
|
9
|
+
port: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Gets the default host for MCP Bridge connections.
|
|
13
|
+
*
|
|
14
|
+
* Resolution priority:
|
|
15
|
+
* 1. MCP_BRIDGE_HOST environment variable
|
|
16
|
+
* 2. TAURI_DEV_HOST environment variable (set by Tauri CLI for mobile dev)
|
|
17
|
+
* 3. 'localhost' (default)
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDefaultHost(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the default port for MCP Bridge connections.
|
|
22
|
+
*
|
|
23
|
+
* Resolution priority:
|
|
24
|
+
* 1. MCP_BRIDGE_PORT environment variable
|
|
25
|
+
* 2. 9223 (default)
|
|
26
|
+
*/
|
|
27
|
+
export declare function getDefaultPort(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the full bridge configuration from environment variables.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getConfig(): BridgeConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Builds a WebSocket URL from host and port.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildWebSocketURL(host: string, port: number): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App discovery and session management for multiple Tauri instances.
|
|
3
|
+
*
|
|
4
|
+
* This module handles discovering and connecting to multiple Tauri apps
|
|
5
|
+
* running with MCP Bridge on the same machine or remote devices using port scanning.
|
|
6
|
+
*/
|
|
7
|
+
import { PluginClient } from './plugin-client.js';
|
|
8
|
+
export interface AppInstance {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
available: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface SessionInfo {
|
|
14
|
+
appId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
host: string;
|
|
17
|
+
port: number;
|
|
18
|
+
client?: PluginClient;
|
|
19
|
+
connected: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Manages discovery and connection to multiple Tauri app instances
|
|
23
|
+
*/
|
|
24
|
+
export declare class AppDiscovery {
|
|
25
|
+
private _activeSessions;
|
|
26
|
+
private _host;
|
|
27
|
+
private _basePort;
|
|
28
|
+
private _maxPorts;
|
|
29
|
+
constructor(host?: string, basePort?: number);
|
|
30
|
+
/**
|
|
31
|
+
* Gets the configured host.
|
|
32
|
+
*/
|
|
33
|
+
get host(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the host for discovery.
|
|
36
|
+
*/
|
|
37
|
+
setHost(host: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Discovers available Tauri app instances by scanning ports
|
|
40
|
+
*/
|
|
41
|
+
discoverApps(): Promise<AppInstance[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Connects to a specific app on a host and port
|
|
44
|
+
*/
|
|
45
|
+
connectToPort(port: number, appName?: string, host?: string): Promise<SessionInfo>;
|
|
46
|
+
/**
|
|
47
|
+
* Gets the first available app
|
|
48
|
+
*/
|
|
49
|
+
getFirstAvailableApp(): Promise<AppInstance | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Disconnects from a specific session
|
|
52
|
+
*/
|
|
53
|
+
disconnectSession(sessionId: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Disconnects from all apps
|
|
56
|
+
*/
|
|
57
|
+
disconnectAll(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets the active session by ID
|
|
60
|
+
*/
|
|
61
|
+
getSession(sessionId: string): SessionInfo | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Gets all active sessions
|
|
64
|
+
*/
|
|
65
|
+
getAllSessions(): SessionInfo[];
|
|
66
|
+
/**
|
|
67
|
+
* Try to connect to the default port
|
|
68
|
+
*/
|
|
69
|
+
connectToDefaultPort(): Promise<SessionInfo>;
|
|
70
|
+
/**
|
|
71
|
+
* Check if a port is in use (likely a Tauri app)
|
|
72
|
+
*/
|
|
73
|
+
private _isPortInUse;
|
|
74
|
+
}
|
|
75
|
+
export declare const appDiscovery: AppDiscovery;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Element picker module for MCP Server Tauri.
|
|
3
|
+
*
|
|
4
|
+
* Provides two tools:
|
|
5
|
+
* - selectElement: Agent-initiated picker overlay (user clicks element)
|
|
6
|
+
* - getPointedElement: Retrieve element user pointed at via Alt+Shift+Click
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import type { ToolContent } from '../tools-registry.js';
|
|
10
|
+
export declare const SelectElementSchema: z.ZodObject<{
|
|
11
|
+
windowId: z.ZodOptional<z.ZodString>;
|
|
12
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
13
|
+
} & {
|
|
14
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
timeout: number;
|
|
17
|
+
windowId?: string | undefined;
|
|
18
|
+
appIdentifier?: string | number | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
windowId?: string | undefined;
|
|
21
|
+
appIdentifier?: string | number | undefined;
|
|
22
|
+
timeout?: number | undefined;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const GetPointedElementSchema: z.ZodObject<{
|
|
25
|
+
windowId: z.ZodOptional<z.ZodString>;
|
|
26
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
windowId?: string | undefined;
|
|
29
|
+
appIdentifier?: string | number | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
windowId?: string | undefined;
|
|
32
|
+
appIdentifier?: string | number | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function selectElement(options: {
|
|
35
|
+
timeout?: number;
|
|
36
|
+
windowId?: string;
|
|
37
|
+
appIdentifier?: string | number;
|
|
38
|
+
}): Promise<ToolContent[]>;
|
|
39
|
+
export declare function getPointedElement(options: {
|
|
40
|
+
windowId?: string;
|
|
41
|
+
appIdentifier?: string | number;
|
|
42
|
+
}): Promise<ToolContent[]>;
|
|
@@ -99,13 +99,13 @@ async function cleanupPickerHighlights(windowId, appIdentifier) {
|
|
|
99
99
|
* Capture a screenshot of a specific element using html2canvas.
|
|
100
100
|
* Returns the base64 data URL of the cropped element image, or null on failure.
|
|
101
101
|
*/
|
|
102
|
-
async function captureElementScreenshot(cssSelector, windowId) {
|
|
102
|
+
async function captureElementScreenshot(cssSelector, windowId, appIdentifier) {
|
|
103
103
|
// Ensure html2canvas is loaded in the webview
|
|
104
104
|
try {
|
|
105
|
-
const isRegistered = await isScriptRegistered(HTML2CANVAS_SCRIPT_ID);
|
|
105
|
+
const isRegistered = await isScriptRegistered(HTML2CANVAS_SCRIPT_ID, appIdentifier);
|
|
106
106
|
if (!isRegistered) {
|
|
107
107
|
const source = getHtml2CanvasSource();
|
|
108
|
-
await registerScript(HTML2CANVAS_SCRIPT_ID, 'inline', source);
|
|
108
|
+
await registerScript(HTML2CANVAS_SCRIPT_ID, 'inline', source, windowId, appIdentifier);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
catch {
|
|
@@ -149,7 +149,7 @@ async function captureElementScreenshot(cssSelector, windowId) {
|
|
|
149
149
|
return dataUrl;
|
|
150
150
|
`;
|
|
151
151
|
try {
|
|
152
|
-
const dataUrl = await executeAsyncInWebview(captureScript, windowId, 10000);
|
|
152
|
+
const dataUrl = await executeAsyncInWebview(captureScript, windowId, 10000, appIdentifier);
|
|
153
153
|
if (!dataUrl || !dataUrl.startsWith('data:image/')) {
|
|
154
154
|
return null;
|
|
155
155
|
}
|
|
@@ -221,7 +221,7 @@ export async function selectElement(options) {
|
|
|
221
221
|
// Add formatted metadata
|
|
222
222
|
content.push({ type: 'text', text: formatElementMetadata(element) });
|
|
223
223
|
// Capture element-only screenshot (no picker overlays visible)
|
|
224
|
-
const screenshot = await captureElementScreenshot(element.cssSelector, windowId);
|
|
224
|
+
const screenshot = await captureElementScreenshot(element.cssSelector, windowId, appIdentifier);
|
|
225
225
|
if (screenshot) {
|
|
226
226
|
content.push(screenshot);
|
|
227
227
|
}
|
|
@@ -261,7 +261,7 @@ export async function getPointedElement(options) {
|
|
|
261
261
|
// Add formatted metadata
|
|
262
262
|
content.push({ type: 'text', text: formatElementMetadata(element) });
|
|
263
263
|
// Capture element-only screenshot (no overlays)
|
|
264
|
-
const screenshot = await captureElementScreenshot(element.cssSelector, windowId);
|
|
264
|
+
const screenshot = await captureElementScreenshot(element.cssSelector, windowId, appIdentifier);
|
|
265
265
|
if (screenshot) {
|
|
266
266
|
content.push(screenshot);
|
|
267
267
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
interface PluginCommand {
|
|
3
|
+
id?: string;
|
|
4
|
+
command: string;
|
|
5
|
+
args?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface PluginResponse {
|
|
8
|
+
id?: string;
|
|
9
|
+
success: boolean;
|
|
10
|
+
data?: unknown;
|
|
11
|
+
error?: string;
|
|
12
|
+
windowContext?: {
|
|
13
|
+
windowLabel: string;
|
|
14
|
+
totalWindows: number;
|
|
15
|
+
warning?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Client to communicate with the MCP Bridge plugin's WebSocket server
|
|
20
|
+
*/
|
|
21
|
+
export declare class PluginClient extends EventEmitter {
|
|
22
|
+
private _ws;
|
|
23
|
+
private _url;
|
|
24
|
+
private _host;
|
|
25
|
+
private _port;
|
|
26
|
+
private _reconnectAttempts;
|
|
27
|
+
private _shouldReconnect;
|
|
28
|
+
private _reconnectDelay;
|
|
29
|
+
private _pendingRequests;
|
|
30
|
+
/**
|
|
31
|
+
* Constructor for PluginClient
|
|
32
|
+
* @param host Host address of the WebSocket server
|
|
33
|
+
* @param port Port number of the WebSocket server
|
|
34
|
+
*/
|
|
35
|
+
constructor(host: string, port: number);
|
|
36
|
+
/**
|
|
37
|
+
* Creates a PluginClient with default configuration from environment.
|
|
38
|
+
*/
|
|
39
|
+
static create_default(): PluginClient;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the host this client is configured to connect to.
|
|
42
|
+
*/
|
|
43
|
+
get host(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the port this client is configured to connect to.
|
|
46
|
+
*/
|
|
47
|
+
get port(): number;
|
|
48
|
+
/**
|
|
49
|
+
* Connect to the plugin's WebSocket server
|
|
50
|
+
*/
|
|
51
|
+
connect(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Disconnect from the plugin
|
|
54
|
+
*/
|
|
55
|
+
disconnect(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Send a command to the plugin and wait for response.
|
|
58
|
+
*
|
|
59
|
+
* Automatically retries on transient "not found" errors (e.g. window not
|
|
60
|
+
* yet registered after WebSocket connect) with exponential backoff.
|
|
61
|
+
*/
|
|
62
|
+
sendCommand(command: PluginCommand, timeoutMs?: number): Promise<PluginResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Check if connected
|
|
65
|
+
*/
|
|
66
|
+
isConnected(): boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the existing singleton PluginClient without creating or modifying it.
|
|
70
|
+
* Use this for status checks where you don't want to affect the current connection.
|
|
71
|
+
*
|
|
72
|
+
* @returns The existing PluginClient or null if none exists
|
|
73
|
+
*/
|
|
74
|
+
export declare function getExistingPluginClient(): PluginClient | null;
|
|
75
|
+
/**
|
|
76
|
+
* Gets or creates a singleton PluginClient.
|
|
77
|
+
*
|
|
78
|
+
* If host/port are provided and differ from the existing client's configuration,
|
|
79
|
+
* the existing client is disconnected and a new one is created. This ensures
|
|
80
|
+
* that session start with a specific port always uses that port.
|
|
81
|
+
*
|
|
82
|
+
* @param host Optional host override
|
|
83
|
+
* @param port Optional port override
|
|
84
|
+
*/
|
|
85
|
+
export declare function getPluginClient(host?: string, port?: number): PluginClient;
|
|
86
|
+
/**
|
|
87
|
+
* Resets the singleton client (useful for reconnecting with different config).
|
|
88
|
+
*/
|
|
89
|
+
export declare function resetPluginClient(): void;
|
|
90
|
+
export declare function connectPlugin(host?: string, port?: number): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Ensures a session is active and connects to the plugin using session config.
|
|
93
|
+
* This should be used by all tools that require a connected Tauri app.
|
|
94
|
+
*
|
|
95
|
+
* @param appIdentifier - Optional app identifier to target specific app
|
|
96
|
+
* @throws Error if no session is active
|
|
97
|
+
*/
|
|
98
|
+
export declare function ensureSessionAndConnect(appIdentifier?: string | number): Promise<PluginClient>;
|
|
99
|
+
export declare function disconnectPlugin(): Promise<void>;
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ExecuteIPCCommandSchema: z.ZodObject<{
|
|
3
|
+
command: z.ZodString;
|
|
4
|
+
args: z.ZodOptional<z.ZodUnknown>;
|
|
5
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
command: string;
|
|
8
|
+
appIdentifier?: string | number | undefined;
|
|
9
|
+
args?: unknown;
|
|
10
|
+
}, {
|
|
11
|
+
command: string;
|
|
12
|
+
appIdentifier?: string | number | undefined;
|
|
13
|
+
args?: unknown;
|
|
14
|
+
}>;
|
|
15
|
+
export declare function executeIPCCommand(options: {
|
|
16
|
+
command: string;
|
|
17
|
+
args?: unknown;
|
|
18
|
+
appIdentifier?: string | number;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
export declare const ManageIPCMonitoringSchema: z.ZodObject<{
|
|
21
|
+
action: z.ZodEnum<["start", "stop"]>;
|
|
22
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
action: "start" | "stop";
|
|
25
|
+
appIdentifier?: string | number | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
action: "start" | "stop";
|
|
28
|
+
appIdentifier?: string | number | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const StartIPCMonitoringSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
31
|
+
export declare const StopIPCMonitoringSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
32
|
+
export declare function manageIPCMonitoring(action: 'start' | 'stop', appIdentifier?: string | number): Promise<string>;
|
|
33
|
+
export declare function startIPCMonitoring(appIdentifier?: string | number): Promise<string>;
|
|
34
|
+
export declare function stopIPCMonitoring(appIdentifier?: string | number): Promise<string>;
|
|
35
|
+
export declare const GetIPCEventsSchema: z.ZodObject<{
|
|
36
|
+
filter: z.ZodOptional<z.ZodString>;
|
|
37
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
filter?: string | undefined;
|
|
40
|
+
appIdentifier?: string | number | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
filter?: string | undefined;
|
|
43
|
+
appIdentifier?: string | number | undefined;
|
|
44
|
+
}>;
|
|
45
|
+
export declare function getIPCEvents(filter?: string, appIdentifier?: string | number): Promise<string>;
|
|
46
|
+
export declare const EmitTestEventSchema: z.ZodObject<{
|
|
47
|
+
eventName: z.ZodString;
|
|
48
|
+
payload: z.ZodUnknown;
|
|
49
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
eventName: string;
|
|
52
|
+
appIdentifier?: string | number | undefined;
|
|
53
|
+
payload?: unknown;
|
|
54
|
+
}, {
|
|
55
|
+
eventName: string;
|
|
56
|
+
appIdentifier?: string | number | undefined;
|
|
57
|
+
payload?: unknown;
|
|
58
|
+
}>;
|
|
59
|
+
export declare function emitTestEvent(eventName: string, payload: unknown, appIdentifier?: string | number): Promise<string>;
|
|
60
|
+
export declare const GetWindowInfoSchema: z.ZodObject<{
|
|
61
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
appIdentifier?: string | number | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
appIdentifier?: string | number | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
export declare function getWindowInfo(appIdentifier?: string | number): Promise<string>;
|
|
68
|
+
export declare const GetBackendStateSchema: z.ZodObject<{
|
|
69
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
appIdentifier?: string | number | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
appIdentifier?: string | number | undefined;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Get backend state from the connected Tauri app.
|
|
77
|
+
*
|
|
78
|
+
* This function can work in two modes:
|
|
79
|
+
* 1. Normal mode: Requires an active session (for MCP tool calls)
|
|
80
|
+
* 2. Setup mode: Uses existing connected client (for session setup)
|
|
81
|
+
*
|
|
82
|
+
* @param useExistingClient If true, uses the existing connected client without
|
|
83
|
+
* session validation. Used during session setup before currentSession is set.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getBackendState(options?: {
|
|
86
|
+
useExistingClient?: boolean;
|
|
87
|
+
appIdentifier?: string | number;
|
|
88
|
+
}): Promise<string>;
|
|
89
|
+
export declare const ListWindowsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
90
|
+
/**
|
|
91
|
+
* Lists all open webview windows in the Tauri application.
|
|
92
|
+
*/
|
|
93
|
+
export declare function listWindows(appIdentifier?: string | number): Promise<string>;
|
|
94
|
+
export declare const ResizeWindowSchema: z.ZodObject<{
|
|
95
|
+
width: z.ZodNumber;
|
|
96
|
+
height: z.ZodNumber;
|
|
97
|
+
windowId: z.ZodOptional<z.ZodString>;
|
|
98
|
+
logical: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
width: number;
|
|
101
|
+
height: number;
|
|
102
|
+
logical: boolean;
|
|
103
|
+
windowId?: string | undefined;
|
|
104
|
+
}, {
|
|
105
|
+
width: number;
|
|
106
|
+
height: number;
|
|
107
|
+
windowId?: string | undefined;
|
|
108
|
+
logical?: boolean | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Resizes a window to the specified dimensions.
|
|
112
|
+
*
|
|
113
|
+
* @param options - Resize options including width, height, and optional windowId
|
|
114
|
+
* @returns JSON string with the result of the resize operation
|
|
115
|
+
*/
|
|
116
|
+
export declare function resizeWindow(options: {
|
|
117
|
+
width: number;
|
|
118
|
+
height: number;
|
|
119
|
+
windowId?: string;
|
|
120
|
+
logical?: boolean;
|
|
121
|
+
appIdentifier?: string | number;
|
|
122
|
+
}): Promise<string>;
|
|
123
|
+
export declare const ManageWindowSchema: z.ZodObject<{
|
|
124
|
+
action: z.ZodEnum<["list", "info", "resize"]>;
|
|
125
|
+
windowId: z.ZodOptional<z.ZodString>;
|
|
126
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
127
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
logical: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
129
|
+
appIdentifier: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
action: "list" | "info" | "resize";
|
|
132
|
+
logical: boolean;
|
|
133
|
+
windowId?: string | undefined;
|
|
134
|
+
appIdentifier?: string | number | undefined;
|
|
135
|
+
width?: number | undefined;
|
|
136
|
+
height?: number | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
action: "list" | "info" | "resize";
|
|
139
|
+
windowId?: string | undefined;
|
|
140
|
+
appIdentifier?: string | number | undefined;
|
|
141
|
+
width?: number | undefined;
|
|
142
|
+
height?: number | undefined;
|
|
143
|
+
logical?: boolean | undefined;
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* Unified window management function.
|
|
147
|
+
*
|
|
148
|
+
* Actions:
|
|
149
|
+
* - `list`: List all open webview windows with their labels, titles, URLs, and state
|
|
150
|
+
* - `info`: Get detailed info for a window (size, position, title, focus, visibility)
|
|
151
|
+
* - `resize`: Resize a window to specified dimensions
|
|
152
|
+
*
|
|
153
|
+
* @param options - Action and parameters
|
|
154
|
+
* @returns JSON string with the result
|
|
155
|
+
*/
|
|
156
|
+
export declare function manageWindow(options: {
|
|
157
|
+
action: 'list' | 'info' | 'resize';
|
|
158
|
+
windowId?: string;
|
|
159
|
+
width?: number;
|
|
160
|
+
height?: number;
|
|
161
|
+
logical?: boolean;
|
|
162
|
+
appIdentifier?: string | number;
|
|
163
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket protocol types for communication between MCP server and Tauri plugin
|
|
3
|
+
*
|
|
4
|
+
* This file defines the message format for the WebSocket-based communication
|
|
5
|
+
* between the Node.js MCP server and the Rust Tauri plugin.
|
|
6
|
+
*/
|
|
7
|
+
/** Commands that can be sent to the Tauri plugin */
|
|
8
|
+
export type PluginCommandType = 'execute_command' | 'get_window_info' | 'get_backend_state' | 'emit_event' | 'start_ipc_monitor' | 'stop_ipc_monitor' | 'get_ipc_events' | 'execute_js' | 'capture_native_screenshot';
|
|
9
|
+
/** Request message sent from MCP server to Tauri plugin */
|
|
10
|
+
export interface PluginRequest {
|
|
11
|
+
id: string;
|
|
12
|
+
command: PluginCommandType;
|
|
13
|
+
args?: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** Response message sent from Tauri plugin to MCP server */
|
|
16
|
+
export interface PluginResponse {
|
|
17
|
+
id: string;
|
|
18
|
+
success: boolean;
|
|
19
|
+
data?: unknown;
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
/** Event broadcast from Tauri plugin (not in response to a request) */
|
|
23
|
+
export interface PluginEvent {
|
|
24
|
+
type: 'ipc_event' | 'console_log' | 'error' | 'element_picked' | 'element_pointed';
|
|
25
|
+
payload: unknown;
|
|
26
|
+
timestamp?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Structured info about a parent element in the DOM ancestry */
|
|
29
|
+
export interface ParentElementInfo {
|
|
30
|
+
tag: string;
|
|
31
|
+
id: string | null;
|
|
32
|
+
classes: string[];
|
|
33
|
+
boundingRect: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Metadata collected about a picked/pointed DOM element */
|
|
41
|
+
export interface ElementMetadata {
|
|
42
|
+
tag: string;
|
|
43
|
+
id: string | null;
|
|
44
|
+
classes: string[];
|
|
45
|
+
attributes: Record<string, string>;
|
|
46
|
+
textContent: string;
|
|
47
|
+
boundingRect: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
top: number;
|
|
53
|
+
right: number;
|
|
54
|
+
bottom: number;
|
|
55
|
+
left: number;
|
|
56
|
+
};
|
|
57
|
+
cssSelector: string;
|
|
58
|
+
xpath: string;
|
|
59
|
+
computedStyles: Record<string, string>;
|
|
60
|
+
parentChain: ParentElementInfo[];
|
|
61
|
+
timestamp: number;
|
|
62
|
+
}
|
|
63
|
+
/** Broadcast message for element picker events */
|
|
64
|
+
export interface ElementPickerBroadcast {
|
|
65
|
+
type: 'element_picked' | 'element_pointed';
|
|
66
|
+
payload: {
|
|
67
|
+
pickerId?: string;
|
|
68
|
+
element?: ElementMetadata;
|
|
69
|
+
cancelled?: boolean;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** IPC event captured by the monitor */
|
|
73
|
+
export interface IPCEvent {
|
|
74
|
+
command: string;
|
|
75
|
+
args?: unknown;
|
|
76
|
+
response?: unknown;
|
|
77
|
+
duration?: number;
|
|
78
|
+
timestamp: string;
|
|
79
|
+
}
|
|
80
|
+
/** Window information returned by get_window_info */
|
|
81
|
+
export interface WindowInfo {
|
|
82
|
+
width: number;
|
|
83
|
+
height: number;
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
title: string;
|
|
87
|
+
focused: boolean;
|
|
88
|
+
visible: boolean;
|
|
89
|
+
}
|
|
90
|
+
/** Backend state returned by get_backend_state */
|
|
91
|
+
export interface BackendState {
|
|
92
|
+
app: {
|
|
93
|
+
name: string;
|
|
94
|
+
identifier: string;
|
|
95
|
+
version: string;
|
|
96
|
+
};
|
|
97
|
+
tauri: {
|
|
98
|
+
version: string;
|
|
99
|
+
};
|
|
100
|
+
environment: {
|
|
101
|
+
debug: boolean;
|
|
102
|
+
os: string;
|
|
103
|
+
arch: string;
|
|
104
|
+
family: string;
|
|
105
|
+
};
|
|
106
|
+
windows: Array<{
|
|
107
|
+
label: string;
|
|
108
|
+
title: string;
|
|
109
|
+
focused: boolean;
|
|
110
|
+
visible: boolean;
|
|
111
|
+
}>;
|
|
112
|
+
window_count: number;
|
|
113
|
+
timestamp: number;
|
|
114
|
+
}
|
|
115
|
+
/** Console log entry */
|
|
116
|
+
export interface ConsoleLogEntry {
|
|
117
|
+
level: 'log' | 'info' | 'warn' | 'error' | 'debug';
|
|
118
|
+
message: string;
|
|
119
|
+
timestamp: string;
|
|
120
|
+
source?: string;
|
|
121
|
+
}
|
|
122
|
+
/** Screenshot result */
|
|
123
|
+
export interface ScreenshotResult {
|
|
124
|
+
data: string;
|
|
125
|
+
format: 'png' | 'jpeg';
|
|
126
|
+
width?: number;
|
|
127
|
+
height?: number;
|
|
128
|
+
}
|