@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
|
@@ -31,6 +31,7 @@ export declare function callToolCommand(name: string, toolName: string, argsList
|
|
|
31
31
|
json?: boolean;
|
|
32
32
|
screenshot?: boolean;
|
|
33
33
|
screenshotOutput?: string;
|
|
34
|
+
screenshotDeviceScaleFactor?: string;
|
|
34
35
|
}): Promise<void>;
|
|
35
36
|
export declare function listResourcesCommand(name: string, options: {
|
|
36
37
|
json?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/commands/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/commands/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqDpC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,aAMtC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,aAQ5B,CAAC;AAEH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,OAAO,EAAE;IACP,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,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C,CAsBf;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAiDf;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,EACnB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAoDf;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoLpE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAyC7C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA2H5D"}
|
|
@@ -14,6 +14,7 @@ interface ScreenshotOptions {
|
|
|
14
14
|
timeout: string;
|
|
15
15
|
cdpUrl?: string;
|
|
16
16
|
header?: string[];
|
|
17
|
+
deviceScaleFactor?: string;
|
|
17
18
|
}
|
|
18
19
|
interface ScreenshotContext {
|
|
19
20
|
sessionName?: string;
|
|
@@ -56,6 +57,12 @@ export interface CaptureToolScreenshotOptions {
|
|
|
56
57
|
* must be reachable from that remote browser.
|
|
57
58
|
*/
|
|
58
59
|
cdpUrl?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Device pixel ratio for rendering. Defaults to 1. With a value of 2 the
|
|
62
|
+
* resulting PNG is (width × 2) × (height × 2) device pixels (Retina-style
|
|
63
|
+
* capture). Forwarded to `Emulation.setDeviceMetricsOverride`.
|
|
64
|
+
*/
|
|
65
|
+
deviceScaleFactor?: number;
|
|
59
66
|
}
|
|
60
67
|
export interface CaptureToolScreenshotResult {
|
|
61
68
|
outputPath: string;
|
|
@@ -77,6 +84,11 @@ export declare function captureToolScreenshot(inputs: CaptureToolScreenshotInput
|
|
|
77
84
|
export declare function timestampSuffix(date?: Date): string;
|
|
78
85
|
export declare function extractViewName(resourceUri: string): string;
|
|
79
86
|
export declare function parseDimension(raw: string, name: string): number;
|
|
87
|
+
/**
|
|
88
|
+
* Parse `--device-scale-factor <n>`. Allows fractional values (e.g. 1.5) and
|
|
89
|
+
* caps at 4 to avoid accidental 16x-pixel screenshots (memory + disk).
|
|
90
|
+
*/
|
|
91
|
+
export declare function parseDeviceScaleFactor(raw: string): number;
|
|
80
92
|
export declare function screenshotCommand(options: ScreenshotOptions, argsList: string[] | undefined, context: ScreenshotContext): Promise<void>;
|
|
81
93
|
/**
|
|
82
94
|
* Top-level ad-hoc form: `mcp-use client screenshot --mcp <url> --tool <name>`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/commands/screenshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAkBjD,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;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,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMhE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa1D;AAgDD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,EAC9B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAkJf;AAqDD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAwBvD;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAetE"}
|
package/dist/index.cjs
CHANGED
|
@@ -2881,7 +2881,7 @@ async function captureScreenshot(opts) {
|
|
|
2881
2881
|
{
|
|
2882
2882
|
width: opts.width,
|
|
2883
2883
|
height: opts.height,
|
|
2884
|
-
deviceScaleFactor: 1,
|
|
2884
|
+
deviceScaleFactor: opts.deviceScaleFactor ?? 1,
|
|
2885
2885
|
mobile: false
|
|
2886
2886
|
},
|
|
2887
2887
|
sessionId
|
|
@@ -3116,7 +3116,8 @@ async function captureToolScreenshot(inputs, options = {}) {
|
|
|
3116
3116
|
chromePath,
|
|
3117
3117
|
cdpUrl: options.cdpUrl,
|
|
3118
3118
|
delayMs: Number.isFinite(delayMs) && delayMs > 0 ? delayMs : 0,
|
|
3119
|
-
bundle
|
|
3119
|
+
bundle,
|
|
3120
|
+
deviceScaleFactor: options.deviceScaleFactor
|
|
3120
3121
|
});
|
|
3121
3122
|
return { outputPath, width, height, view };
|
|
3122
3123
|
} finally {
|
|
@@ -3259,6 +3260,20 @@ function parseDimension(raw, name) {
|
|
|
3259
3260
|
}
|
|
3260
3261
|
return n;
|
|
3261
3262
|
}
|
|
3263
|
+
function parseDeviceScaleFactor(raw) {
|
|
3264
|
+
const n = parseFloat(raw);
|
|
3265
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
3266
|
+
throw new Error(
|
|
3267
|
+
`--device-scale-factor must be a positive number (got "${raw}")`
|
|
3268
|
+
);
|
|
3269
|
+
}
|
|
3270
|
+
if (n > 4) {
|
|
3271
|
+
throw new Error(
|
|
3272
|
+
`--device-scale-factor must be <= 4 to avoid excessive pixel counts (got "${raw}")`
|
|
3273
|
+
);
|
|
3274
|
+
}
|
|
3275
|
+
return n;
|
|
3276
|
+
}
|
|
3262
3277
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3263
3278
|
async function resolveSessionForScreenshot(options, sessionName, headers) {
|
|
3264
3279
|
if (sessionName) {
|
|
@@ -3335,6 +3350,7 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3335
3350
|
const height = parseDimension(options.height, "height");
|
|
3336
3351
|
const navTimeout = parseInt(options.timeout, 10) || 3e4;
|
|
3337
3352
|
const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
|
|
3353
|
+
const deviceScaleFactor = options.deviceScaleFactor ? parseDeviceScaleFactor(options.deviceScaleFactor) : void 0;
|
|
3338
3354
|
const session = await resolveSessionForScreenshot(
|
|
3339
3355
|
options,
|
|
3340
3356
|
context.sessionName,
|
|
@@ -3406,7 +3422,8 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3406
3422
|
timeoutMs: navTimeout,
|
|
3407
3423
|
inspector: options.inspector,
|
|
3408
3424
|
quiet: options.quiet,
|
|
3409
|
-
cdpUrl: options.cdpUrl
|
|
3425
|
+
cdpUrl: options.cdpUrl,
|
|
3426
|
+
deviceScaleFactor
|
|
3410
3427
|
}
|
|
3411
3428
|
);
|
|
3412
3429
|
console.log(
|
|
@@ -3428,6 +3445,9 @@ function withCommonScreenshotOptions(cmd) {
|
|
|
3428
3445
|
"--tool <name>",
|
|
3429
3446
|
"Tool to call. Its UI resource is rendered with the result."
|
|
3430
3447
|
).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
|
|
3448
|
+
"--device-scale-factor <n>",
|
|
3449
|
+
"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."
|
|
3450
|
+
).option(
|
|
3431
3451
|
"--inspector <url>",
|
|
3432
3452
|
"Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
|
|
3433
3453
|
).option(
|
|
@@ -3905,6 +3925,15 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3905
3925
|
formatInfo(`Capturing widget screenshot (${resourceUri})...`)
|
|
3906
3926
|
);
|
|
3907
3927
|
try {
|
|
3928
|
+
const screenshotOpts = {};
|
|
3929
|
+
if (options?.screenshotOutput) {
|
|
3930
|
+
screenshotOpts.output = options.screenshotOutput;
|
|
3931
|
+
}
|
|
3932
|
+
if (options?.screenshotDeviceScaleFactor) {
|
|
3933
|
+
screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
|
|
3934
|
+
options.screenshotDeviceScaleFactor
|
|
3935
|
+
);
|
|
3936
|
+
}
|
|
3908
3937
|
const shot = await captureToolScreenshot(
|
|
3909
3938
|
{
|
|
3910
3939
|
session,
|
|
@@ -3913,7 +3942,7 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3913
3942
|
toolOutput: callResult,
|
|
3914
3943
|
resourceUri
|
|
3915
3944
|
},
|
|
3916
|
-
|
|
3945
|
+
screenshotOpts
|
|
3917
3946
|
);
|
|
3918
3947
|
screenshot = {
|
|
3919
3948
|
path: shot.outputPath,
|
|
@@ -4359,6 +4388,9 @@ function createPerClientCommand(name) {
|
|
|
4359
4388
|
).option(
|
|
4360
4389
|
"--screenshot-output <path>",
|
|
4361
4390
|
"Output PNG path for the widget screenshot (defaults to ./<view>-<timestamp>.png)"
|
|
4391
|
+
).option(
|
|
4392
|
+
"--screenshot-device-scale-factor <n>",
|
|
4393
|
+
"Device pixel ratio for the auto-screenshot (e.g. 2 for Retina). Defaults to 1."
|
|
4362
4394
|
).action(
|
|
4363
4395
|
(tool, args, options) => callToolCommand(name, tool, args, options)
|
|
4364
4396
|
);
|