mcp-use 1.4.1 → 1.5.0-canary.1

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.
Files changed (44) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-RE7EYFDV.js → chunk-5XVM4A23.js} +446 -964
  3. package/dist/{chunk-35A6O3YH.js → chunk-MCF5P6GJ.js} +1 -1
  4. package/dist/{display-LIYVTGEU.js → display-YIYC6WJE.js} +77 -6
  5. package/dist/index.cjs +572 -1004
  6. package/dist/index.js +33 -12
  7. package/dist/src/agents/display.d.ts +5 -1
  8. package/dist/src/agents/display.d.ts.map +1 -1
  9. package/dist/src/agents/index.cjs +77 -6
  10. package/dist/src/agents/index.js +1 -1
  11. package/dist/src/browser.cjs +77 -6
  12. package/dist/src/browser.js +1 -1
  13. package/dist/src/client/codeExecutor.d.ts +1 -1
  14. package/dist/src/client/codeExecutor.d.ts.map +1 -1
  15. package/dist/src/client/executors/base.d.ts +10 -1
  16. package/dist/src/client/executors/base.d.ts.map +1 -1
  17. package/dist/src/client.d.ts +1 -1
  18. package/dist/src/client.d.ts.map +1 -1
  19. package/dist/src/react/ErrorBoundary.d.ts +24 -0
  20. package/dist/src/react/ErrorBoundary.d.ts.map +1 -0
  21. package/dist/src/react/Image.d.ts +11 -0
  22. package/dist/src/react/Image.d.ts.map +1 -0
  23. package/dist/src/react/McpUseProvider.d.ts +46 -0
  24. package/dist/src/react/McpUseProvider.d.ts.map +1 -0
  25. package/dist/src/react/ThemeProvider.d.ts +14 -0
  26. package/dist/src/react/ThemeProvider.d.ts.map +1 -0
  27. package/dist/src/react/WidgetControls.d.ts +44 -0
  28. package/dist/src/react/WidgetControls.d.ts.map +1 -0
  29. package/dist/src/react/index.cjs +474 -992
  30. package/dist/src/react/index.d.ts +9 -6
  31. package/dist/src/react/index.d.ts.map +1 -1
  32. package/dist/src/react/index.js +11 -5
  33. package/dist/src/react/useWidget.d.ts.map +1 -1
  34. package/dist/src/react/widget-types.d.ts +6 -0
  35. package/dist/src/react/widget-types.d.ts.map +1 -1
  36. package/dist/src/server/connect-adapter.d.ts.map +1 -1
  37. package/dist/src/server/index.cjs +232 -21
  38. package/dist/src/server/index.js +232 -21
  39. package/dist/src/server/mcp-server.d.ts.map +1 -1
  40. package/package.json +6 -4
  41. package/dist/src/react/WidgetDebugger.d.ts +0 -31
  42. package/dist/src/react/WidgetDebugger.d.ts.map +0 -1
  43. package/dist/src/react/WidgetFullscreenWrapper.d.ts +0 -32
  44. package/dist/src/react/WidgetFullscreenWrapper.d.ts.map +0 -1
