@mcp-use/cli 3.2.0-canary.10 → 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.
@@ -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;AA+CpC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,aAKtC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,aAO5B,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,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,OAAO,CAAC,IAAI,CAAC,CAmMf;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAenE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DrE;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CA6CxD;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CA0Df;AA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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"}
@@ -6,7 +6,6 @@ interface ScreenshotOptions {
6
6
  height: string;
7
7
  inspector?: string;
8
8
  mcp?: string;
9
- session?: string;
10
9
  theme: "light" | "dark";
11
10
  output?: string;
12
11
  waitFor?: string;
@@ -15,6 +14,11 @@ interface ScreenshotOptions {
15
14
  timeout: string;
16
15
  cdpUrl?: string;
17
16
  header?: string[];
17
+ deviceScaleFactor?: string;
18
+ }
19
+ interface ScreenshotContext {
20
+ sessionName?: string;
21
+ usagePrefix: string;
18
22
  }
19
23
  /**
20
24
  * Curl-style `Key: Value` parser. Splits on the first `:` so values may
@@ -53,6 +57,12 @@ export interface CaptureToolScreenshotOptions {
53
57
  * must be reachable from that remote browser.
54
58
  */
55
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;
56
66
  }
57
67
  export interface CaptureToolScreenshotResult {
58
68
  outputPath: string;
@@ -74,7 +84,25 @@ export declare function captureToolScreenshot(inputs: CaptureToolScreenshotInput
74
84
  export declare function timestampSuffix(date?: Date): string;
75
85
  export declare function extractViewName(resourceUri: string): string;
76
86
  export declare function parseDimension(raw: string, name: string): number;
77
- export declare function screenshotCommand(options: ScreenshotOptions, argsList: string[] | undefined): Promise<void>;
78
- export declare function createScreenshotCommand(): Command;
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 screenshotCommand(options: ScreenshotOptions, argsList: string[] | undefined, context: ScreenshotContext): Promise<void>;
93
+ /**
94
+ * Top-level ad-hoc form: `mcp-use client screenshot --mcp <url> --tool <name>`.
95
+ *
96
+ * Doesn't take a saved-server positional. The MCP server is supplied inline
97
+ * via `--mcp`, and authenticated servers can be reached with repeatable
98
+ * `-H, --header` flags. This is the programmatic entry point for one-off or
99
+ * automated screenshot runs that don't want to first `mcp-use client connect`.
100
+ */
101
+ export declare function createClientScreenshotCommand(): Command;
102
+ /**
103
+ * Per-server form: `mcp-use client <name> screenshot --tool <name>`. The saved
104
+ * server's auth (OAuth or bearer) is reused — no `--mcp`/`--header` flags.
105
+ */
106
+ export declare function createPerClientScreenshotCommand(name: string): Command;
79
107
  export {};
80
108
  //# sourceMappingURL=screenshot.d.ts.map
@@ -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,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC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AA2B;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,2BAA2B,EACnC,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAAC,2BAA2B,CAAC,CA2DtC;AAqLD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,OAAa,GAAG,MAAM,CAKzD;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,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;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,10 +3260,24 @@ 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
- async function resolveSessionForScreenshot(options, headers) {
3264
- if (options.session) {
3265
- const result = await getOrRestoreSession(options.session);
3278
+ async function resolveSessionForScreenshot(options, sessionName, headers) {
3279
+ if (sessionName) {
3280
+ const result = await getOrRestoreSession(sessionName);
3266
3281
  return result?.session ?? null;
3267
3282
  }
3268
3283
  if (options.mcp) {
@@ -3284,12 +3299,12 @@ async function resolveSessionForScreenshot(options, headers) {
3284
3299
  }
3285
3300
  console.error(
3286
3301
  formatError(
3287
- "No MCP target. Pass --session <name> (a saved server) or --mcp <url> (ad-hoc)."
3302
+ "No MCP target. Pass --mcp <url> for an ad-hoc connection, or use `mcp-use client <name> screenshot` for a saved server."
3288
3303
  )
3289
3304
  );
3290
3305
  return null;
3291
3306
  }
3292
- async function screenshotCommand(options, argsList) {
3307
+ async function screenshotCommand(options, argsList, context) {
3293
3308
  let exitCode = 0;
3294
3309
  try {
3295
3310
  if (!options.tool) {
@@ -3306,7 +3321,7 @@ async function screenshotCommand(options, argsList) {
3306
3321
  if (!options.mcp) {
3307
3322
  console.error(
3308
3323
  formatError(
3309
- "--header is only supported with --mcp <url>. Saved sessions (use --session) carry their own auth from `mcp-use client connect`."
3324
+ "--header is only supported with --mcp <url>. Saved servers carry their own auth from `mcp-use client connect`."
3310
3325
  )
3311
3326
  );
3312
3327
  exitCode = 1;
@@ -3335,7 +3350,12 @@ async function screenshotCommand(options, argsList) {
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;
3338
- const session = await resolveSessionForScreenshot(options, headers);
3353
+ const deviceScaleFactor = options.deviceScaleFactor ? parseDeviceScaleFactor(options.deviceScaleFactor) : void 0;
3354
+ const session = await resolveSessionForScreenshot(
3355
+ options,
3356
+ context.sessionName,
3357
+ headers
3358
+ );
3339
3359
  if (!session) {
3340
3360
  exitCode = 1;
3341
3361
  return;
@@ -3366,13 +3386,13 @@ async function screenshotCommand(options, argsList) {
3366
3386
  console.log("");
3367
3387
  console.log(formatInfo("Usage:"));
3368
3388
  console.log(
3369
- ` npx mcp-use screenshot --tool ${options.tool} key=value [key2=value2 ...]`
3389
+ ` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
3370
3390
  );
3371
3391
  console.log(
3372
- ` npx mcp-use screenshot --tool ${options.tool} nested:='{"a":1}' # JSON value`
3392
+ ` npx ${context.usagePrefix} --tool ${options.tool} nested:='{"a":1}' # JSON value`
3373
3393
  );
3374
3394
  console.log(
3375
- ` npx mcp-use screenshot --tool ${options.tool} '{"key":"value"}' # full JSON object`
3395
+ ` npx ${context.usagePrefix} --tool ${options.tool} '{"key":"value"}' # full JSON object`
3376
3396
  );
3377
3397
  if (tool.inputSchema) {
3378
3398
  console.log("");
@@ -3402,7 +3422,8 @@ async function screenshotCommand(options, argsList) {
3402
3422
  timeoutMs: navTimeout,
3403
3423
  inspector: options.inspector,
3404
3424
  quiet: options.quiet,
3405
- cdpUrl: options.cdpUrl
3425
+ cdpUrl: options.cdpUrl,
3426
+ deviceScaleFactor
3406
3427
  }
3407
3428
  );
3408
3429
  console.log(
@@ -3416,29 +3437,19 @@ async function screenshotCommand(options, argsList) {
3416
3437
  await cleanupAndExit(exitCode);
3417
3438
  }
3418
3439
  }
3419
- function createScreenshotCommand() {
3420
- return new import_commander.Command("screenshot").description(
3421
- "Render an MCP Apps view headlessly and save a PNG by calling a tool and rendering its UI resource with the result."
3422
- ).argument(
3440
+ function withCommonScreenshotOptions(cmd) {
3441
+ return cmd.argument(
3423
3442
  "[args...]",
3424
3443
  "Tool args as key=value pairs (use key:=<json> for nested values, or pass a single JSON object)."
3425
3444
  ).option(
3426
3445
  "--tool <name>",
3427
3446
  "Tool to call. Its UI resource is rendered with the result."
3428
3447
  ).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
3429
- "--inspector <url>",
3430
- "Inspector host that serves /inspector/preview/:view. When omitted, probes localhost:3000 then auto-spawns `mcp-use dev`."
3431
- ).option(
3432
- "--session <name>",
3433
- "Saved server name (from `mcp-use client connect <name> <url>`)."
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."
3434
3450
  ).option(
3435
- "--mcp <url>",
3436
- "Ad-hoc MCP server URL (escape hatch). Use when you don't have a saved server. No authentication unless --header is supplied."
3437
- ).option(
3438
- "-H, --header <header>",
3439
- 'HTTP header to send to the --mcp <url> server, formatted "Key: Value". Repeatable. Use to pass an Authorization bearer token or other auth headers when screenshotting an authenticated MCP server.',
3440
- collectHeader,
3441
- []
3451
+ "--inspector <url>",
3452
+ "Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
3442
3453
  ).option(
3443
3454
  "--theme <light|dark>",
3444
3455
  "Color scheme to render the view in.",
@@ -3456,9 +3467,42 @@ function createScreenshotCommand() {
3456
3467
  ).option("--timeout <ms>", "Navigation + readiness timeout in ms.", "30000").option(
3457
3468
  "--cdp-url <url>",
3458
3469
  "Connect to an existing CDP WebSocket (ws:// or wss://) instead of spawning local Chrome. Useful for hosted browsers like Notte."
3459
- ).option("--quiet", "Suppress dev-server output.").action(async (args, opts) => {
3460
- await screenshotCommand(opts, args);
3470
+ ).option("--quiet", "Suppress dev-server output.");
3471
+ }
3472
+ function createClientScreenshotCommand() {
3473
+ const cmd = withCommonScreenshotOptions(
3474
+ new import_commander.Command("screenshot").description(
3475
+ "Render an MCP Apps view headlessly and save a PNG. Connects to an MCP server inline via --mcp; for a saved server, use `mcp-use client <name> screenshot`."
3476
+ )
3477
+ ).option(
3478
+ "--mcp <url>",
3479
+ "Ad-hoc MCP server URL. Required for the top-level form. No authentication unless --header is supplied."
3480
+ ).option(
3481
+ "-H, --header <header>",
3482
+ 'HTTP header to send to the --mcp <url> server, formatted "Key: Value". Repeatable. Use to pass an Authorization bearer token or other auth headers when screenshotting an authenticated MCP server.',
3483
+ collectHeader,
3484
+ []
3485
+ );
3486
+ cmd.action(async (args, opts) => {
3487
+ await screenshotCommand(opts, args, {
3488
+ usagePrefix: "mcp-use client screenshot"
3489
+ });
3461
3490
  });
3491
+ return cmd;
3492
+ }
3493
+ function createPerClientScreenshotCommand(name) {
3494
+ const cmd = withCommonScreenshotOptions(
3495
+ new import_commander.Command("screenshot").description(
3496
+ `Render an MCP Apps view headlessly using the saved server '${name}'.`
3497
+ )
3498
+ );
3499
+ cmd.action(async (args, opts) => {
3500
+ await screenshotCommand(opts, args, {
3501
+ sessionName: name,
3502
+ usagePrefix: `mcp-use client ${name} screenshot`
3503
+ });
3504
+ });
3505
+ return cmd;
3462
3506
  }
3463
3507
 
3464
3508
  // src/commands/client.ts
@@ -3466,6 +3510,7 @@ var RESERVED_CLIENT_SUBCOMMANDS = /* @__PURE__ */ new Set([
3466
3510
  "connect",
3467
3511
  "list",
3468
3512
  "remove",
3513
+ "screenshot",
3469
3514
  "help"
3470
3515
  ]);
3471
3516
  var PER_CLIENT_SCOPES = /* @__PURE__ */ new Set([
@@ -3474,7 +3519,8 @@ var PER_CLIENT_SCOPES = /* @__PURE__ */ new Set([
3474
3519
  "prompts",
3475
3520
  "auth",
3476
3521
  "disconnect",
3477
- "interactive"
3522
+ "interactive",
3523
+ "screenshot"
3478
3524
  ]);
3479
3525
  async function connectCommand(name, urlOrCommand, options) {
3480
3526
  if (!name || !urlOrCommand) {
@@ -3879,6 +3925,15 @@ async function callToolCommand(name, toolName, argsList, options) {
3879
3925
  formatInfo(`Capturing widget screenshot (${resourceUri})...`)
3880
3926
  );
3881
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
+ }
3882
3937
  const shot = await captureToolScreenshot(
3883
3938
  {
3884
3939
  session,
@@ -3887,7 +3942,7 @@ async function callToolCommand(name, toolName, argsList, options) {
3887
3942
  toolOutput: callResult,
3888
3943
  resourceUri
3889
3944
  },
3890
- options?.screenshotOutput ? { output: options.screenshotOutput } : {}
3945
+ screenshotOpts
3891
3946
  );
3892
3947
  screenshot = {
3893
3948
  path: shot.outputPath,
@@ -4312,6 +4367,7 @@ function createClientCommand() {
4312
4367
  clientCommand.command("remove <name>").description(
4313
4368
  "Remove a saved server. Also clears any OAuth tokens for that URL, unless another saved server still uses it."
4314
4369
  ).action(removeClientCommand);
4370
+ clientCommand.addCommand(createClientScreenshotCommand());
4315
4371
  return clientCommand;
4316
4372
  }
4317
4373
  function createPerClientCommand(name) {
@@ -4332,6 +4388,9 @@ function createPerClientCommand(name) {
4332
4388
  ).option(
4333
4389
  "--screenshot-output <path>",
4334
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."
4335
4394
  ).action(
4336
4395
  (tool, args, options) => callToolCommand(name, tool, args, options)
4337
4396
  );
@@ -4362,6 +4421,7 @@ function createPerClientCommand(name) {
4362
4421
  authCommand.command("refresh").description("Force-refresh the OAuth access token").action(() => authRefreshCommand(name));
4363
4422
  authCommand.command("logout").description("Remove stored OAuth tokens for this server's URL").action(() => authLogoutCommand(name));
4364
4423
  cmd.addCommand(authCommand);
4424
+ cmd.addCommand(createPerClientScreenshotCommand(name));
4365
4425
  return cmd;
4366
4426
  }
4367
4427
 
@@ -9223,7 +9283,6 @@ program.addCommand(createClientCommand());
9223
9283
  program.addCommand(createDeploymentsCommand());
9224
9284
  program.addCommand(createServersCommand());
9225
9285
  program.addCommand(createSkillsCommand());
9226
- program.addCommand(createScreenshotCommand());
9227
9286
  program.command("generate-types").description(
9228
9287
  "Generate TypeScript type definitions for tools (writes .mcp-use/tool-registry.d.ts)"
9229
9288
  ).option("-p, --path <path>", "Path to project directory", process.cwd()).option("--server <file>", "Server entry file", "index.ts").action(async (options) => {