@hypothesi/tauri-mcp-server 0.1.1

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.
@@ -0,0 +1,292 @@
1
+ /**
2
+ * Single source of truth for all MCP tool definitions
3
+ * This file defines all available tools and their metadata
4
+ */
5
+ import { runTauriCommand, RunCommandSchema } from './manager/cli.js';
6
+ import { readConfig, writeConfig, ReadConfigSchema, WriteConfigSchema } from './manager/config.js';
7
+ import { listDevices, launchEmulator, ListDevicesSchema, LaunchEmulatorSchema } from './manager/mobile.js';
8
+ import { manageDriverSession, ManageDriverSessionSchema, } from './driver/session-manager.js';
9
+ import { readLogs, ReadLogsSchema } from './monitor/logs.js';
10
+ import { getDocs, GetDocsSchema } from './manager/docs.js';
11
+ import { executeIPCCommand, getWindowInfo, manageIPCMonitoring, getIPCEvents, emitTestEvent, getBackendState, ExecuteIPCCommandSchema, GetWindowInfoSchema, ManageIPCMonitoringSchema, GetIPCEventsSchema, EmitTestEventSchema, GetBackendStateSchema, } from './driver/plugin-commands.js';
12
+ import { interact, screenshot, keyboard, waitFor, getStyles, executeJavaScript, focusElement, findElement, getConsoleLogs, InteractSchema, ScreenshotSchema, KeyboardSchema, WaitForSchema, GetStylesSchema, ExecuteJavaScriptSchema, FocusElementSchema, FindElementSchema, GetConsoleLogsSchema, } from './driver/webview-interactions.js';
13
+ /**
14
+ * Tool categories for organization
15
+ */
16
+ export const TOOL_CATEGORIES = {
17
+ PROJECT_MANAGEMENT: 'Project Management',
18
+ MOBILE_DEVELOPMENT: 'Mobile Development',
19
+ UI_AUTOMATION: 'UI Automation & WebView Interaction',
20
+ IPC_PLUGIN: 'IPC & Plugin Tools (via MCP Bridge)',
21
+ };
22
+ /**
23
+ * Complete registry of all available tools
24
+ * This is the single source of truth for tool definitions
25
+ */
26
+ export const TOOLS = [
27
+ // Project Management Tools
28
+ {
29
+ name: 'tauri_run_command',
30
+ description: 'Run any Tauri CLI command with full flexibility',
31
+ category: TOOL_CATEGORIES.PROJECT_MANAGEMENT,
32
+ schema: RunCommandSchema,
33
+ handler: async (args) => {
34
+ const parsed = RunCommandSchema.parse(args);
35
+ return await runTauriCommand(parsed.command, parsed.cwd, parsed.args || [], parsed.timeout);
36
+ },
37
+ },
38
+ {
39
+ name: 'tauri_read_config',
40
+ description: 'Read Tauri configuration files (including platform-specific configs)',
41
+ category: TOOL_CATEGORIES.PROJECT_MANAGEMENT,
42
+ schema: ReadConfigSchema,
43
+ handler: async (args) => {
44
+ const parsed = ReadConfigSchema.parse(args);
45
+ return await readConfig(parsed.projectPath, parsed.file);
46
+ },
47
+ },
48
+ {
49
+ name: 'tauri_write_config',
50
+ description: 'Write to Tauri configuration files with validation',
51
+ category: TOOL_CATEGORIES.PROJECT_MANAGEMENT,
52
+ schema: WriteConfigSchema,
53
+ handler: async (args) => {
54
+ const parsed = WriteConfigSchema.parse(args);
55
+ return await writeConfig(parsed.projectPath, parsed.file, parsed.content);
56
+ },
57
+ },
58
+ {
59
+ name: 'tauri_get_docs',
60
+ description: 'Get Tauri documentation (LLM Cheat Sheet)',
61
+ category: TOOL_CATEGORIES.PROJECT_MANAGEMENT,
62
+ schema: GetDocsSchema,
63
+ handler: async (args) => {
64
+ const parsed = GetDocsSchema.parse(args);
65
+ return await getDocs(parsed.projectPath);
66
+ },
67
+ },
68
+ // Mobile Development Tools
69
+ {
70
+ name: 'tauri_list_devices',
71
+ description: 'List Android devices and iOS simulators',
72
+ category: TOOL_CATEGORIES.MOBILE_DEVELOPMENT,
73
+ schema: ListDevicesSchema,
74
+ handler: async () => {
75
+ const devices = await listDevices();
76
+ return `Android Devices:\n${devices.android.join('\n') || 'None'}\n\niOS Booted Simulators:\n${devices.ios.join('\n') || 'None'}`;
77
+ },
78
+ },
79
+ {
80
+ name: 'tauri_launch_emulator',
81
+ description: 'Launch Android AVD or iOS Simulator',
82
+ category: TOOL_CATEGORIES.MOBILE_DEVELOPMENT,
83
+ schema: LaunchEmulatorSchema,
84
+ handler: async (args) => {
85
+ const parsed = LaunchEmulatorSchema.parse(args);
86
+ return await launchEmulator(parsed.platform, parsed.name);
87
+ },
88
+ },
89
+ // UI Automation Tools
90
+ {
91
+ name: 'tauri_driver_session',
92
+ description: 'Manage automation session (start or stop). Supports remote device connections via host parameter.',
93
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
94
+ schema: ManageDriverSessionSchema,
95
+ handler: async (args) => {
96
+ const parsed = ManageDriverSessionSchema.parse(args);
97
+ return await manageDriverSession(parsed.action, parsed.host, parsed.port);
98
+ },
99
+ },
100
+ {
101
+ name: 'tauri_webview_find_element',
102
+ description: 'Find elements',
103
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
104
+ schema: FindElementSchema,
105
+ handler: async (args) => {
106
+ const parsed = FindElementSchema.parse(args);
107
+ return await findElement(parsed.selector, parsed.strategy);
108
+ },
109
+ },
110
+ {
111
+ name: 'tauri_driver_get_console_logs',
112
+ description: 'Get console logs',
113
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
114
+ schema: GetConsoleLogsSchema,
115
+ handler: async (args) => {
116
+ const parsed = GetConsoleLogsSchema.parse(args);
117
+ return await getConsoleLogs(parsed.filter, parsed.since);
118
+ },
119
+ },
120
+ {
121
+ name: 'tauri_read_platform_logs',
122
+ description: 'Read platform logs (Android logcat, iOS device logs, or system logs)',
123
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
124
+ schema: ReadLogsSchema,
125
+ handler: async (args) => {
126
+ const parsed = ReadLogsSchema.parse(args);
127
+ return await readLogs(parsed.source, parsed.lines, parsed.filter, parsed.since);
128
+ },
129
+ },
130
+ // WebView Interaction Tools
131
+ {
132
+ name: 'tauri_webview_interact',
133
+ description: 'Perform gestures (click, double-click, long-press, swipe) or scroll',
134
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
135
+ schema: InteractSchema,
136
+ handler: async (args) => {
137
+ const parsed = InteractSchema.parse(args);
138
+ return await interact(parsed);
139
+ },
140
+ },
141
+ {
142
+ name: 'tauri_webview_screenshot',
143
+ description: 'Take a screenshot of the current viewport (visible area) of the webview. ' +
144
+ '**Important**: This only captures what is currently visible. ' +
145
+ 'Scroll content into view before taking screenshots if you need to capture specific elements.',
146
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
147
+ schema: ScreenshotSchema,
148
+ handler: async (args) => {
149
+ const parsed = ScreenshotSchema.parse(args);
150
+ return await screenshot(parsed.quality, parsed.format);
151
+ },
152
+ },
153
+ {
154
+ name: 'tauri_webview_keyboard',
155
+ description: 'Type text or simulate keyboard events',
156
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
157
+ schema: KeyboardSchema,
158
+ handler: async (args) => {
159
+ const parsed = KeyboardSchema.parse(args);
160
+ if (parsed.action === 'type') {
161
+ return await keyboard(parsed.action, parsed.selector, parsed.text);
162
+ }
163
+ return await keyboard(parsed.action, parsed.key, parsed.modifiers);
164
+ },
165
+ },
166
+ {
167
+ name: 'tauri_webview_wait_for',
168
+ description: 'Wait for elements, text, or events',
169
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
170
+ schema: WaitForSchema,
171
+ handler: async (args) => {
172
+ const parsed = WaitForSchema.parse(args);
173
+ return await waitFor(parsed.type, parsed.value, parsed.timeout);
174
+ },
175
+ },
176
+ {
177
+ name: 'tauri_webview_get_styles',
178
+ description: 'Get computed CSS styles',
179
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
180
+ schema: GetStylesSchema,
181
+ handler: async (args) => {
182
+ const parsed = GetStylesSchema.parse(args);
183
+ return await getStyles(parsed.selector, parsed.properties, parsed.multiple);
184
+ },
185
+ },
186
+ {
187
+ name: 'tauri_webview_execute_js',
188
+ description: 'Execute JavaScript in webview',
189
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
190
+ schema: ExecuteJavaScriptSchema,
191
+ handler: async (args) => {
192
+ const parsed = ExecuteJavaScriptSchema.parse(args);
193
+ return await executeJavaScript(parsed.script, parsed.args);
194
+ },
195
+ },
196
+ {
197
+ name: 'tauri_webview_focus_element',
198
+ description: 'Focus on specific elements',
199
+ category: TOOL_CATEGORIES.UI_AUTOMATION,
200
+ schema: FocusElementSchema,
201
+ handler: async (args) => {
202
+ const parsed = FocusElementSchema.parse(args);
203
+ return await focusElement(parsed.selector);
204
+ },
205
+ },
206
+ // IPC & Plugin Tools
207
+ {
208
+ name: 'tauri_plugin_execute_ipc',
209
+ description: 'Execute Tauri IPC commands',
210
+ category: TOOL_CATEGORIES.IPC_PLUGIN,
211
+ schema: ExecuteIPCCommandSchema,
212
+ handler: async (args) => {
213
+ const parsed = ExecuteIPCCommandSchema.parse(args);
214
+ return await executeIPCCommand(parsed.command, parsed.args);
215
+ },
216
+ },
217
+ {
218
+ name: 'tauri_plugin_get_window_info',
219
+ description: 'Get window information',
220
+ category: TOOL_CATEGORIES.IPC_PLUGIN,
221
+ schema: GetWindowInfoSchema,
222
+ handler: async () => {
223
+ return await getWindowInfo();
224
+ },
225
+ },
226
+ {
227
+ name: 'tauri_plugin_ipc_monitor',
228
+ description: 'Start or stop IPC monitoring to capture Tauri command invocations. ' +
229
+ 'Use "start" to begin capturing, then tauri_plugin_ipc_get_events to retrieve captured events.',
230
+ category: TOOL_CATEGORIES.IPC_PLUGIN,
231
+ schema: ManageIPCMonitoringSchema,
232
+ handler: async (args) => {
233
+ const parsed = ManageIPCMonitoringSchema.parse(args);
234
+ return await manageIPCMonitoring(parsed.action);
235
+ },
236
+ },
237
+ {
238
+ name: 'tauri_plugin_ipc_get_events',
239
+ description: 'Retrieve IPC events captured since monitoring started. ' +
240
+ 'Shows Tauri command invocations with their arguments and responses. ' +
241
+ 'Requires tauri_plugin_ipc_monitor to be started first.',
242
+ category: TOOL_CATEGORIES.IPC_PLUGIN,
243
+ schema: GetIPCEventsSchema,
244
+ handler: async (args) => {
245
+ const parsed = GetIPCEventsSchema.parse(args);
246
+ return await getIPCEvents(parsed.filter);
247
+ },
248
+ },
249
+ {
250
+ name: 'tauri_plugin_emit_event',
251
+ description: 'Emit a custom Tauri event that can be listened to by the frontend or backend. ' +
252
+ 'Useful for testing event handlers or triggering application behavior.',
253
+ category: TOOL_CATEGORIES.IPC_PLUGIN,
254
+ schema: EmitTestEventSchema,
255
+ handler: async (args) => {
256
+ const parsed = EmitTestEventSchema.parse(args);
257
+ return await emitTestEvent(parsed.eventName, parsed.payload);
258
+ },
259
+ },
260
+ {
261
+ name: 'tauri_plugin_get_backend_state',
262
+ description: 'Get comprehensive backend state including app metadata, Tauri version, environment info, and window list',
263
+ category: TOOL_CATEGORIES.IPC_PLUGIN,
264
+ schema: GetBackendStateSchema,
265
+ handler: async () => {
266
+ return await getBackendState();
267
+ },
268
+ },
269
+ ];
270
+ /**
271
+ * Get tools grouped by category
272
+ */
273
+ export function getToolsByCategory() {
274
+ const grouped = {};
275
+ for (const tool of TOOLS) {
276
+ if (!grouped[tool.category]) {
277
+ grouped[tool.category] = [];
278
+ }
279
+ grouped[tool.category].push(tool);
280
+ }
281
+ return grouped;
282
+ }
283
+ /**
284
+ * Get total tool count
285
+ */
286
+ export function getToolCount() {
287
+ return TOOLS.length;
288
+ }
289
+ /**
290
+ * Create a Map for fast tool lookup by name
291
+ */
292
+ export const TOOL_MAP = new Map(TOOLS.map((tool) => { return [tool.name, tool]; }));
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@hypothesi/tauri-mcp-server",
3
+ "version": "0.1.1",
4
+ "description": "A Model Context Protocol server for Tauri v2 development",
5
+ "type": "module",
6
+ "bin": {
7
+ "mcp-server-tauri": "./dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc && cp -r src/driver/scripts/*.js dist/driver/scripts/ && chmod +x dist/index.js",
11
+ "start": "node dist/index.js",
12
+ "test": "vitest run",
13
+ "test:unit": "vitest run --config vitest.config.unit.ts",
14
+ "test:e2e": "vitest run --config vitest.config.ts",
15
+ "dev": "tsc --watch",
16
+ "generate:docs": "tsx scripts/generate-tools-docs.ts",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/hypothesi/mcp-server-tauri.git",
22
+ "directory": "packages/mcp-server"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "package.json",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "author": "hypothesi",
31
+ "license": "MIT",
32
+ "keywords": [
33
+ "mcp",
34
+ "model-context-protocol",
35
+ "tauri",
36
+ "automation",
37
+ "testing",
38
+ "debugging",
39
+ "cursor",
40
+ "windsurf",
41
+ "vscode"
42
+ ],
43
+ "dependencies": {
44
+ "@modelcontextprotocol/sdk": "0.6.1",
45
+ "execa": "9.6.0",
46
+ "html2canvas": "1.4.1",
47
+ "ws": "8.18.3",
48
+ "zod": "3.25.76",
49
+ "zod-to-json-schema": "3.25.0"
50
+ },
51
+ "devDependencies": {
52
+ "@types/html2canvas": "0.5.35",
53
+ "@types/node": "22.19.1",
54
+ "@types/ws": "8.18.1",
55
+ "vitest": "4.0.13"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }