@mcp-use/cli 3.2.0-canary.7 → 3.2.0-canary.9
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/screenshot.d.ts +8 -0
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/index.cjs +55 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -14,7 +14,15 @@ interface ScreenshotOptions {
|
|
|
14
14
|
quiet?: boolean;
|
|
15
15
|
timeout: string;
|
|
16
16
|
cdpUrl?: string;
|
|
17
|
+
header?: string[];
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Curl-style `Key: Value` parser. Splits on the first `:` so values may
|
|
21
|
+
* contain colons, and trims both sides so `Authorization:Bearer xyz` and
|
|
22
|
+
* `Authorization: Bearer xyz` are equivalent.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseHeaderArg(raw: string): [string, string];
|
|
25
|
+
export declare function parseHeaderArgs(args: string[]): Record<string, string>;
|
|
18
26
|
/**
|
|
19
27
|
* Inspect a tool's `_meta` for the UI resource URI it renders, if any. Falls back
|
|
20
28
|
* to the OpenAI Apps `openai/outputTemplate` key for cross-ecosystem compatibility.
|
|
@@ -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,CAA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AAG,MAAM,CAMhE;AA2CD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,MAAM,EAAE,GAAG,SAAS,GAC7B,OAAO,CAAC,IAAI,CAAC,CA0If;AAED,wBAAgB,uBAAuB,IAAI,OAAO,CA4DjD"}
|
package/dist/index.cjs
CHANGED
|
@@ -3240,6 +3240,31 @@ function resolveChromePath() {
|
|
|
3240
3240
|
}
|
|
3241
3241
|
|
|
3242
3242
|
// src/commands/screenshot.ts
|
|
3243
|
+
function parseHeaderArg(raw) {
|
|
3244
|
+
const idx = raw.indexOf(":");
|
|
3245
|
+
if (idx === -1) {
|
|
3246
|
+
throw new Error(
|
|
3247
|
+
`Invalid --header value "${raw}". Expected "Key: Value" (e.g. "Authorization: Bearer xyz").`
|
|
3248
|
+
);
|
|
3249
|
+
}
|
|
3250
|
+
const key = raw.slice(0, idx).trim();
|
|
3251
|
+
const value = raw.slice(idx + 1).trim();
|
|
3252
|
+
if (!key) {
|
|
3253
|
+
throw new Error(`Invalid --header value "${raw}". Header name is empty.`);
|
|
3254
|
+
}
|
|
3255
|
+
return [key, value];
|
|
3256
|
+
}
|
|
3257
|
+
function parseHeaderArgs(args) {
|
|
3258
|
+
const headers = {};
|
|
3259
|
+
for (const raw of args) {
|
|
3260
|
+
const [key, value] = parseHeaderArg(raw);
|
|
3261
|
+
headers[key] = value;
|
|
3262
|
+
}
|
|
3263
|
+
return headers;
|
|
3264
|
+
}
|
|
3265
|
+
function collectHeader(value, previous = []) {
|
|
3266
|
+
return previous.concat([value]);
|
|
3267
|
+
}
|
|
3243
3268
|
function detectToolResourceUri(tool) {
|
|
3244
3269
|
if (!tool) return null;
|
|
3245
3270
|
const meta = tool._meta;
|
|
@@ -3435,7 +3460,7 @@ function parseDimension(raw, name) {
|
|
|
3435
3460
|
return n;
|
|
3436
3461
|
}
|
|
3437
3462
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3438
|
-
async function resolveSessionForScreenshot(options) {
|
|
3463
|
+
async function resolveSessionForScreenshot(options, headers) {
|
|
3439
3464
|
if (options.session) {
|
|
3440
3465
|
const result2 = await getOrRestoreSession(options.session);
|
|
3441
3466
|
return result2?.session ?? null;
|
|
@@ -3444,6 +3469,7 @@ async function resolveSessionForScreenshot(options) {
|
|
|
3444
3469
|
const client = new import_client2.MCPClient();
|
|
3445
3470
|
client.addServer(AD_HOC_SESSION_NAME, {
|
|
3446
3471
|
url: options.mcp,
|
|
3472
|
+
...headers ? { headers } : {},
|
|
3447
3473
|
clientInfo: getCliClientInfo()
|
|
3448
3474
|
});
|
|
3449
3475
|
try {
|
|
@@ -3471,6 +3497,27 @@ async function screenshotCommand(options, argsList) {
|
|
|
3471
3497
|
exitCode = 1;
|
|
3472
3498
|
return;
|
|
3473
3499
|
}
|
|
3500
|
+
let headers;
|
|
3501
|
+
if (options.header && options.header.length > 0) {
|
|
3502
|
+
if (!options.mcp) {
|
|
3503
|
+
console.error(
|
|
3504
|
+
formatError(
|
|
3505
|
+
"--header is only supported with --mcp <url>. Saved sessions (use --session) carry their own auth from `mcp-use client connect`."
|
|
3506
|
+
)
|
|
3507
|
+
);
|
|
3508
|
+
exitCode = 1;
|
|
3509
|
+
return;
|
|
3510
|
+
}
|
|
3511
|
+
try {
|
|
3512
|
+
headers = parseHeaderArgs(options.header);
|
|
3513
|
+
} catch (err) {
|
|
3514
|
+
console.error(
|
|
3515
|
+
formatError(err instanceof Error ? err.message : String(err))
|
|
3516
|
+
);
|
|
3517
|
+
exitCode = 1;
|
|
3518
|
+
return;
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3474
3521
|
try {
|
|
3475
3522
|
resolveChromePath();
|
|
3476
3523
|
} catch (err) {
|
|
@@ -3484,7 +3531,7 @@ async function screenshotCommand(options, argsList) {
|
|
|
3484
3531
|
const height = parseDimension(options.height, "height");
|
|
3485
3532
|
const navTimeout = parseInt(options.timeout, 10) || 3e4;
|
|
3486
3533
|
const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
|
|
3487
|
-
const session = await resolveSessionForScreenshot(options);
|
|
3534
|
+
const session = await resolveSessionForScreenshot(options, headers);
|
|
3488
3535
|
if (!session) {
|
|
3489
3536
|
exitCode = 1;
|
|
3490
3537
|
return;
|
|
@@ -3582,7 +3629,12 @@ function createScreenshotCommand() {
|
|
|
3582
3629
|
"Saved session name (from `mcp-use client connect`). Defaults to the active session."
|
|
3583
3630
|
).option(
|
|
3584
3631
|
"--mcp <url>",
|
|
3585
|
-
"Ad-hoc MCP server URL (escape hatch). Used only when no --session and no active saved session. No authentication."
|
|
3632
|
+
"Ad-hoc MCP server URL (escape hatch). Used only when no --session and no active saved session. No authentication unless --header is supplied."
|
|
3633
|
+
).option(
|
|
3634
|
+
"-H, --header <header>",
|
|
3635
|
+
'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.',
|
|
3636
|
+
collectHeader,
|
|
3637
|
+
[]
|
|
3586
3638
|
).option(
|
|
3587
3639
|
"--theme <light|dark>",
|
|
3588
3640
|
"Color scheme to render the view in.",
|