mcp-use 1.3.4-canary.2 → 1.4.0-canary.3

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 (41) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{chunk-6EHM3S3M.js → chunk-35A6O3YH.js} +52 -10
  3. package/dist/chunk-DSBKVAWD.js +263 -0
  4. package/dist/{chunk-TIUSJAAE.js → chunk-GRLCLVAK.js} +3 -254
  5. package/dist/{chunk-QKPVHYJU.js → chunk-RE7EYFDV.js} +1 -1
  6. package/dist/chunk-WERYJ6PF.js +209 -0
  7. package/dist/chunk-ZFZPZ4GE.js +21 -0
  8. package/dist/display-LIYVTGEU.js +350 -0
  9. package/dist/index.cjs +1539 -284
  10. package/dist/index.d.ts +5 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +686 -22
  13. package/dist/src/agents/display.d.ts +54 -0
  14. package/dist/src/agents/display.d.ts.map +1 -0
  15. package/dist/src/agents/index.cjs +504 -10
  16. package/dist/src/agents/index.d.ts +1 -0
  17. package/dist/src/agents/index.d.ts.map +1 -1
  18. package/dist/src/agents/index.js +10 -18
  19. package/dist/src/agents/mcp_agent.d.ts +5 -0
  20. package/dist/src/agents/mcp_agent.d.ts.map +1 -1
  21. package/dist/src/browser.cjs +406 -10
  22. package/dist/src/browser.js +10 -8
  23. package/dist/src/client/codeExecutor.d.ts +6 -0
  24. package/dist/src/client/codeExecutor.d.ts.map +1 -0
  25. package/dist/src/client/connectors/codeMode.d.ts +27 -0
  26. package/dist/src/client/connectors/codeMode.d.ts.map +1 -0
  27. package/dist/src/client/executors/base.d.ts +56 -0
  28. package/dist/src/client/executors/base.d.ts.map +1 -0
  29. package/dist/src/client/executors/e2b.d.ts +46 -0
  30. package/dist/src/client/executors/e2b.d.ts.map +1 -0
  31. package/dist/src/client/executors/vm.d.ts +30 -0
  32. package/dist/src/client/executors/vm.d.ts.map +1 -0
  33. package/dist/src/client/prompts.cjs +401 -0
  34. package/dist/src/client/prompts.d.ts +13 -0
  35. package/dist/src/client/prompts.d.ts.map +1 -0
  36. package/dist/src/client/prompts.js +9 -0
  37. package/dist/src/client.d.ts +51 -4
  38. package/dist/src/client.d.ts.map +1 -1
  39. package/dist/src/react/index.js +3 -2
  40. package/dist/tsup.config.d.ts.map +1 -1
  41. package/package.json +14 -4
