@mcp-use/cli 3.2.0-canary.11 → 3.2.0-canary.12
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/commands/client.d.ts +1 -0
- package/dist/commands/client.d.ts.map +1 -1
- package/dist/commands/screenshot.d.ts +12 -0
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/index.cjs +36 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -4
- package/dist/index.js.map +1 -1
- package/dist/utils/cdp-screenshot.d.ts +7 -0
- package/dist/utils/cdp-screenshot.d.ts.map +1 -1
- package/package.json +3 -3
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,20 @@ 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
|
+
}
|
|
3247
3262
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3248
3263
|
async function resolveSessionForScreenshot(options, sessionName, headers) {
|
|
3249
3264
|
if (sessionName) {
|
|
@@ -3320,6 +3335,7 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3320
3335
|
const height = parseDimension(options.height, "height");
|
|
3321
3336
|
const navTimeout = parseInt(options.timeout, 10) || 3e4;
|
|
3322
3337
|
const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
|
|
3338
|
+
const deviceScaleFactor = options.deviceScaleFactor ? parseDeviceScaleFactor(options.deviceScaleFactor) : void 0;
|
|
3323
3339
|
const session = await resolveSessionForScreenshot(
|
|
3324
3340
|
options,
|
|
3325
3341
|
context.sessionName,
|
|
@@ -3391,7 +3407,8 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3391
3407
|
timeoutMs: navTimeout,
|
|
3392
3408
|
inspector: options.inspector,
|
|
3393
3409
|
quiet: options.quiet,
|
|
3394
|
-
cdpUrl: options.cdpUrl
|
|
3410
|
+
cdpUrl: options.cdpUrl,
|
|
3411
|
+
deviceScaleFactor
|
|
3395
3412
|
}
|
|
3396
3413
|
);
|
|
3397
3414
|
console.log(
|
|
@@ -3413,6 +3430,9 @@ function withCommonScreenshotOptions(cmd) {
|
|
|
3413
3430
|
"--tool <name>",
|
|
3414
3431
|
"Tool to call. Its UI resource is rendered with the result."
|
|
3415
3432
|
).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
|
|
3433
|
+
"--device-scale-factor <n>",
|
|
3434
|
+
"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."
|
|
3435
|
+
).option(
|
|
3416
3436
|
"--inspector <url>",
|
|
3417
3437
|
"Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
|
|
3418
3438
|
).option(
|
|
@@ -3890,6 +3910,15 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3890
3910
|
formatInfo(`Capturing widget screenshot (${resourceUri})...`)
|
|
3891
3911
|
);
|
|
3892
3912
|
try {
|
|
3913
|
+
const screenshotOpts = {};
|
|
3914
|
+
if (options?.screenshotOutput) {
|
|
3915
|
+
screenshotOpts.output = options.screenshotOutput;
|
|
3916
|
+
}
|
|
3917
|
+
if (options?.screenshotDeviceScaleFactor) {
|
|
3918
|
+
screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
|
|
3919
|
+
options.screenshotDeviceScaleFactor
|
|
3920
|
+
);
|
|
3921
|
+
}
|
|
3893
3922
|
const shot = await captureToolScreenshot(
|
|
3894
3923
|
{
|
|
3895
3924
|
session,
|
|
@@ -3898,7 +3927,7 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3898
3927
|
toolOutput: callResult,
|
|
3899
3928
|
resourceUri
|
|
3900
3929
|
},
|
|
3901
|
-
|
|
3930
|
+
screenshotOpts
|
|
3902
3931
|
);
|
|
3903
3932
|
screenshot = {
|
|
3904
3933
|
path: shot.outputPath,
|
|
@@ -4344,6 +4373,9 @@ function createPerClientCommand(name) {
|
|
|
4344
4373
|
).option(
|
|
4345
4374
|
"--screenshot-output <path>",
|
|
4346
4375
|
"Output PNG path for the widget screenshot (defaults to ./<view>-<timestamp>.png)"
|
|
4376
|
+
).option(
|
|
4377
|
+
"--screenshot-device-scale-factor <n>",
|
|
4378
|
+
"Device pixel ratio for the auto-screenshot (e.g. 2 for Retina). Defaults to 1."
|
|
4347
4379
|
).action(
|
|
4348
4380
|
(tool, args, options) => callToolCommand(name, tool, args, options)
|
|
4349
4381
|
);
|