@mcp-use/cli 3.2.0-canary.10 → 3.2.0-canary.11
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.map +1 -1
- package/dist/commands/screenshot.d.ts +19 -3
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/index.cjs +57 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -30
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3245,9 +3245,9 @@ function parseDimension(raw, name) {
|
|
|
3245
3245
|
return n;
|
|
3246
3246
|
}
|
|
3247
3247
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3248
|
-
async function resolveSessionForScreenshot(options, headers) {
|
|
3249
|
-
if (
|
|
3250
|
-
const result = await getOrRestoreSession(
|
|
3248
|
+
async function resolveSessionForScreenshot(options, sessionName, headers) {
|
|
3249
|
+
if (sessionName) {
|
|
3250
|
+
const result = await getOrRestoreSession(sessionName);
|
|
3251
3251
|
return result?.session ?? null;
|
|
3252
3252
|
}
|
|
3253
3253
|
if (options.mcp) {
|
|
@@ -3269,12 +3269,12 @@ async function resolveSessionForScreenshot(options, headers) {
|
|
|
3269
3269
|
}
|
|
3270
3270
|
console.error(
|
|
3271
3271
|
formatError(
|
|
3272
|
-
"No MCP target. Pass --
|
|
3272
|
+
"No MCP target. Pass --mcp <url> for an ad-hoc connection, or use `mcp-use client <name> screenshot` for a saved server."
|
|
3273
3273
|
)
|
|
3274
3274
|
);
|
|
3275
3275
|
return null;
|
|
3276
3276
|
}
|
|
3277
|
-
async function screenshotCommand(options, argsList) {
|
|
3277
|
+
async function screenshotCommand(options, argsList, context) {
|
|
3278
3278
|
let exitCode = 0;
|
|
3279
3279
|
try {
|
|
3280
3280
|
if (!options.tool) {
|
|
@@ -3291,7 +3291,7 @@ async function screenshotCommand(options, argsList) {
|
|
|
3291
3291
|
if (!options.mcp) {
|
|
3292
3292
|
console.error(
|
|
3293
3293
|
formatError(
|
|
3294
|
-
"--header is only supported with --mcp <url>. Saved
|
|
3294
|
+
"--header is only supported with --mcp <url>. Saved servers carry their own auth from `mcp-use client connect`."
|
|
3295
3295
|
)
|
|
3296
3296
|
);
|
|
3297
3297
|
exitCode = 1;
|
|
@@ -3320,7 +3320,11 @@ async function screenshotCommand(options, argsList) {
|
|
|
3320
3320
|
const height = parseDimension(options.height, "height");
|
|
3321
3321
|
const navTimeout = parseInt(options.timeout, 10) || 3e4;
|
|
3322
3322
|
const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
|
|
3323
|
-
const session = await resolveSessionForScreenshot(
|
|
3323
|
+
const session = await resolveSessionForScreenshot(
|
|
3324
|
+
options,
|
|
3325
|
+
context.sessionName,
|
|
3326
|
+
headers
|
|
3327
|
+
);
|
|
3324
3328
|
if (!session) {
|
|
3325
3329
|
exitCode = 1;
|
|
3326
3330
|
return;
|
|
@@ -3351,13 +3355,13 @@ async function screenshotCommand(options, argsList) {
|
|
|
3351
3355
|
console.log("");
|
|
3352
3356
|
console.log(formatInfo("Usage:"));
|
|
3353
3357
|
console.log(
|
|
3354
|
-
` npx
|
|
3358
|
+
` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
|
|
3355
3359
|
);
|
|
3356
3360
|
console.log(
|
|
3357
|
-
` npx
|
|
3361
|
+
` npx ${context.usagePrefix} --tool ${options.tool} nested:='{"a":1}' # JSON value`
|
|
3358
3362
|
);
|
|
3359
3363
|
console.log(
|
|
3360
|
-
` npx
|
|
3364
|
+
` npx ${context.usagePrefix} --tool ${options.tool} '{"key":"value"}' # full JSON object`
|
|
3361
3365
|
);
|
|
3362
3366
|
if (tool.inputSchema) {
|
|
3363
3367
|
console.log("");
|
|
@@ -3401,10 +3405,8 @@ async function screenshotCommand(options, argsList) {
|
|
|
3401
3405
|
await cleanupAndExit(exitCode);
|
|
3402
3406
|
}
|
|
3403
3407
|
}
|
|
3404
|
-
function
|
|
3405
|
-
return
|
|
3406
|
-
"Render an MCP Apps view headlessly and save a PNG by calling a tool and rendering its UI resource with the result."
|
|
3407
|
-
).argument(
|
|
3408
|
+
function withCommonScreenshotOptions(cmd) {
|
|
3409
|
+
return cmd.argument(
|
|
3408
3410
|
"[args...]",
|
|
3409
3411
|
"Tool args as key=value pairs (use key:=<json> for nested values, or pass a single JSON object)."
|
|
3410
3412
|
).option(
|
|
@@ -3412,18 +3414,7 @@ function createScreenshotCommand() {
|
|
|
3412
3414
|
"Tool to call. Its UI resource is rendered with the result."
|
|
3413
3415
|
).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
|
|
3414
3416
|
"--inspector <url>",
|
|
3415
|
-
"Inspector host that serves /inspector/preview/:view. When omitted,
|
|
3416
|
-
).option(
|
|
3417
|
-
"--session <name>",
|
|
3418
|
-
"Saved server name (from `mcp-use client connect <name> <url>`)."
|
|
3419
|
-
).option(
|
|
3420
|
-
"--mcp <url>",
|
|
3421
|
-
"Ad-hoc MCP server URL (escape hatch). Use when you don't have a saved server. No authentication unless --header is supplied."
|
|
3422
|
-
).option(
|
|
3423
|
-
"-H, --header <header>",
|
|
3424
|
-
'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.',
|
|
3425
|
-
collectHeader,
|
|
3426
|
-
[]
|
|
3417
|
+
"Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
|
|
3427
3418
|
).option(
|
|
3428
3419
|
"--theme <light|dark>",
|
|
3429
3420
|
"Color scheme to render the view in.",
|
|
@@ -3441,9 +3432,42 @@ function createScreenshotCommand() {
|
|
|
3441
3432
|
).option("--timeout <ms>", "Navigation + readiness timeout in ms.", "30000").option(
|
|
3442
3433
|
"--cdp-url <url>",
|
|
3443
3434
|
"Connect to an existing CDP WebSocket (ws:// or wss://) instead of spawning local Chrome. Useful for hosted browsers like Notte."
|
|
3444
|
-
).option("--quiet", "Suppress dev-server output.")
|
|
3445
|
-
|
|
3435
|
+
).option("--quiet", "Suppress dev-server output.");
|
|
3436
|
+
}
|
|
3437
|
+
function createClientScreenshotCommand() {
|
|
3438
|
+
const cmd = withCommonScreenshotOptions(
|
|
3439
|
+
new Command("screenshot").description(
|
|
3440
|
+
"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`."
|
|
3441
|
+
)
|
|
3442
|
+
).option(
|
|
3443
|
+
"--mcp <url>",
|
|
3444
|
+
"Ad-hoc MCP server URL. Required for the top-level form. No authentication unless --header is supplied."
|
|
3445
|
+
).option(
|
|
3446
|
+
"-H, --header <header>",
|
|
3447
|
+
'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.',
|
|
3448
|
+
collectHeader,
|
|
3449
|
+
[]
|
|
3450
|
+
);
|
|
3451
|
+
cmd.action(async (args, opts) => {
|
|
3452
|
+
await screenshotCommand(opts, args, {
|
|
3453
|
+
usagePrefix: "mcp-use client screenshot"
|
|
3454
|
+
});
|
|
3446
3455
|
});
|
|
3456
|
+
return cmd;
|
|
3457
|
+
}
|
|
3458
|
+
function createPerClientScreenshotCommand(name) {
|
|
3459
|
+
const cmd = withCommonScreenshotOptions(
|
|
3460
|
+
new Command("screenshot").description(
|
|
3461
|
+
`Render an MCP Apps view headlessly using the saved server '${name}'.`
|
|
3462
|
+
)
|
|
3463
|
+
);
|
|
3464
|
+
cmd.action(async (args, opts) => {
|
|
3465
|
+
await screenshotCommand(opts, args, {
|
|
3466
|
+
sessionName: name,
|
|
3467
|
+
usagePrefix: `mcp-use client ${name} screenshot`
|
|
3468
|
+
});
|
|
3469
|
+
});
|
|
3470
|
+
return cmd;
|
|
3447
3471
|
}
|
|
3448
3472
|
|
|
3449
3473
|
// src/commands/client.ts
|
|
@@ -3451,6 +3475,7 @@ var RESERVED_CLIENT_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
|
3451
3475
|
"connect",
|
|
3452
3476
|
"list",
|
|
3453
3477
|
"remove",
|
|
3478
|
+
"screenshot",
|
|
3454
3479
|
"help"
|
|
3455
3480
|
]);
|
|
3456
3481
|
var PER_CLIENT_SCOPES = /* @__PURE__ */ new Set([
|
|
@@ -3459,7 +3484,8 @@ var PER_CLIENT_SCOPES = /* @__PURE__ */ new Set([
|
|
|
3459
3484
|
"prompts",
|
|
3460
3485
|
"auth",
|
|
3461
3486
|
"disconnect",
|
|
3462
|
-
"interactive"
|
|
3487
|
+
"interactive",
|
|
3488
|
+
"screenshot"
|
|
3463
3489
|
]);
|
|
3464
3490
|
async function connectCommand(name, urlOrCommand, options) {
|
|
3465
3491
|
if (!name || !urlOrCommand) {
|
|
@@ -4297,6 +4323,7 @@ function createClientCommand() {
|
|
|
4297
4323
|
clientCommand.command("remove <name>").description(
|
|
4298
4324
|
"Remove a saved server. Also clears any OAuth tokens for that URL, unless another saved server still uses it."
|
|
4299
4325
|
).action(removeClientCommand);
|
|
4326
|
+
clientCommand.addCommand(createClientScreenshotCommand());
|
|
4300
4327
|
return clientCommand;
|
|
4301
4328
|
}
|
|
4302
4329
|
function createPerClientCommand(name) {
|
|
@@ -4347,6 +4374,7 @@ function createPerClientCommand(name) {
|
|
|
4347
4374
|
authCommand.command("refresh").description("Force-refresh the OAuth access token").action(() => authRefreshCommand(name));
|
|
4348
4375
|
authCommand.command("logout").description("Remove stored OAuth tokens for this server's URL").action(() => authLogoutCommand(name));
|
|
4349
4376
|
cmd.addCommand(authCommand);
|
|
4377
|
+
cmd.addCommand(createPerClientScreenshotCommand(name));
|
|
4350
4378
|
return cmd;
|
|
4351
4379
|
}
|
|
4352
4380
|
|
|
@@ -9208,7 +9236,6 @@ program.addCommand(createClientCommand());
|
|
|
9208
9236
|
program.addCommand(createDeploymentsCommand());
|
|
9209
9237
|
program.addCommand(createServersCommand());
|
|
9210
9238
|
program.addCommand(createSkillsCommand());
|
|
9211
|
-
program.addCommand(createScreenshotCommand());
|
|
9212
9239
|
program.command("generate-types").description(
|
|
9213
9240
|
"Generate TypeScript type definitions for tools (writes .mcp-use/tool-registry.d.ts)"
|
|
9214
9241
|
).option("-p, --path <path>", "Path to project directory", process.cwd()).option("--server <file>", "Server entry file", "index.ts").action(async (options) => {
|