@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/commands/client.d.ts +1 -0
- package/dist/commands/client.d.ts.map +1 -1
- package/dist/commands/screenshot.d.ts +13 -0
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/index.cjs +53 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +53 -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,12 @@ 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;
|
|
92
|
+
export declare function requiresArguments(inputSchema: unknown): boolean;
|
|
80
93
|
export declare function screenshotCommand(options: ScreenshotOptions, argsList: string[] | undefined, context: ScreenshotContext): Promise<void>;
|
|
81
94
|
/**
|
|
82
95
|
* 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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MAAM,CAK3D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAMhE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAa1D;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAI/D;AAgDD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,EAC9B,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA8Jf;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,25 @@ 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
|
+
}
|
|
3277
|
+
function requiresArguments(inputSchema) {
|
|
3278
|
+
if (!inputSchema || typeof inputSchema !== "object") return false;
|
|
3279
|
+
const required = inputSchema.required;
|
|
3280
|
+
return Array.isArray(required) && required.length > 0;
|
|
3281
|
+
}
|
|
3262
3282
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3263
3283
|
async function resolveSessionForScreenshot(options, sessionName, headers) {
|
|
3264
3284
|
if (sessionName) {
|
|
@@ -3335,6 +3355,7 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3335
3355
|
const height = parseDimension(options.height, "height");
|
|
3336
3356
|
const navTimeout = parseInt(options.timeout, 10) || 3e4;
|
|
3337
3357
|
const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
|
|
3358
|
+
const deviceScaleFactor = options.deviceScaleFactor ? parseDeviceScaleFactor(options.deviceScaleFactor) : void 0;
|
|
3338
3359
|
const session = await resolveSessionForScreenshot(
|
|
3339
3360
|
options,
|
|
3340
3361
|
context.sessionName,
|
|
@@ -3386,6 +3407,18 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3386
3407
|
exitCode = 1;
|
|
3387
3408
|
return;
|
|
3388
3409
|
}
|
|
3410
|
+
} else if (requiresArguments(tool.inputSchema)) {
|
|
3411
|
+
console.error(formatError("This tool requires arguments."));
|
|
3412
|
+
console.log("");
|
|
3413
|
+
console.log(formatInfo("Provide arguments as key=value pairs:"));
|
|
3414
|
+
console.log(
|
|
3415
|
+
` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
|
|
3416
|
+
);
|
|
3417
|
+
console.log("");
|
|
3418
|
+
console.log(formatInfo("Tool schema:"));
|
|
3419
|
+
console.log(formatSchema(tool.inputSchema));
|
|
3420
|
+
exitCode = 1;
|
|
3421
|
+
return;
|
|
3389
3422
|
}
|
|
3390
3423
|
const toolOutput = await session.callTool(options.tool, toolArgs);
|
|
3391
3424
|
const result = await captureToolScreenshot(
|
|
@@ -3406,7 +3439,8 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3406
3439
|
timeoutMs: navTimeout,
|
|
3407
3440
|
inspector: options.inspector,
|
|
3408
3441
|
quiet: options.quiet,
|
|
3409
|
-
cdpUrl: options.cdpUrl
|
|
3442
|
+
cdpUrl: options.cdpUrl,
|
|
3443
|
+
deviceScaleFactor
|
|
3410
3444
|
}
|
|
3411
3445
|
);
|
|
3412
3446
|
console.log(
|
|
@@ -3428,6 +3462,9 @@ function withCommonScreenshotOptions(cmd) {
|
|
|
3428
3462
|
"--tool <name>",
|
|
3429
3463
|
"Tool to call. Its UI resource is rendered with the result."
|
|
3430
3464
|
).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
|
|
3465
|
+
"--device-scale-factor <n>",
|
|
3466
|
+
"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."
|
|
3467
|
+
).option(
|
|
3431
3468
|
"--inspector <url>",
|
|
3432
3469
|
"Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
|
|
3433
3470
|
).option(
|
|
@@ -3905,6 +3942,15 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3905
3942
|
formatInfo(`Capturing widget screenshot (${resourceUri})...`)
|
|
3906
3943
|
);
|
|
3907
3944
|
try {
|
|
3945
|
+
const screenshotOpts = {};
|
|
3946
|
+
if (options?.screenshotOutput) {
|
|
3947
|
+
screenshotOpts.output = options.screenshotOutput;
|
|
3948
|
+
}
|
|
3949
|
+
if (options?.screenshotDeviceScaleFactor) {
|
|
3950
|
+
screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
|
|
3951
|
+
options.screenshotDeviceScaleFactor
|
|
3952
|
+
);
|
|
3953
|
+
}
|
|
3908
3954
|
const shot = await captureToolScreenshot(
|
|
3909
3955
|
{
|
|
3910
3956
|
session,
|
|
@@ -3913,7 +3959,7 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3913
3959
|
toolOutput: callResult,
|
|
3914
3960
|
resourceUri
|
|
3915
3961
|
},
|
|
3916
|
-
|
|
3962
|
+
screenshotOpts
|
|
3917
3963
|
);
|
|
3918
3964
|
screenshot = {
|
|
3919
3965
|
path: shot.outputPath,
|
|
@@ -4359,6 +4405,9 @@ function createPerClientCommand(name) {
|
|
|
4359
4405
|
).option(
|
|
4360
4406
|
"--screenshot-output <path>",
|
|
4361
4407
|
"Output PNG path for the widget screenshot (defaults to ./<view>-<timestamp>.png)"
|
|
4408
|
+
).option(
|
|
4409
|
+
"--screenshot-device-scale-factor <n>",
|
|
4410
|
+
"Device pixel ratio for the auto-screenshot (e.g. 2 for Retina). Defaults to 1."
|
|
4362
4411
|
).action(
|
|
4363
4412
|
(tool, args, options) => callToolCommand(name, tool, args, options)
|
|
4364
4413
|
);
|