@@ -234,6 +234,11 @@ export declare class MCPAgent {
234
234
  */
235
235
  flush(): Promise<void>;
236
236
  close(): Promise<void>;
237
+ /**
238
+ * Yields with pretty-printed output for code mode.
239
+ * This method formats and displays tool executions in a user-friendly way with syntax highlighting.
240
+ */
241
+ prettyStreamEvents<T = string>(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: BaseMessage[], outputSchema?: ZodSchema<T>): AsyncGenerator<void, string, void>;
237
242
  /**
238
243
  * Yields LangChain StreamEvent objects from the underlying streamEvents() method.
239
244
  * This provides token-level streaming and fine-grained event updates.
@@ -1 +1 @@
1
- {"version":3,"file":"mcp_agent.d.ts","sourceRoot":"","sources":["../../../src/agents/mcp_agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,KAAK,EACV,0BAA0B,EAC1B,iBAAiB,EAClB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAKL,aAAa,EAId,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,aAAa,E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EACb,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,UAAO,EACtB,eAAe,CAAC,EAAE,WAAW,EAAE,EAC/B,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAC1B,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC;IA6R1C;;;;;;OAMG;YACW,wBAAwB;IAmLtC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA2CjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;CA2BhC"}
@@ -559,6 +559,360 @@ var init_langfuse = __esm({
559
559
  }
560
560
  });
561
561
 
562
+ // src/agents/display.ts
563
+ var display_exports = {};
564
+ __export(display_exports, {
565
+ extractCodeFromToolInput: () => extractCodeFromToolInput,
566
+ extractToolMessageContent: () => extractToolMessageContent,
567
+ formatSearchToolsAsTree: () => formatSearchToolsAsTree,
568
+ handleToolEnd: () => handleToolEnd,
569
+ handleToolStart: () => handleToolStart,
570
+ parseExecuteCodeResult: () => parseExecuteCodeResult,
571
+ prettyStreamEvents: () => prettyStreamEvents,
572
+ printBox: () => printBox,
573
+ renderContent: () => renderContent,
574
+ unwrapToolInput: () => unwrapToolInput
575
+ });
576
+ function stripAnsi(str) {
577
+ return (0, import_strip_ansi.default)(str);
578
+ }
579
+ function wrapAnsiLine(line, maxWidth) {
580
+ const stripped = stripAnsi(line);
581
+ if (stripped.length <= maxWidth) return [line];
582
+ const result = [];
583
+ let visibleCount = 0;
584
+ let current = "";
585
+ let i = 0;
586
+ while (i < line.length) {
587
+ const char = line[i];
588
+ if (char === "\x1B") {
589
+ let sequence = char;
590
+ i++;
591
+ while (i < line.length) {
592
+ const nextChar = line[i];
593
+ sequence += nextChar;
594
+ i++;
595
+ if (nextChar === "m") break;
596
+ }
597
+ current += sequence;
598
+ continue;
599
+ }
600
+ current += char;
601
+ visibleCount++;
602
+ i++;
603
+ if (visibleCount >= maxWidth) {
604
+ result.push(current);
605
+ current = "";
606
+ visibleCount = 0;
607
+ }
608
+ }
609
+ if (current) result.push(current);
610
+ return result;
611
+ }
612
+ function printBox(content, title, language, bgColor = false) {
613
+ const width = TERMINAL_WIDTH;
614
+ let displayContent = content;
615
+ if (language) {
616
+ try {
617
+ displayContent = (0, import_cli_highlight.highlight)(content, { language, ignoreIllegals: true });
618
+ } catch {
619
+ }
620
+ }
621
+ const lines = displayContent.split("\n").flatMap((line) => wrapAnsiLine(line, width - 4));
622
+ console.log(import_chalk.default.gray("\u250C" + "\u2500".repeat(width - 2) + "\u2510"));
623
+ if (title) {
624
+ const stripped = stripAnsi(title);
625
+ const lineText = `${title} `;
626
+ const padding = Math.max(0, width - 4 - stripped.length - 2);
627
+ console.log(
628
+ import_chalk.default.gray("\u2502 ") + import_chalk.default.bold.white(lineText) + " ".repeat(padding) + import_chalk.default.gray(" \u2502")
629
+ );
630
+ console.log(import_chalk.default.gray("\u251C" + "\u2500".repeat(width - 2) + "\u2524"));
631
+ }
632
+ lines.forEach((line) => {
633
+ const stripped = stripAnsi(line);
634
+ const padding = Math.max(0, width - 4 - stripped.length);
635
+ const finalLine = bgColor ? import_chalk.default.bgGray(line + " ".repeat(padding)) : line + " ".repeat(padding);
636
+ console.log(import_chalk.default.gray("\u2502 ") + finalLine + import_chalk.default.gray(" \u2502"));
637
+ });
638
+ console.log(import_chalk.default.gray("\u2514" + "\u2500".repeat(width - 2) + "\u2518"));
639
+ }
640
+ function extractCodeFromToolInput(input) {
641
+ if (typeof input === "object" && input !== null && "code" in input) {
642
+ const inputObj = input;
643
+ return typeof inputObj.code === "string" ? inputObj.code : null;
644
+ }
645
+ return null;
646
+ }
647
+ function isExecuteCodeResult(obj) {
648
+ if (typeof obj !== "object" || obj === null) return false;
649
+ const result = obj;
650
+ return "result" in result && "logs" in result && Array.isArray(result.logs) && "execution_time" in result && typeof result.execution_time === "number" && "error" in result && (typeof result.error === "string" || result.error === null);
651
+ }
652
+ function parseExecuteCodeResult(output) {
653
+ try {
654
+ if (typeof output === "string") {
655
+ const parsed = JSON.parse(output);
656
+ if (isExecuteCodeResult(parsed)) {
657
+ return parsed;
658
+ }
659
+ }
660
+ if (isExecuteCodeResult(output)) {
661
+ return output;
662
+ }
663
+ } catch (e) {
664
+ }
665
+ return null;
666
+ }
667
+ function renderContent(content) {
668
+ if (content === null || content === void 0) {
669
+ return "null";
670
+ }
671
+ if (typeof content === "object") {
672
+ return JSON.stringify(content, null, 2);
673
+ }
674
+ return String(content);
675
+ }
676
+ function unwrapToolInput(input) {
677
+ if (typeof input === "object" && input !== null && "input" in input) {
678
+ const inputObj = input;
679
+ if (typeof inputObj.input === "string") {
680
+ try {
681
+ return JSON.parse(inputObj.input);
682
+ } catch (e) {
683
+ return inputObj.input;
684
+ }
685
+ }
686
+ }
687
+ return input;
688
+ }
689
+ function handleToolStart(event) {
690
+ const toolName = event.name || "unknown";
691
+ let input = event.data?.input || {};
692
+ input = unwrapToolInput(input);
693
+ const code = extractCodeFromToolInput(input);
694
+ if (code) {
695
+ printBox(code, `${toolName} - input`, "javascript", false);
696
+ const otherParams = { ...input };
697
+ delete otherParams.code;
698
+ if (Object.keys(otherParams).length > 0) {
699
+ printBox(renderContent(otherParams), "Other Parameters", "json", false);
700
+ }
701
+ } else {
702
+ printBox(renderContent(input), `${toolName} - input`, "json", false);
703
+ }
704
+ }
705
+ function extractToolMessageContent(output) {
706
+ try {
707
+ if (typeof output === "object" && output !== null && "name" in output && "content" in output) {
708
+ const outputObj = output;
709
+ const toolName = (typeof outputObj.name === "string" ? outputObj.name : null) || "unknown";
710
+ const lcKwargs = outputObj.lc_kwargs;
711
+ const status = lcKwargs?.status || outputObj.status || "unknown";
712
+ let content = outputObj.content;
713
+ if (typeof content === "string") {
714
+ try {
715
+ content = JSON.parse(content);
716
+ } catch (e) {
717
+ }
718
+ }
719
+ return { toolName, status, content };
720
+ }
721
+ } catch (e) {
722
+ }
723
+ return null;
724
+ }
725
+ function formatSearchToolsAsTree(tools) {
726
+ if (!Array.isArray(tools) || tools.length === 0) {
727
+ return "(no tools found)";
728
+ }
729
+ const toolsByServer = {};
730
+ for (const tool of tools) {
731
+ const server = tool.server || "unknown";
732
+ if (!toolsByServer[server]) {
733
+ toolsByServer[server] = [];
734
+ }
735
+ toolsByServer[server].push(tool);
736
+ }
737
+ const lines = [];
738
+ const servers = Object.keys(toolsByServer).sort();
739
+ for (let i = 0; i < servers.length; i++) {
740
+ const server = servers[i];
741
+ const serverTools = toolsByServer[server];
742
+ const isLastServer = i === servers.length - 1;
743
+ const serverPrefix = isLastServer ? "\u2514\u2500" : "\u251C\u2500";
744
+ lines.push(
745
+ `${serverPrefix} ${import_chalk.default.cyan(server)} (${serverTools.length} tools)`
746
+ );
747
+ for (let j = 0; j < serverTools.length; j++) {
748
+ const tool = serverTools[j];
749
+ const isLastTool = j === serverTools.length - 1;
750
+ const indent = isLastServer ? " " : "\u2502 ";
751
+ const toolPrefix = isLastTool ? "\u2514\u2500" : "\u251C\u2500";
752
+ let toolLine = `${indent}${toolPrefix} ${tool.name}`;
753
+ if (tool.description) {
754
+ toolLine += import_chalk.default.dim(` - ${tool.description}`);
755
+ }
756
+ lines.push(toolLine);
757
+ }
758
+ }
759
+ return lines.join("\n");
760
+ }
761
+ function handleToolEnd(event) {
762
+ const output = event.data?.output;
763
+ const toolMessage = extractToolMessageContent(output);
764
+ if (toolMessage) {
765
+ const { toolName, status, content } = toolMessage;
766
+ if (toolName === "execute_code") {
767
+ let actualContent = content;
768
+ if (typeof content === "object" && content !== null && "content" in content) {
769
+ const innerContent = content.content;
770
+ if (Array.isArray(innerContent) && innerContent.length > 0) {
771
+ if (innerContent[0].type === "text" && innerContent[0].text) {
772
+ actualContent = innerContent[0].text;
773
+ }
774
+ }
775
+ }
776
+ const execResult2 = parseExecuteCodeResult(actualContent);
777
+ if (execResult2) {
778
+ const timeMs = execResult2.execution_time ? Math.round(execResult2.execution_time * 1e3) : 0;
779
+ const timeStr = `${timeMs}ms`;
780
+ const isError2 = execResult2.error !== null && execResult2.error !== void 0 && execResult2.error !== "";
781
+ const statusText = isError2 ? import_chalk.default.red("error") : import_chalk.default.green("success");
782
+ const title2 = `${toolName} - ${statusText} - ${timeStr}`;
783
+ if (execResult2.result !== null && execResult2.result !== void 0) {
784
+ const resultStr = renderContent(execResult2.result);
785
+ const language3 = typeof execResult2.result === "object" ? "json" : void 0;
786
+ printBox(resultStr, title2, language3, false);
787
+ } else {
788
+ printBox("(no result)", title2, void 0, false);
789
+ }
790
+ if (execResult2.logs && execResult2.logs.length > 0) {
791
+ printBox(execResult2.logs.join("\n"), `Logs`, void 0, false);
792
+ }
793
+ if (execResult2.error) {
794
+ printBox(execResult2.error, import_chalk.default.red("Error"), void 0, false);
795
+ }
796
+ return;
797
+ }
798
+ }
799
+ if (toolName === "search_tools") {
800
+ let actualContent = content;
801
+ if (typeof content === "object" && content !== null && !Array.isArray(content) && "content" in content) {
802
+ const innerContent = content.content;
803
+ if (Array.isArray(innerContent) && innerContent.length > 0) {
804
+ if (innerContent[0].type === "text" && innerContent[0].text) {
805
+ try {
806
+ actualContent = JSON.parse(innerContent[0].text);
807
+ } catch (e) {
808
+ actualContent = innerContent[0].text;
809
+ }
810
+ }
811
+ }
812
+ }
813
+ if (Array.isArray(actualContent)) {
814
+ const treeStr = formatSearchToolsAsTree(actualContent);
815
+ const statusText = status === "success" ? import_chalk.default.green("Success") : import_chalk.default.red("Error");
816
+ const title2 = `${statusText}: ${toolName} - Result`;
817
+ printBox(treeStr, title2, void 0, false);
818
+ return;
819
+ }
820
+ }
821
+ const contentObj = typeof content === "object" && content !== null ? content : null;
822
+ const isError = contentObj && "isError" in contentObj && contentObj.isError === true || status === "error";
823
+ let displayContent = content;
824
+ if (typeof content === "object" && content !== null && "content" in content) {
825
+ displayContent = content.content;
826
+ if (Array.isArray(displayContent) && displayContent.length > 0) {
827
+ if (displayContent[0].type === "text" && displayContent[0].text) {
828
+ displayContent = displayContent[0].text;
829
+ }
830
+ }
831
+ }
832
+ const contentStr = renderContent(displayContent);
833
+ const language2 = typeof displayContent === "object" ? "json" : void 0;
834
+ const statusLabel = status === "success" ? import_chalk.default.green("Success") : isError ? import_chalk.default.red("Error") : "Result";
835
+ const title = `${statusLabel}: ${toolName} - Result`;
836
+ printBox(contentStr, title, language2, false);
837
+ return;
838
+ }
839
+ const execResult = parseExecuteCodeResult(output);
840
+ if (execResult) {
841
+ const timeMs = execResult.execution_time ? Math.round(execResult.execution_time * 1e3) : 0;
842
+ const timeStr = `${timeMs}ms`;
843
+ if (execResult.result !== null && execResult.result !== void 0) {
844
+ const resultStr = renderContent(execResult.result);
845
+ const language2 = typeof execResult.result === "object" ? "json" : void 0;
846
+ printBox(resultStr, `Result - ${timeStr}`, language2, false);
847
+ }
848
+ if (execResult.logs && execResult.logs.length > 0) {
849
+ printBox(execResult.logs.join("\n"), `Logs`, void 0, false);
850
+ }
851
+ if (execResult.error) {
852
+ printBox(execResult.error, import_chalk.default.red("Error"), void 0, false);
853
+ }
854
+ return;
855
+ }
856
+ const outputStr = renderContent(output);
857
+ const language = typeof output === "object" ? "json" : void 0;
858
+ printBox(outputStr, "Result", language, false);
859
+ }
860
+ async function* prettyStreamEvents(streamEventsGenerator) {
861
+ let finalResponse = "";
862
+ let isFirstTextChunk = true;
863
+ let hasStreamedText = false;
864
+ for await (const event of streamEventsGenerator) {
865
+ if (event.event === "on_tool_start") {
866
+ if (hasStreamedText) {
867
+ process.stdout.write("\n");
868
+ hasStreamedText = false;
869
+ isFirstTextChunk = true;
870
+ }
871
+ handleToolStart(event);
872
+ } else if (event.event === "on_tool_end") {
873
+ handleToolEnd(event);
874
+ } else if (event.event === "on_chat_model_stream") {
875
+ if (event.data?.chunk?.text) {
876
+ const text = event.data.chunk.text;
877
+ if (typeof text === "string" && text.length > 0) {
878
+ if (isFirstTextChunk) {
879
+ process.stdout.write("\n\u{1F916} ");
880
+ isFirstTextChunk = false;
881
+ }
882
+ process.stdout.write(text);
883
+ finalResponse += text;
884
+ hasStreamedText = true;
885
+ }
886
+ }
887
+ }
888
+ yield;
889
+ }
890
+ return finalResponse;
891
+ }
892
+ var import_chalk, import_cli_highlight, import_strip_ansi, TERMINAL_WIDTH;
893
+ var init_display = __esm({
894
+ "src/agents/display.ts"() {
895
+ "use strict";
896
+ import_chalk = __toESM(require("chalk"), 1);
897
+ import_cli_highlight = require("cli-highlight");
898
+ import_strip_ansi = __toESM(require("strip-ansi"), 1);
899
+ TERMINAL_WIDTH = process.stdout.columns || 120;
900
+ __name(stripAnsi, "stripAnsi");
901
+ __name(wrapAnsiLine, "wrapAnsiLine");
902
+ __name(printBox, "printBox");
903
+ __name(extractCodeFromToolInput, "extractCodeFromToolInput");
904
+ __name(isExecuteCodeResult, "isExecuteCodeResult");
905
+ __name(parseExecuteCodeResult, "parseExecuteCodeResult");
906
+ __name(renderContent, "renderContent");
907
+ __name(unwrapToolInput, "unwrapToolInput");
908
+ __name(handleToolStart, "handleToolStart");
909
+ __name(extractToolMessageContent, "extractToolMessageContent");
910
+ __name(formatSearchToolsAsTree, "formatSearchToolsAsTree");
911
+ __name(handleToolEnd, "handleToolEnd");
912
+ __name(prettyStreamEvents, "prettyStreamEvents");
913
+ }
914
+ });
915
+
562
916
  // src/browser.ts
563
917
  var browser_exports = {};
564
918
  __export(browser_exports, {
@@ -3233,18 +3587,35 @@ var MCPAgent = class {
3233
3587
  logger.info(
3234
3588
  `\u{1F50C} Found ${Object.keys(this.sessions).length} existing sessions`
3235
3589
  );
3236
- if (Object.keys(this.sessions).length === 0) {
3590
+ const nonCodeModeSessions = Object.keys(this.sessions).filter(
3591
+ (name) => name !== "code_mode"
3592
+ );
3593
+ if (nonCodeModeSessions.length === 0) {
3237
3594
  logger.info("\u{1F504} No active sessions found, creating new ones...");
3238
3595
  this.sessions = await this.client.createAllSessions();
3239
3596
  logger.info(
3240
3597
  `\u2705 Created ${Object.keys(this.sessions).length} new sessions`
3241
3598
  );
3242
3599
  }
3243
- this._tools = await LangChainAdapter.createTools(this.client);
3600
+ if (this.client.codeMode) {
3601
+ const codeModeSession = this.sessions["code_mode"];
3602
+ if (codeModeSession) {
3603
+ this._tools = await this.adapter.createToolsFromConnectors([
3604
+ codeModeSession.connector
3605
+ ]);
3606
+ logger.info(`\u{1F6E0}\uFE0F Created ${this._tools.length} code mode tools`);
3607
+ } else {
3608
+ throw new Error(
3609
+ "Code mode enabled but code_mode session not found"
3610
+ );
3611
+ }
3612
+ } else {
3613
+ this._tools = await LangChainAdapter.createTools(this.client);
3614
+ logger.info(
3615
+ `\u{1F6E0}\uFE0F Created ${this._tools.length} LangChain tools from client`
3616
+ );
3617
+ }
3244
3618
  this._tools.push(...this.additionalTools);
3245
- logger.info(
3246
- `\u{1F6E0}\uFE0F Created ${this._tools.length} LangChain tools from client`
3247
- );
3248
3619
  } else {
3249
3620
  logger.info(
3250
3621
  `\u{1F517} Connecting to ${this.connectors.length} direct connectors...`
@@ -3809,6 +4180,8 @@ var MCPAgent = class {
3809
4180
  tags: this.getTags(),
3810
4181
  // Set trace name for LangChain/Langfuse
3811
4182
  runName: this.metadata.trace_name || "mcp-use-agent",
4183
+ // Set recursion limit to 3x maxSteps to account for model calls + tool executions
4184
+ recursionLimit: this.maxSteps * 3,
3812
4185
  // Pass sessionId for Langfuse if present in metadata
3813
4186
  ...this.metadata.session_id && {
3814
4187
  sessionId: this.metadata.session_id
@@ -4022,8 +4395,8 @@ var MCPAgent = class {
4022
4395
  this._agentExecutor = null;
4023
4396
  this._tools = [];
4024
4397
  if (this.client) {
4025
- logger.info("\u{1F504} Closing sessions through client");
4026
- await this.client.closeAllSessions();
4398
+ logger.info("\u{1F504} Closing client and cleaning up resources");
4399
+ await this.client.close();
4027
4400
  this.sessions = {};
4028
4401
  } else {
4029
4402
  for (const connector of this.connectors) {
@@ -4039,6 +4412,26 @@ var MCPAgent = class {
4039
4412
  logger.info("\u{1F44B} Agent closed successfully");
4040
4413
  }
4041
4414
  }
4415
+ /**
4416
+ * Yields with pretty-printed output for code mode.
4417
+ * This method formats and displays tool executions in a user-friendly way with syntax highlighting.
4418
+ */
4419
+ async *prettyStreamEvents(query, maxSteps, manageConnector = true, externalHistory, outputSchema) {
4420
+ const { prettyStreamEvents: prettyStream } = await Promise.resolve().then(() => (init_display(), display_exports));
4421
+ const finalResponse = "";
4422
+ for await (const _ of prettyStream(
4423
+ this.streamEvents(
4424
+ query,
4425
+ maxSteps,
4426
+ manageConnector,
4427
+ externalHistory,
4428
+ outputSchema
4429
+ )
4430
+ )) {
4431
+ yield;
4432
+ }
4433
+ return finalResponse;
4434
+ }
4042
4435
  /**
4043
4436
  * Yields LangChain StreamEvent objects from the underlying streamEvents() method.
4044
4437
  * This provides token-level streaming and fine-grained event updates.
@@ -4066,11 +4459,11 @@ var MCPAgent = class {
4066
4459
  throw new Error("MCP agent failed to initialize");
4067
4460
  }
4068
4461
  this.maxSteps = maxSteps ?? this.maxSteps;
4069
- const display_query = query.length > 50 ? `${query.slice(0, 50).replace(/\n/g, " ")}...` : query.replace(/\n/g, " ");
4462
+ const display_query = typeof query === "string" && query.length > 50 ? `${query.slice(0, 50).replace(/\n/g, " ")}...` : typeof query === "string" ? query.replace(/\n/g, " ") : String(query);
4070
4463
  logger.info(`\u{1F4AC} Received query for streamEvents: '${display_query}'`);
4071
4464
  if (this.memoryEnabled) {
4072
- logger.info(`\u{1F504} Adding user message to history: ${query}`);
4073
- this.addToHistory(new import_langchain2.HumanMessage(query));
4465
+ logger.info(`\u{1F504} Adding user message to history: ${display_query}`);
4466
+ this.addToHistory(new import_langchain2.HumanMessage({ content: query }));
4074
4467
  }
4075
4468
  const historyToUse = externalHistory ?? this.conversationHistory;
4076
4469
  const langchainHistory = [];
@@ -4098,6 +4491,8 @@ var MCPAgent = class {
4098
4491
  tags: this.getTags(),
4099
4492
  // Set trace name for LangChain/Langfuse
4100
4493
  runName: this.metadata.trace_name || "mcp-use-agent",
4494
+ // Set recursion limit to 3x maxSteps to account for model calls + tool executions
4495
+ recursionLimit: this.maxSteps * 3,
4101
4496
  // Pass sessionId for Langfuse if present in metadata
4102
4497
  ...this.metadata.session_id && {
4103
4498
  sessionId: this.metadata.session_id
@@ -4197,6 +4592,7 @@ var MCPAgent = class {
4197
4592
  } else if (this.memoryEnabled && finalResponse) {
4198
4593
  this.addToHistory(new import_langchain2.AIMessage(finalResponse));
4199
4594
  }
4595
+ console.log("\n\n");
4200
4596
  logger.info(`\u{1F389} StreamEvents complete - ${eventCount} events emitted`);
4201
4597
  success = true;
4202
4598
  } catch (e) {
@@ -4,21 +4,23 @@ import {
4
4
  streamEventsToAISDKWithTools
5
5
  } from "../chunk-EW4MJSHA.js";
6
6
  import {
7
- BaseConnector,
7
+ BaseAdapter,
8
+ LangChainAdapter,
9
+ MCPAgent,
10
+ ObservabilityManager,
11
+ RemoteAgent
12
+ } from "../chunk-35A6O3YH.js";
13
+ import {
8
14
  BrowserMCPClient,
9
15
  BrowserOAuthClientProvider,
10
16
  HttpConnector,
11
17
  MCPSession,
12
18
  WebSocketConnector,
13
19
  onMcpAuthorization
14
- } from "../chunk-TIUSJAAE.js";
20
+ } from "../chunk-GRLCLVAK.js";
15
21
  import {
16
- BaseAdapter,
17
- LangChainAdapter,
18
- MCPAgent,
19
- ObservabilityManager,
20
- RemoteAgent
21
- } from "../chunk-6EHM3S3M.js";
22
+ BaseConnector
23
+ } from "../chunk-DSBKVAWD.js";
22
24
  import "../chunk-YURRUCIM.js";
23
25
  import {
24
26
  Logger,
@@ -0,0 +1,6 @@
1
+ export { BaseCodeExecutor } from "./executors/base.js";
2
+ export type { ExecutionResult, SearchToolsFunction, ToolNamespaceInfo, ToolSearchResult, } from "./executors/base.js";
3
+ export { E2BCodeExecutor } from "./executors/e2b.js";
4
+ export { VMCodeExecutor } from "./executors/vm.js";
5
+ export { BaseCodeExecutor as CodeExecutor } from "./executors/base.js";
6
+ //# sourceMappingURL=codeExecutor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeExecutor.d.ts","sourceRoot":"","sources":["../../../src/client/codeExecutor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,gBAAgB,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { MCPClient } from "../../client.js";
3
+ import { BaseConnector } from "../../connectors/base.js";
4
+ export declare const CODE_MODE_AGENT_PROMPT = "\n## MCP Code Mode Tool Usage Guide\n\nYou have access to an MCP Code Mode Client that allows you to execute JavaScript/TypeScript code with access to registered tools. Follow this workflow:\n\n### 1. Tool Discovery Phase\n**Always start by discovering available tools:**\n- Tools are organized by server namespace (e.g., `server_name.tool_name`)\n- Use the `search_tools(query, detail_level)` function to find available tools\n- You can access `__tool_namespaces` to see all available server namespaces\n\n```javascript\n// Find all GitHub-related tools\nconst tools = await search_tools(\"github\");\nfor (const tool of tools) {\n console.log(`${tool.server}.${tool.name}: ${tool.description}`);\n}\n\n// Get only tool names for quick overview\nconst tools = await search_tools(\"\", \"names\");\n```\n\n### 2. Interface Introspection\n**Understand tool contracts before using them:**\n- Use `search_tools` to get tool descriptions and input schemas\n- Look for \"Access as: server.tool(args)\" patterns in descriptions\n\n### 3. Code Execution Guidelines\n**When writing code:**\n- Use `await server.tool({ param: value })` syntax for all tool calls\n- Tools are async functions that return promises\n- You have access to standard JavaScript globals: `console`, `JSON`, `Math`, `Date`, etc.\n- All console output (`console.log`, `console.error`, etc.) is automatically captured and returned\n- Build properly structured input objects based on interface definitions\n- Handle errors appropriately with try/catch blocks\n- Chain tool calls by using results from previous calls\n\n### 4. Best Practices\n- **Discover first, code second**: Always explore available tools before writing execution code\n- **Respect namespaces**: Use full `server.tool` names to avoid conflicts\n- **Minimize Context**: Process large data in code, return only essential results\n- **Error handling**: Wrap tool calls in try/catch for robustness\n- **Data flow**: Chain tools by passing outputs as inputs to subsequent tools\n\n### 5. Available Runtime Context\n- `search_tools(query, detail_level)`: Function to discover tools\n- `__tool_namespaces`: Array of available server namespaces\n- All registered tools as `server.tool` functions\n- Standard JavaScript built-ins for data processing\n\n### Example Workflow\n\n```javascript\n// 1. Discover available tools\nconst github_tools = await search_tools(\"github pull request\");\nconsole.log(`Available GitHub PR tools: ${github_tools.map(t => t.name)}`);\n\n// 2. Call tools with proper parameters\nconst pr = await github.get_pull_request({\n owner: \"facebook\",\n repo: \"react\",\n number: 12345\n});\n\n// 3. Process results\nlet result;\nif (pr.state === 'open' && pr.labels.some(l => l.name === 'bug')) {\n // 4. Chain with other tools\n await slack.post_message({\n channel: \"#bugs\",\n text: `\uD83D\uDC1B Bug PR needs review: ${pr.title}`\n });\n result = \"Notification sent\";\n} else {\n result = \"No action needed\";\n}\n\n// 5. Return structured results\nreturn {\n pr_number: pr.number,\n pr_title: pr.title,\n action_taken: result\n};\n```\n\nRemember: Always discover and understand available tools before attempting to use them in code execution.\n";
5
+ /**
6
+ * CodeModeConnector provides a special "code mode" interface for executing JavaScript/TypeScript
7
+ * code with access to MCP tools. Unlike other connectors, it doesn't establish its own external
8
+ * connection - instead, it wraps an already-connected BaseMCPClient and exposes special tools
9
+ * (execute_code, search_tools) on top of it.
10
+ *
11
+ * Since there's no connection phase to perform, the connector is immediately ready to use
12
+ * (connected=true) upon construction. The connect() and disconnect() methods exist for
13
+ * lifecycle compatibility with the BaseConnector interface but don't manage actual connections.
14
+ */
15
+ export declare class CodeModeConnector extends BaseConnector {
16
+ private mcpClient;
17
+ private _tools;
18
+ constructor(client: MCPClient);
19
+ connect(): Promise<void>;
20
+ disconnect(): Promise<void>;
21
+ get publicIdentifier(): Record<string, string>;
22
+ private _createToolsList;
23
+ get tools(): Tool[];
24
+ initialize(): Promise<any>;
25
+ callTool(name: string, args: Record<string, any>): Promise<CallToolResult>;
26
+ }
27
+ //# sourceMappingURL=codeMode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeMode.d.ts","sourceRoot":"","sources":["../../../../src/client/connectors/codeMode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,eAAO,MAAM,sBAAsB,0rGAsFlC,CAAC;AAEF;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,aAAa;IAClD,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,SAAS;IAOvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,IAAI,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7C;IAED,OAAO,CAAC,gBAAgB;IA4DxB,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAEK,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC;IAK1B,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,OAAO,CAAC,cAAc,CAAC;CA2C3B"}
@@ -0,0 +1,56 @@
1
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import type { MCPClient } from "../../client.js";
3
+ export interface ExecutionResult {
4
+ result: unknown;
5
+ logs: string[];
6
+ error: string | null;
7
+ execution_time: number;
8
+ }
9
+ export interface ToolSearchResult {
10
+ name: string;
11
+ server: string;
12
+ description?: string;
13
+ input_schema?: Tool["inputSchema"];
14
+ }
15
+ export type SearchToolsFunction = (query?: string, detailLevel?: "names" | "descriptions" | "full") => Promise<ToolSearchResult[]>;
16
+ export interface ToolNamespaceInfo {
17
+ serverName: string;
18
+ tools: Tool[];
19
+ session: any;
20
+ }
21
+ /**
22
+ * Abstract base class for code executors.
23
+ * Provides shared functionality for connecting to MCP servers and building tool contexts.
24
+ */
25
+ export declare abstract class BaseCodeExecutor {
26
+ protected client: MCPClient;
27
+ protected _connecting: boolean;
28
+ constructor(client: MCPClient);
29
+ /**
30
+ * Execute code with access to MCP tools.
31
+ * @param code - The code to execute
32
+ * @param timeout - Execution timeout in milliseconds
33
+ */
34
+ abstract execute(code: string, timeout?: number): Promise<ExecutionResult>;
35
+ /**
36
+ * Clean up resources used by the executor.
37
+ * Should be called when the executor is no longer needed.
38
+ */
39
+ abstract cleanup(): Promise<void>;
40
+ /**
41
+ * Ensure all configured MCP servers are connected before execution.
42
+ * Prevents race conditions with a connection lock.
43
+ */
44
+ protected ensureServersConnected(): Promise<void>;
45
+ /**
46
+ * Get tool namespace information from all active MCP sessions.
47
+ * Filters out the internal code_mode server.
48
+ */
49
+ protected getToolNamespaces(): ToolNamespaceInfo[];
50
+ /**
51
+ * Create a search function for discovering available MCP tools.
52
+ * Used by code execution environments to find tools at runtime.
53
+ */
54
+ createSearchToolsFunction(): SearchToolsFunction;
55
+ }
56
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/client/executors/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGjD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;I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