@mcp-use/cli 3.2.0-canary.12 → 3.2.0-canary.14
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/index.js
CHANGED
|
@@ -3259,6 +3259,11 @@ function parseDeviceScaleFactor(raw) {
|
|
|
3259
3259
|
}
|
|
3260
3260
|
return n;
|
|
3261
3261
|
}
|
|
3262
|
+
function requiresArguments(inputSchema) {
|
|
3263
|
+
if (!inputSchema || typeof inputSchema !== "object") return false;
|
|
3264
|
+
const required = inputSchema.required;
|
|
3265
|
+
return Array.isArray(required) && required.length > 0;
|
|
3266
|
+
}
|
|
3262
3267
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3263
3268
|
async function resolveSessionForScreenshot(options, sessionName, headers) {
|
|
3264
3269
|
if (sessionName) {
|
|
@@ -3387,6 +3392,18 @@ async function screenshotCommand(options, argsList, context) {
|
|
|
3387
3392
|
exitCode = 1;
|
|
3388
3393
|
return;
|
|
3389
3394
|
}
|
|
3395
|
+
} else if (requiresArguments(tool.inputSchema)) {
|
|
3396
|
+
console.error(formatError("This tool requires arguments."));
|
|
3397
|
+
console.log("");
|
|
3398
|
+
console.log(formatInfo("Provide arguments as key=value pairs:"));
|
|
3399
|
+
console.log(
|
|
3400
|
+
` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
|
|
3401
|
+
);
|
|
3402
|
+
console.log("");
|
|
3403
|
+
console.log(formatInfo("Tool schema:"));
|
|
3404
|
+
console.log(formatSchema(tool.inputSchema));
|
|
3405
|
+
exitCode = 1;
|
|
3406
|
+
return;
|
|
3390
3407
|
}
|
|
3391
3408
|
const toolOutput = await session.callTool(options.tool, toolArgs);
|
|
3392
3409
|
const result = await captureToolScreenshot(
|
|
@@ -3900,12 +3917,14 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3900
3917
|
const callResult = await session.callTool(toolName, args, {
|
|
3901
3918
|
timeout: options?.timeout
|
|
3902
3919
|
});
|
|
3920
|
+
const toolWithMeta = session.tools.find((t) => t.name === toolName);
|
|
3921
|
+
const resourceUri = detectToolResourceUri(toolWithMeta);
|
|
3922
|
+
const wantsScreenshot = options?.screenshot === true || options?.screenshotOutput !== void 0 || options?.screenshotDeviceScaleFactor !== void 0;
|
|
3903
3923
|
let screenshot = null;
|
|
3904
3924
|
let screenshotError = null;
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
if (resourceUri) {
|
|
3925
|
+
let widgetHintUri = null;
|
|
3926
|
+
if (resourceUri) {
|
|
3927
|
+
if (wantsScreenshot) {
|
|
3909
3928
|
console.error(
|
|
3910
3929
|
formatInfo(`Capturing widget screenshot (${resourceUri})...`)
|
|
3911
3930
|
);
|
|
@@ -3938,6 +3957,8 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3938
3957
|
} catch (err) {
|
|
3939
3958
|
screenshotError = err?.message ?? String(err);
|
|
3940
3959
|
}
|
|
3960
|
+
} else {
|
|
3961
|
+
widgetHintUri = resourceUri;
|
|
3941
3962
|
}
|
|
3942
3963
|
}
|
|
3943
3964
|
if (options?.json) {
|
|
@@ -3957,6 +3978,13 @@ async function callToolCommand(name, toolName, argsList, options) {
|
|
|
3957
3978
|
formatWarning(`Skipped widget screenshot: ${screenshotError}`)
|
|
3958
3979
|
);
|
|
3959
3980
|
}
|
|
3981
|
+
if (widgetHintUri) {
|
|
3982
|
+
console.error(
|
|
3983
|
+
formatInfo(
|
|
3984
|
+
`This tool renders a widget (${widgetHintUri}). Re-run with --screenshot to save a PNG of it.`
|
|
3985
|
+
)
|
|
3986
|
+
);
|
|
3987
|
+
}
|
|
3960
3988
|
if (callResult.isError) {
|
|
3961
3989
|
await cleanupAndExit(1);
|
|
3962
3990
|
}
|
|
@@ -4368,14 +4396,14 @@ function createPerClientCommand(name) {
|
|
|
4368
4396
|
toolsCommand.command("call <tool> [args...]").description(
|
|
4369
4397
|
"Call a tool. Args as key=value pairs (use key:=<json> for nested values, or pass a JSON object)"
|
|
4370
4398
|
).option("--timeout <ms>", "Request timeout in milliseconds", parseInt).option("--json", "Output as JSON").option(
|
|
4371
|
-
"--
|
|
4372
|
-
"
|
|
4399
|
+
"--screenshot",
|
|
4400
|
+
"Capture a PNG screenshot of the rendered widget for tools that declare a UI resource"
|
|
4373
4401
|
).option(
|
|
4374
4402
|
"--screenshot-output <path>",
|
|
4375
|
-
"Output PNG path for the widget screenshot (defaults to ./<view>-<timestamp>.png)"
|
|
4403
|
+
"Output PNG path for the widget screenshot (implies --screenshot; defaults to ./<view>-<timestamp>.png)"
|
|
4376
4404
|
).option(
|
|
4377
4405
|
"--screenshot-device-scale-factor <n>",
|
|
4378
|
-
"Device pixel ratio for the
|
|
4406
|
+
"Device pixel ratio for the widget screenshot (implies --screenshot; e.g. 2 for Retina). Defaults to 1."
|
|
4379
4407
|
).action(
|
|
4380
4408
|
(tool, args, options) => callToolCommand(name, tool, args, options)
|
|
4381
4409
|
);
|