@mcp-use/cli 3.2.0-canary.11 → 3.2.0-canary.13

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/dist/index.js CHANGED
@@ -2866,7 +2866,7 @@ async function captureScreenshot(opts) {
2866
2866
  {
2867
2867
  width: opts.width,
2868
2868
  height: opts.height,
2869
- deviceScaleFactor: 1,
2869
+ deviceScaleFactor: opts.deviceScaleFactor ?? 1,
2870
2870
  mobile: false
2871
2871
  },
2872
2872
  sessionId
@@ -3101,7 +3101,8 @@ async function captureToolScreenshot(inputs, options = {}) {
3101
3101
  chromePath,
3102
3102
  cdpUrl: options.cdpUrl,
3103
3103
  delayMs: Number.isFinite(delayMs) && delayMs > 0 ? delayMs : 0,
3104
- bundle
3104
+ bundle,
3105
+ deviceScaleFactor: options.deviceScaleFactor
3105
3106
  });
3106
3107
  return { outputPath, width, height, view };
3107
3108
  } finally {
@@ -3244,6 +3245,25 @@ function parseDimension(raw, name) {
3244
3245
  }
3245
3246
  return n;
3246
3247
  }
3248
+ function parseDeviceScaleFactor(raw) {
3249
+ const n = parseFloat(raw);
3250
+ if (!Number.isFinite(n) || n <= 0) {
3251
+ throw new Error(
3252
+ `--device-scale-factor must be a positive number (got "${raw}")`
3253
+ );
3254
+ }
3255
+ if (n > 4) {
3256
+ throw new Error(
3257
+ `--device-scale-factor must be <= 4 to avoid excessive pixel counts (got "${raw}")`
3258
+ );
3259
+ }
3260
+ return n;
3261
+ }
3262
+ function requiresArguments(inputSchema) {
3263
+ if (!inputSchema || typeof inputSchema !== "object") return false;
3264
+ const required = inputSchema.required;
3265
+ return Array.isArray(required) && required.length > 0;
3266
+ }
3247
3267
  var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
3248
3268
  async function resolveSessionForScreenshot(options, sessionName, headers) {
3249
3269
  if (sessionName) {
@@ -3320,6 +3340,7 @@ async function screenshotCommand(options, argsList, context) {
3320
3340
  const height = parseDimension(options.height, "height");
3321
3341
  const navTimeout = parseInt(options.timeout, 10) || 3e4;
3322
3342
  const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
3343
+ const deviceScaleFactor = options.deviceScaleFactor ? parseDeviceScaleFactor(options.deviceScaleFactor) : void 0;
3323
3344
  const session = await resolveSessionForScreenshot(
3324
3345
  options,
3325
3346
  context.sessionName,
@@ -3371,6 +3392,18 @@ async function screenshotCommand(options, argsList, context) {
3371
3392
  exitCode = 1;
3372
3393
  return;
3373
3394
  }
3395
+ } else if (requiresArguments(tool.inputSchema)) {
3396
+ console.error(formatError("This tool requires arguments."));
3397
+ console.log("");
3398
+ console.log(formatInfo("Provide arguments as key=value pairs:"));
3399
+ console.log(
3400
+ ` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
3401
+ );
3402
+ console.log("");
3403
+ console.log(formatInfo("Tool schema:"));
3404
+ console.log(formatSchema(tool.inputSchema));
3405
+ exitCode = 1;
3406
+ return;
3374
3407
  }
3375
3408
  const toolOutput = await session.callTool(options.tool, toolArgs);
3376
3409
  const result = await captureToolScreenshot(
@@ -3391,7 +3424,8 @@ async function screenshotCommand(options, argsList, context) {
3391
3424
  timeoutMs: navTimeout,
3392
3425
  inspector: options.inspector,
3393
3426
  quiet: options.quiet,
3394
- cdpUrl: options.cdpUrl
3427
+ cdpUrl: options.cdpUrl,
3428
+ deviceScaleFactor
3395
3429
  }
3396
3430
  );
3397
3431
  console.log(
@@ -3413,6 +3447,9 @@ function withCommonScreenshotOptions(cmd) {
3413
3447
  "--tool <name>",
3414
3448
  "Tool to call. Its UI resource is rendered with the result."
3415
3449
  ).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
3450
+ "--device-scale-factor <n>",
3451
+ "Device pixel ratio for rendering (e.g. 2 for Retina). Output PNG is (width \xD7 dsf) \xD7 (height \xD7 dsf). Must be > 0 and <= 4."
3452
+ ).option(
3416
3453
  "--inspector <url>",
3417
3454
  "Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
3418
3455
  ).option(
@@ -3890,6 +3927,15 @@ async function callToolCommand(name, toolName, argsList, options) {
3890
3927
  formatInfo(`Capturing widget screenshot (${resourceUri})...`)
3891
3928
  );
3892
3929
  try {
3930
+ const screenshotOpts = {};
3931
+ if (options?.screenshotOutput) {
3932
+ screenshotOpts.output = options.screenshotOutput;
3933
+ }
3934
+ if (options?.screenshotDeviceScaleFactor) {
3935
+ screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
3936
+ options.screenshotDeviceScaleFactor
3937
+ );
3938
+ }
3893
3939
  const shot = await captureToolScreenshot(
3894
3940
  {
3895
3941
  session,
@@ -3898,7 +3944,7 @@ async function callToolCommand(name, toolName, argsList, options) {
3898
3944
  toolOutput: callResult,
3899
3945
  resourceUri
3900
3946
  },
3901
- options?.screenshotOutput ? { output: options.screenshotOutput } : {}
3947
+ screenshotOpts
3902
3948
  );
3903
3949
  screenshot = {
3904
3950
  path: shot.outputPath,
@@ -4344,6 +4390,9 @@ function createPerClientCommand(name) {
4344
4390
  ).option(
4345
4391
  "--screenshot-output <path>",
4346
4392
  "Output PNG path for the widget screenshot (defaults to ./<view>-<timestamp>.png)"
4393
+ ).option(
4394
+ "--screenshot-device-scale-factor <n>",
4395
+ "Device pixel ratio for the auto-screenshot (e.g. 2 for Retina). Defaults to 1."
4347
4396
  ).action(
4348
4397
  (tool, args, options) => callToolCommand(name, tool, args, options)
4349
4398
  );