@hypothesi/tauri-mcp-server 0.8.3 → 0.10.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 +16 -2
- 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 +272 -0
- 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/scripts/aria-api-loader.d.ts +17 -0
- package/dist/driver/scripts/element-picker.js +395 -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 +1 -0
- package/dist/driver/session-manager.d.ts +76 -0
- package/dist/driver/webview-executor.d.ts +122 -0
- package/dist/driver/webview-interactions.d.ts +349 -0
- 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/prompts-registry.js +46 -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 +51 -0
- package/dist/types/window.d.ts +30 -0
- package/dist/version.d.ts +15 -0
- package/package.json +9 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Script Manager - Manages persistent script injection across page navigations.
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to register, remove, and manage scripts that
|
|
5
|
+
* should be automatically re-injected when pages load or navigate.
|
|
6
|
+
*
|
|
7
|
+
* @internal This module is for internal use only and is not exposed as MCP tools.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Type of script to inject.
|
|
11
|
+
*/
|
|
12
|
+
export type ScriptType = 'inline' | 'url';
|
|
13
|
+
/**
|
|
14
|
+
* A script entry in the registry.
|
|
15
|
+
*/
|
|
16
|
+
export interface ScriptEntry {
|
|
17
|
+
/** Unique identifier for this script. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Type of script (inline code or external URL). */
|
|
20
|
+
type: ScriptType;
|
|
21
|
+
/** The script content (JavaScript code) or URL. */
|
|
22
|
+
content: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Response from script registration.
|
|
26
|
+
*/
|
|
27
|
+
interface RegisterScriptResponse {
|
|
28
|
+
registered: boolean;
|
|
29
|
+
scriptId: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Response from script removal.
|
|
33
|
+
*/
|
|
34
|
+
interface RemoveScriptResponse {
|
|
35
|
+
removed: boolean;
|
|
36
|
+
scriptId: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Response from clearing scripts.
|
|
40
|
+
*/
|
|
41
|
+
interface ClearScriptsResponse {
|
|
42
|
+
cleared: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Response from getting scripts.
|
|
46
|
+
*/
|
|
47
|
+
interface GetScriptsResponse {
|
|
48
|
+
scripts: ScriptEntry[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Registers a script to be injected into the webview.
|
|
52
|
+
*
|
|
53
|
+
* The script will be immediately injected if the page is loaded, and will be
|
|
54
|
+
* automatically re-injected on subsequent page loads/navigations.
|
|
55
|
+
*
|
|
56
|
+
* @param id - Unique identifier for the script
|
|
57
|
+
* @param type - Type of script ('inline' for code, 'url' for external script)
|
|
58
|
+
* @param content - The script content (JavaScript code) or URL
|
|
59
|
+
* @param windowLabel - Optional window label to target
|
|
60
|
+
* @returns Promise resolving to registration result
|
|
61
|
+
*/
|
|
62
|
+
export declare function registerScript(id: string, type: ScriptType, content: string, windowLabel?: string): Promise<RegisterScriptResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Removes a script from the registry and DOM.
|
|
65
|
+
*
|
|
66
|
+
* @param id - The script ID to remove
|
|
67
|
+
* @param windowLabel - Optional window label to target
|
|
68
|
+
* @returns Promise resolving to removal result
|
|
69
|
+
*/
|
|
70
|
+
export declare function removeScript(id: string, windowLabel?: string): Promise<RemoveScriptResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Clears all registered scripts from the registry and DOM.
|
|
73
|
+
*
|
|
74
|
+
* @param windowLabel - Optional window label to target
|
|
75
|
+
* @returns Promise resolving to the number of scripts cleared
|
|
76
|
+
*/
|
|
77
|
+
export declare function clearScripts(windowLabel?: string): Promise<ClearScriptsResponse>;
|
|
78
|
+
/**
|
|
79
|
+
* Gets all registered scripts.
|
|
80
|
+
*
|
|
81
|
+
* @returns Promise resolving to the list of registered scripts
|
|
82
|
+
*/
|
|
83
|
+
export declare function getScripts(): Promise<GetScriptsResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Checks if a script with the given ID is registered.
|
|
86
|
+
*
|
|
87
|
+
* @param id - The script ID to check
|
|
88
|
+
* @returns Promise resolving to true if the script is registered
|
|
89
|
+
*/
|
|
90
|
+
export declare function isScriptRegistered(id: string): Promise<boolean>;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* aria-api library loader
|
|
3
|
+
*
|
|
4
|
+
* Bundles aria-api for browser injection. Provides comprehensive W3C-compliant
|
|
5
|
+
* accessibility computation including:
|
|
6
|
+
* - WAI-ARIA 1.3 role computation
|
|
7
|
+
* - HTML-AAM 1.0 implicit role mappings
|
|
8
|
+
* - Accessible Name and Description Computation 1.2
|
|
9
|
+
* - aria-owns relationship handling
|
|
10
|
+
*/
|
|
11
|
+
/** Script ID used for the aria-api library in the script registry. */
|
|
12
|
+
export declare const ARIA_API_SCRIPT_ID = "__mcp_aria_api__";
|
|
13
|
+
/**
|
|
14
|
+
* Get the aria-api library source code.
|
|
15
|
+
* Loaded lazily and cached.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAriaApiSource(): string;
|