@mcp-use/cli 3.5.2-canary.8 → 3.5.2-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.
@@ -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;AAqDpC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,aAMtC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,aAQ5B,CAAC;AAgiCH;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAyC7C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA2H5D"}
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;AA8iCH;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAyC7C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA2H5D"}
package/dist/index.cjs CHANGED
@@ -4046,6 +4046,71 @@ async function describeToolCommand(name, toolName) {
4046
4046
  }
4047
4047
  await cleanupAndExit(0);
4048
4048
  }
4049
+ async function processToolScreenshot(session, toolName, args, callResult, options) {
4050
+ const toolWithMeta = session.tools.find((t) => t.name === toolName);
4051
+ const resourceUri = detectToolResourceUri(toolWithMeta);
4052
+ const wantsScreenshot = options?.screenshot === true || options?.screenshotOutput !== void 0 || options?.screenshotDeviceScaleFactor !== void 0;
4053
+ let screenshot = null;
4054
+ let screenshotError = null;
4055
+ let widgetHintUri = null;
4056
+ if (resourceUri) {
4057
+ if (wantsScreenshot) {
4058
+ console.error(
4059
+ formatInfo(`Capturing widget screenshot (${resourceUri})...`)
4060
+ );
4061
+ try {
4062
+ const screenshotOpts = {};
4063
+ if (options?.screenshotOutput) {
4064
+ screenshotOpts.output = options.screenshotOutput;
4065
+ }
4066
+ if (options?.screenshotDeviceScaleFactor) {
4067
+ screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
4068
+ options.screenshotDeviceScaleFactor
4069
+ );
4070
+ }
4071
+ const shot = await captureToolScreenshot(
4072
+ {
4073
+ session,
4074
+ toolName,
4075
+ toolArgs: args,
4076
+ toolOutput: callResult,
4077
+ resourceUri
4078
+ },
4079
+ screenshotOpts
4080
+ );
4081
+ screenshot = {
4082
+ path: shot.outputPath,
4083
+ width: shot.width,
4084
+ height: shot.height,
4085
+ view: shot.view
4086
+ };
4087
+ } catch (err) {
4088
+ screenshotError = err?.message ?? String(err);
4089
+ }
4090
+ } else {
4091
+ widgetHintUri = resourceUri;
4092
+ }
4093
+ }
4094
+ if (screenshot) {
4095
+ console.error(
4096
+ formatSuccess(
4097
+ `Saved widget screenshot: ${screenshot.path} (${screenshot.width}\xD7${screenshot.height})`
4098
+ )
4099
+ );
4100
+ }
4101
+ if (screenshotError) {
4102
+ console.error(
4103
+ formatWarning(`Skipped widget screenshot: ${screenshotError}`)
4104
+ );
4105
+ }
4106
+ if (widgetHintUri) {
4107
+ console.error(
4108
+ formatInfo(
4109
+ `This tool renders a widget (${widgetHintUri}). Re-run with --screenshot to save a PNG of it.`
4110
+ )
4111
+ );
4112
+ }
4113
+ }
4049
4114
  async function callToolCommand(name, toolName, argsList, options) {
4050
4115
  try {
4051
4116
  const result = await getOrRestoreSession(name);
@@ -4095,74 +4160,12 @@ async function callToolCommand(name, toolName, argsList, options) {
4095
4160
  const callResult = await session.callTool(toolName, args, {
4096
4161
  timeout: options?.timeout
4097
4162
  });
4098
- const toolWithMeta = session.tools.find((t) => t.name === toolName);
4099
- const resourceUri = detectToolResourceUri(toolWithMeta);
4100
- const wantsScreenshot = options?.screenshot === true || options?.screenshotOutput !== void 0 || options?.screenshotDeviceScaleFactor !== void 0;
4101
- let screenshot = null;
4102
- let screenshotError = null;
4103
- let widgetHintUri = null;
4104
- if (resourceUri) {
4105
- if (wantsScreenshot) {
4106
- console.error(
4107
- formatInfo(`Capturing widget screenshot (${resourceUri})...`)
4108
- );
4109
- try {
4110
- const screenshotOpts = {};
4111
- if (options?.screenshotOutput) {
4112
- screenshotOpts.output = options.screenshotOutput;
4113
- }
4114
- if (options?.screenshotDeviceScaleFactor) {
4115
- screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
4116
- options.screenshotDeviceScaleFactor
4117
- );
4118
- }
4119
- const shot = await captureToolScreenshot(
4120
- {
4121
- session,
4122
- toolName,
4123
- toolArgs: args,
4124
- toolOutput: callResult,
4125
- resourceUri
4126
- },
4127
- screenshotOpts
4128
- );
4129
- screenshot = {
4130
- path: shot.outputPath,
4131
- width: shot.width,
4132
- height: shot.height,
4133
- view: shot.view
4134
- };
4135
- } catch (err) {
4136
- screenshotError = err?.message ?? String(err);
4137
- }
4138
- } else {
4139
- widgetHintUri = resourceUri;
4140
- }
4141
- }
4163
+ await processToolScreenshot(session, toolName, args, callResult, options);
4142
4164
  if (options?.json) {
4143
4165
  console.log(formatJson(callResult));
4144
4166
  } else {
4145
4167
  console.log(formatToolCall(callResult));
4146
4168
  }
4147
- if (screenshot) {
4148
- console.error(
4149
- formatSuccess(
4150
- `Saved widget screenshot: ${screenshot.path} (${screenshot.width}\xD7${screenshot.height})`
4151
- )
4152
- );
4153
- }
4154
- if (screenshotError) {
4155
- console.error(
4156
- formatWarning(`Skipped widget screenshot: ${screenshotError}`)
4157
- );
4158
- }
4159
- if (widgetHintUri) {
4160
- console.error(
4161
- formatInfo(
4162
- `This tool renders a widget (${widgetHintUri}). Re-run with --screenshot to save a PNG of it.`
4163
- )
4164
- );
4165
- }
4166
4169
  if (callResult.isError) {
4167
4170
  await cleanupAndExit(1);
4168
4171
  }
@@ -4392,7 +4395,7 @@ async function interactiveCommand(name) {
4392
4395
  console.log(source_default.gray(" tools list - List available tools"));
4393
4396
  console.log(
4394
4397
  source_default.gray(
4395
- " tools call <name> - Call a tool (will prompt for args)"
4398
+ " tools call <name> [--screenshot] - Call a tool (will prompt for args)"
4396
4399
  )
4397
4400
  );
4398
4401
  console.log(source_default.gray(" tools describe <name> - Show tool details"));
@@ -4439,6 +4442,7 @@ async function interactiveCommand(name) {
4439
4442
  )
4440
4443
  );
4441
4444
  } else if (command === "call" && arg) {
4445
+ const wantsScreenshot = parts.includes("--screenshot");
4442
4446
  rl.question(
4443
4447
  "Arguments (JSON, or press Enter for none): ",
4444
4448
  async (argsInput) => {
@@ -4446,6 +4450,9 @@ async function interactiveCommand(name) {
4446
4450
  const args = argsInput.trim() ? JSON.parse(argsInput) : {};
4447
4451
  const result2 = await session.callTool(arg, args);
4448
4452
  console.log(formatToolCall(result2));
4453
+ await processToolScreenshot(session, arg, args, result2, {
4454
+ screenshot: wantsScreenshot
4455
+ });
4449
4456
  } catch (error) {
4450
4457
  console.error(formatError(error.message));
4451
4458
  }