@hypothesi/tauri-mcp-server 0.6.3 → 0.6.5

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.
@@ -285,11 +285,11 @@ async function prepareHtml2canvasScript(format, quality) {
285
285
  /**
286
286
  * Capture a screenshot of the entire webview.
287
287
  *
288
- * @param options - Screenshot options (format, quality, windowId, appIdentifier)
288
+ * @param options - Screenshot options (format, quality, windowId, appIdentifier, etc.)
289
289
  * @returns Screenshot result with image content
290
290
  */
291
291
  export async function captureScreenshot(options = {}) {
292
- const { format = 'png', quality = 90, windowId, appIdentifier } = options;
292
+ const { format = 'png', quality = 90, windowId, appIdentifier, maxWidth } = options;
293
293
  // Primary implementation: Use native platform-specific APIs
294
294
  // - macOS: WKWebView takeSnapshot
295
295
  // - Windows: WebView2 CapturePreview
@@ -307,6 +307,7 @@ export async function captureScreenshot(options = {}) {
307
307
  format,
308
308
  quality,
309
309
  windowLabel: windowId,
310
+ maxWidth,
310
311
  },
311
312
  }, 15000);
312
313
  if (!response.success || !response.data) {
@@ -36,6 +36,8 @@ export const ScreenshotSchema = WindowTargetSchema.extend({
36
36
  format: z.enum(['png', 'jpeg']).optional().default('png').describe('Image format'),
37
37
  quality: z.number().min(0).max(100).optional().describe('JPEG quality (0-100, only for jpeg format)'),
38
38
  filePath: z.string().optional().describe('File path to save the screenshot to instead of returning as base64'),
39
+ maxWidth: z.number().int().positive().optional().describe('Maximum width in pixels. Images wider than this will be scaled down proportionally. ' +
40
+ 'Can also be set via TAURI_MCP_SCREENSHOT_MAX_WIDTH environment variable.'),
39
41
  });
40
42
  export const KeyboardSchema = WindowTargetSchema.extend({
41
43
  action: z.enum(['type', 'press', 'down', 'up'])
@@ -121,9 +123,9 @@ async function performSwipe(options) {
121
123
  }
122
124
  }
123
125
  export async function screenshot(options = {}) {
124
- const { quality, format = 'png', windowId, filePath, appIdentifier } = options;
126
+ const { quality, format = 'png', windowId, filePath, appIdentifier, maxWidth } = options;
125
127
  // Use the native screenshot function from webview-executor
126
- const result = await captureScreenshot({ format, quality, windowId, appIdentifier });
128
+ const result = await captureScreenshot({ format, quality, windowId, appIdentifier, maxWidth });
127
129
  // If filePath is provided, write to file instead of returning base64
128
130
  if (filePath) {
129
131
  // Find the image content in the result
@@ -1,6 +1,49 @@
1
1
  import { z } from 'zod';
2
2
  import { execa } from 'execa';
3
+ import { existsSync } from 'node:fs';
4
+ import { homedir } from 'node:os';
5
+ import { join } from 'node:path';
3
6
  import { getConsoleLogs } from '../driver/webview-interactions.js';
7
+ /**
8
+ * Find the adb executable path. Checks environment variables first, then common
9
+ * installation locations on macOS, Linux, and Windows. This is necessary because
10
+ * MCP servers often run without ANDROID_HOME set (e.g., global npm installs).
11
+ */
12
+ function findAdbPath() {
13
+ // Check environment variables first
14
+ // eslint-disable-next-line no-process-env
15
+ const androidHome = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
16
+ if (androidHome) {
17
+ const envPath = join(androidHome, 'platform-tools', 'adb');
18
+ if (existsSync(envPath)) {
19
+ return envPath;
20
+ }
21
+ }
22
+ // Common installation locations to check
23
+ const home = homedir();
24
+ const commonPaths = [
25
+ // macOS - Android Studio default
26
+ join(home, 'Library', 'Android', 'sdk', 'platform-tools', 'adb'),
27
+ // Linux - Android Studio default
28
+ join(home, 'Android', 'Sdk', 'platform-tools', 'adb'),
29
+ // Linux - alternative location
30
+ join(home, 'android-sdk', 'platform-tools', 'adb'),
31
+ // Windows - Android Studio default
32
+ join(home, 'AppData', 'Local', 'Android', 'Sdk', 'platform-tools', 'adb.exe'),
33
+ // Homebrew on macOS
34
+ '/opt/homebrew/bin/adb',
35
+ '/usr/local/bin/adb',
36
+ // Linux system-wide
37
+ '/usr/bin/adb',
38
+ ];
39
+ for (const adbPath of commonPaths) {
40
+ if (existsSync(adbPath)) {
41
+ return adbPath;
42
+ }
43
+ }
44
+ // Fall back to PATH (will fail if not in PATH, but gives a clear error)
45
+ return 'adb';
46
+ }
4
47
  export const ReadLogsSchema = z.object({
5
48
  source: z.enum(['console', 'android', 'ios', 'system'])
6
49
  .describe('Log source: "console" for webview JS logs, "android" for logcat, "ios" for simulator, "system" for desktop'),
@@ -19,10 +62,7 @@ export async function readLogs(options) {
19
62
  return await getConsoleLogs({ filter, since, windowId, appIdentifier });
20
63
  }
21
64
  if (source === 'android') {
22
- // Find adb - check ANDROID_HOME first, then fall back to PATH
23
- // eslint-disable-next-line no-process-env
24
- const androidHome = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
25
- const adbPath = androidHome ? `${androidHome}/platform-tools/adb` : 'adb';
65
+ const adbPath = findAdbPath();
26
66
  const args = ['logcat', '-d'];
27
67
  if (since) {
28
68
  // adb logcat -T expects "MM-DD HH:MM:SS.mmm"
@@ -248,6 +248,7 @@ export const TOOLS = [
248
248
  windowId: parsed.windowId,
249
249
  filePath: parsed.filePath,
250
250
  appIdentifier: parsed.appIdentifier,
251
+ maxWidth: parsed.maxWidth,
251
252
  });
252
253
  // If saved to file, return text confirmation
253
254
  if ('filePath' in result) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hypothesi/tauri-mcp-server",
3
- "version": "0.6.3",
4
- "mcpName": "io.github.hypothesi/tauri",
3
+ "version": "0.6.5",
4
+ "mcpName": "io.github.hypothesi/mcp-server-tauri",
5
5
  "description": "A Model Context Protocol server for use with Tauri v2 applications",
6
6
  "type": "module",
7
7
  "bin": {