@@ -2408,7 +2408,7 @@ var MCPAgent = class {
2408
2408
  * This method formats and displays tool executions in a user-friendly way with syntax highlighting.
2409
2409
  */
2410
2410
  async *prettyStreamEvents(query, maxSteps, manageConnector = true, externalHistory, outputSchema) {
2411
- const { prettyStreamEvents: prettyStream } = await import("./display-LIYVTGEU.js");
2411
+ const { prettyStreamEvents: prettyStream } = await import("./display-YIYC6WJE.js");
2412
2412
  const finalResponse = "";
2413
2413
  for await (const _ of prettyStream(
2414
2414
  this.streamEvents(
@@ -166,9 +166,27 @@ function extractToolMessageContent(output) {
166
166
  return null;
167
167
  }
168
168
  __name(extractToolMessageContent, "extractToolMessageContent");
169
- function formatSearchToolsAsTree(tools) {
169
+ function formatSearchToolsAsTree(tools, meta, query) {
170
+ const metaLines = [];
171
+ if (meta) {
172
+ if (meta.total_tools !== void 0) {
173
+ metaLines.push(`Total tools: ${meta.total_tools}`);
174
+ }
175
+ if (meta.namespaces && meta.namespaces.length > 0) {
176
+ metaLines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
177
+ }
178
+ if (meta.result_count !== void 0) {
179
+ metaLines.push(`Results: ${meta.result_count}`);
180
+ }
181
+ }
170
182
  if (!Array.isArray(tools) || tools.length === 0) {
171
- return "(no tools found)";
183
+ const noResultsMsg = query ? `No tools found for query "${query}"` : "(no tools found)";
184
+ if (metaLines.length > 0) {
185
+ return `${metaLines.join("\n")}
186
+
187
+ ${noResultsMsg}`;
188
+ }
189
+ return noResultsMsg;
172
190
  }
173
191
  const toolsByServer = {};
174
192
  for (const tool of tools) {
@@ -179,6 +197,20 @@ function formatSearchToolsAsTree(tools) {
179
197
  toolsByServer[server].push(tool);
180
198
  }
181
199
  const lines = [];
200
+ if (meta) {
201
+ if (meta.total_tools !== void 0) {
202
+ lines.push(`Total tools: ${meta.total_tools}`);
203
+ }
204
+ if (meta.namespaces && meta.namespaces.length > 0) {
205
+ lines.push(`Namespaces: ${meta.namespaces.join(", ")}`);
206
+ }
207
+ if (meta.result_count !== void 0) {
208
+ lines.push(`Results: ${meta.result_count}`);
209
+ }
210
+ if (lines.length > 0) {
211
+ lines.push("");
212
+ }
213
+ }
182
214
  const servers = Object.keys(toolsByServer).sort();
183
215
  for (let i = 0; i < servers.length; i++) {
184
216
  const server = servers[i];
@@ -193,11 +225,34 @@ function formatSearchToolsAsTree(tools) {
193
225
  const isLastTool = j === serverTools.length - 1;
194
226
  const indent = isLastServer ? " " : "\u2502 ";
195
227
  const toolPrefix = isLastTool ? "\u2514\u2500" : "\u251C\u2500";
196
- let toolLine = `${indent}${toolPrefix} ${tool.name}`;
228
+ const toolLine = `${indent}${toolPrefix} ${tool.name}`;
229
+ lines.push(toolLine);
197
230
  if (tool.description) {
198
- toolLine += chalk.dim(` - ${tool.description}`);
231
+ const descAlign = isLastTool ? " " : "\u2502 ";
232
+ const descriptionIndent = `${indent}${descAlign}`;
233
+ const indentLength = stripAnsi(descriptionIndent).length;
234
+ const availableWidth = Math.max(40, TERMINAL_WIDTH - indentLength - 4);
235
+ const words = tool.description.split(/(\s+)/);
236
+ const wrappedLines = [];
237
+ let currentLine = "";
238
+ for (const word of words) {
239
+ const testLine = currentLine + word;
240
+ if (stripAnsi(testLine).length <= availableWidth) {
241
+ currentLine = testLine;
242
+ } else {
243
+ if (currentLine) {
244
+ wrappedLines.push(currentLine.trimEnd());
245
+ }
246
+ currentLine = word.trimStart();
247
+ }
248
+ }
249
+ if (currentLine) {
250
+ wrappedLines.push(currentLine.trimEnd());
251
+ }
252
+ for (const descLine of wrappedLines) {
253
+ lines.push(`${descriptionIndent}${chalk.dim(descLine)}`);
254
+ }
199
255
  }
200
- lines.push(toolLine);
201
256
  }
202
257
  }
203
258
  return lines.join("\n");
@@ -242,6 +297,8 @@ function handleToolEnd(event) {
242
297
  }
243
298
  }
244
299
  if (toolName === "search_tools") {
300
+ const toolInput = event.data?.input;
301
+ const query = toolInput?.query;
245
302
  let actualContent = content;
246
303
  if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
247
304
  const innerContent = content.content;
@@ -255,8 +312,22 @@ function handleToolEnd(event) {
255
312
  }
256
313
  }
257
314
  }
315
+ if (typeof actualContent === "object" && actualContent !== null && !Array.isArray(actualContent) && "results" in actualContent && Array.isArray(actualContent.results)) {
316
+ const results = actualContent.results;
317
+ const contentWithMeta = actualContent;
318
+ const meta = contentWithMeta.meta;
319
+ const treeStr = formatSearchToolsAsTree(results, meta, query);
320
+ const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
321
+ const title2 = `${statusText}: ${toolName} - Result`;
322
+ printBox(treeStr, title2, void 0, false);
323
+ return;
324
+ }
258
325
  if (Array.isArray(actualContent)) {
259
- const treeStr = formatSearchToolsAsTree(actualContent);
326
+ const treeStr = formatSearchToolsAsTree(
327
+ actualContent,
328
+ void 0,
329
+ query
330
+ );
260
331
  const statusText = status === "success" ? chalk.green("Success") : chalk.red("Error");
261
332
  const title2 = `${statusText}: ${toolName} - Result`;
262
333
  printBox(treeStr, title2, void 0, false);