@mastra/client-js 0.0.0-generate-message-id-20250512171942 → 0.0.0-inject-middleware-20250528222017

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.cjs CHANGED
@@ -5,6 +5,7 @@ var rxjs = require('rxjs');
5
5
  var uiUtils = require('@ai-sdk/ui-utils');
6
6
  var zod = require('zod');
7
7
  var originalZodToJsonSchema = require('zod-to-json-schema');
8
+ var runtimeContext = require('@mastra/core/runtime-context');
8
9
 
9
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
11
 
@@ -220,7 +221,7 @@ var BaseResource = class {
220
221
  let delay = backoffMs;
221
222
  for (let attempt = 0; attempt <= retries; attempt++) {
222
223
  try {
223
- const response = await fetch(`${baseUrl}${path}`, {
224
+ const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
224
225
  ...options,
225
226
  headers: {
226
227
  ...headers,
@@ -260,6 +261,15 @@ var BaseResource = class {
260
261
  throw lastError || new Error("Request failed");
261
262
  }
262
263
  };
264
+ function parseClientRuntimeContext(runtimeContext$1) {
265
+ if (runtimeContext$1) {
266
+ if (runtimeContext$1 instanceof runtimeContext.RuntimeContext) {
267
+ return Object.fromEntries(runtimeContext$1.entries());
268
+ }
269
+ return runtimeContext$1;
270
+ }
271
+ return void 0;
272
+ }
263
273
 
264
274
  // src/resources/agent.ts
265
275
  var AgentVoice = class extends BaseResource {
@@ -331,9 +341,9 @@ var Agent = class extends BaseResource {
331
341
  generate(params) {
332
342
  const processedParams = {
333
343
  ...params,
334
- output: zodToJsonSchema(params.output),
335
- experimental_output: zodToJsonSchema(params.experimental_output),
336
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
344
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
345
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
346
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
337
347
  };
338
348
  return this.request(`/api/agents/${this.agentId}/generate`, {
339
349
  method: "POST",
@@ -348,9 +358,9 @@ var Agent = class extends BaseResource {
348
358
  async stream(params) {
349
359
  const processedParams = {
350
360
  ...params,
351
- output: zodToJsonSchema(params.output),
352
- experimental_output: zodToJsonSchema(params.experimental_output),
353
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
361
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
362
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
363
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
354
364
  };
355
365
  const response = await this.request(`/api/agents/${this.agentId}/stream`, {
356
366
  method: "POST",
@@ -500,10 +510,15 @@ var MemoryThread = class extends BaseResource {
500
510
  }
501
511
  /**
502
512
  * Retrieves messages associated with the thread
513
+ * @param params - Optional parameters including limit for number of messages to retrieve
503
514
  * @returns Promise containing thread messages and UI messages
504
515
  */
505
- getMessages() {
506
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
516
+ getMessages(params) {
517
+ const query = new URLSearchParams({
518
+ agentId: this.agentId,
519
+ ...params?.limit ? { limit: params.limit.toString() } : {}
520
+ });
521
+ return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
507
522
  }
508
523
  };
509
524
 
@@ -573,24 +588,24 @@ var Vector = class extends BaseResource {
573
588
  }
574
589
  };
575
590
 
576
- // src/resources/workflow.ts
591
+ // src/resources/legacy-workflow.ts
577
592
  var RECORD_SEPARATOR = "";
578
- var Workflow = class extends BaseResource {
593
+ var LegacyWorkflow = class extends BaseResource {
579
594
  constructor(options, workflowId) {
580
595
  super(options);
581
596
  this.workflowId = workflowId;
582
597
  }
583
598
  /**
584
- * Retrieves details about the workflow
585
- * @returns Promise containing workflow details including steps and graphs
599
+ * Retrieves details about the legacy workflow
600
+ * @returns Promise containing legacy workflow details including steps and graphs
586
601
  */
587
602
  details() {
588
- return this.request(`/api/workflows/${this.workflowId}`);
603
+ return this.request(`/api/workflows/legacy/${this.workflowId}`);
589
604
  }
590
605
  /**
591
- * Retrieves all runs for a workflow
606
+ * Retrieves all runs for a legacy workflow
592
607
  * @param params - Parameters for filtering runs
593
- * @returns Promise containing workflow runs array
608
+ * @returns Promise containing legacy workflow runs array
594
609
  */
595
610
  runs(params) {
596
611
  const searchParams = new URLSearchParams();
@@ -610,25 +625,13 @@ var Workflow = class extends BaseResource {
610
625
  searchParams.set("resourceId", params.resourceId);
611
626
  }
612
627
  if (searchParams.size) {
613
- return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
628
+ return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
614
629
  } else {
615
- return this.request(`/api/workflows/${this.workflowId}/runs`);
630
+ return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
616
631
  }
617
632
  }
618
633
  /**
619
- * @deprecated Use `startAsync` instead
620
- * Executes the workflow with the provided parameters
621
- * @param params - Parameters required for workflow execution
622
- * @returns Promise containing the workflow execution results
623
- */
624
- execute(params) {
625
- return this.request(`/api/workflows/${this.workflowId}/execute`, {
626
- method: "POST",
627
- body: params
628
- });
629
- }
630
- /**
631
- * Creates a new workflow run
634
+ * Creates a new legacy workflow run
632
635
  * @returns Promise containing the generated run ID
633
636
  */
634
637
  createRun(params) {
@@ -636,34 +639,34 @@ var Workflow = class extends BaseResource {
636
639
  if (!!params?.runId) {
637
640
  searchParams.set("runId", params.runId);
638
641
  }
639
- return this.request(`/api/workflows/${this.workflowId}/createRun?${searchParams.toString()}`, {
642
+ return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
640
643
  method: "POST"
641
644
  });
642
645
  }
643
646
  /**
644
- * Starts a workflow run synchronously without waiting for the workflow to complete
647
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
645
648
  * @param params - Object containing the runId and triggerData
646
649
  * @returns Promise containing success message
647
650
  */
648
651
  start(params) {
649
- return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
652
+ return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
650
653
  method: "POST",
651
654
  body: params?.triggerData
652
655
  });
653
656
  }
654
657
  /**
655
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
658
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
656
659
  * @param stepId - ID of the step to resume
657
- * @param runId - ID of the workflow run
658
- * @param context - Context to resume the workflow with
659
- * @returns Promise containing the workflow resume results
660
+ * @param runId - ID of the legacy workflow run
661
+ * @param context - Context to resume the legacy workflow with
662
+ * @returns Promise containing the legacy workflow resume results
660
663
  */
661
664
  resume({
662
665
  stepId,
663
666
  runId,
664
667
  context
665
668
  }) {
666
- return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
669
+ return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
667
670
  method: "POST",
668
671
  body: {
669
672
  stepId,
@@ -681,18 +684,18 @@ var Workflow = class extends BaseResource {
681
684
  if (!!params?.runId) {
682
685
  searchParams.set("runId", params.runId);
683
686
  }
684
- return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
687
+ return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
685
688
  method: "POST",
686
689
  body: params?.triggerData
687
690
  });
688
691
  }
689
692
  /**
690
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
693
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
691
694
  * @param params - Object containing the runId, stepId, and context
692
695
  * @returns Promise containing the workflow resume results
693
696
  */
694
697
  resumeAsync(params) {
695
- return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
698
+ return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
696
699
  method: "POST",
697
700
  body: {
698
701
  stepId: params.stepId,
@@ -746,16 +749,16 @@ var Workflow = class extends BaseResource {
746
749
  }
747
750
  }
748
751
  /**
749
- * Watches workflow transitions in real-time
752
+ * Watches legacy workflow transitions in real-time
750
753
  * @param runId - Optional run ID to filter the watch stream
751
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
754
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
752
755
  */
753
756
  async watch({ runId }, onRecord) {
754
- const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
757
+ const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
755
758
  stream: true
756
759
  });
757
760
  if (!response.ok) {
758
- throw new Error(`Failed to watch workflow: ${response.statusText}`);
761
+ throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
759
762
  }
760
763
  if (!response.body) {
761
764
  throw new Error("Response body is null");
@@ -791,7 +794,7 @@ var Tool = class extends BaseResource {
791
794
  }
792
795
  const body = {
793
796
  data: params.data,
794
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
797
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
795
798
  };
796
799
  return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
797
800
  method: "POST",
@@ -799,14 +802,16 @@ var Tool = class extends BaseResource {
799
802
  });
800
803
  }
801
804
  };
805
+
806
+ // src/resources/workflow.ts
802
807
  var RECORD_SEPARATOR2 = "";
803
- var VNextWorkflow = class extends BaseResource {
808
+ var Workflow = class extends BaseResource {
804
809
  constructor(options, workflowId) {
805
810
  super(options);
806
811
  this.workflowId = workflowId;
807
812
  }
808
813
  /**
809
- * Creates an async generator that processes a readable stream and yields vNext workflow records
814
+ * Creates an async generator that processes a readable stream and yields workflow records
810
815
  * separated by the Record Separator character (\x1E)
811
816
  *
812
817
  * @param stream - The readable stream to process
@@ -851,16 +856,16 @@ var VNextWorkflow = class extends BaseResource {
851
856
  }
852
857
  }
853
858
  /**
854
- * Retrieves details about the vNext workflow
855
- * @returns Promise containing vNext workflow details including steps and graphs
859
+ * Retrieves details about the workflow
860
+ * @returns Promise containing workflow details including steps and graphs
856
861
  */
857
862
  details() {
858
- return this.request(`/api/workflows/v-next/${this.workflowId}`);
863
+ return this.request(`/api/workflows/${this.workflowId}`);
859
864
  }
860
865
  /**
861
- * Retrieves all runs for a vNext workflow
866
+ * Retrieves all runs for a workflow
862
867
  * @param params - Parameters for filtering runs
863
- * @returns Promise containing vNext workflow runs array
868
+ * @returns Promise containing workflow runs array
864
869
  */
865
870
  runs(params) {
866
871
  const searchParams = new URLSearchParams();
@@ -880,13 +885,13 @@ var VNextWorkflow = class extends BaseResource {
880
885
  searchParams.set("resourceId", params.resourceId);
881
886
  }
882
887
  if (searchParams.size) {
883
- return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
888
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
884
889
  } else {
885
- return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
890
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
886
891
  }
887
892
  }
888
893
  /**
889
- * Creates a new vNext workflow run
894
+ * Creates a new workflow run
890
895
  * @param params - Optional object containing the optional runId
891
896
  * @returns Promise containing the runId of the created run
892
897
  */
@@ -895,24 +900,24 @@ var VNextWorkflow = class extends BaseResource {
895
900
  if (!!params?.runId) {
896
901
  searchParams.set("runId", params.runId);
897
902
  }
898
- return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
903
+ return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
899
904
  method: "POST"
900
905
  });
901
906
  }
902
907
  /**
903
- * Starts a vNext workflow run synchronously without waiting for the workflow to complete
908
+ * Starts a workflow run synchronously without waiting for the workflow to complete
904
909
  * @param params - Object containing the runId, inputData and runtimeContext
905
910
  * @returns Promise containing success message
906
911
  */
907
912
  start(params) {
908
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
909
- return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
913
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
914
+ return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
910
915
  method: "POST",
911
916
  body: { inputData: params?.inputData, runtimeContext }
912
917
  });
913
918
  }
914
919
  /**
915
- * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
920
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
916
921
  * @param params - Object containing the runId, step, resumeData and runtimeContext
917
922
  * @returns Promise containing success message
918
923
  */
@@ -922,8 +927,8 @@ var VNextWorkflow = class extends BaseResource {
922
927
  resumeData,
923
928
  ...rest
924
929
  }) {
925
- const runtimeContext = rest.runtimeContext ? Object.fromEntries(rest.runtimeContext.entries()) : void 0;
926
- return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
930
+ const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
931
+ return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
927
932
  method: "POST",
928
933
  stream: true,
929
934
  body: {
@@ -934,29 +939,76 @@ var VNextWorkflow = class extends BaseResource {
934
939
  });
935
940
  }
936
941
  /**
937
- * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
942
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
938
943
  * @param params - Object containing the optional runId, inputData and runtimeContext
939
- * @returns Promise containing the vNext workflow execution results
944
+ * @returns Promise containing the workflow execution results
940
945
  */
941
946
  startAsync(params) {
942
947
  const searchParams = new URLSearchParams();
943
948
  if (!!params?.runId) {
944
949
  searchParams.set("runId", params.runId);
945
950
  }
946
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
947
- return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
951
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
952
+ return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
948
953
  method: "POST",
949
954
  body: { inputData: params.inputData, runtimeContext }
950
955
  });
951
956
  }
952
957
  /**
953
- * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
958
+ * Starts a vNext workflow run and returns a stream
959
+ * @param params - Object containing the optional runId, inputData and runtimeContext
960
+ * @returns Promise containing the vNext workflow execution results
961
+ */
962
+ async stream(params) {
963
+ const searchParams = new URLSearchParams();
964
+ if (!!params?.runId) {
965
+ searchParams.set("runId", params.runId);
966
+ }
967
+ const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
968
+ const response = await this.request(
969
+ `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
970
+ {
971
+ method: "POST",
972
+ body: { inputData: params.inputData, runtimeContext },
973
+ stream: true
974
+ }
975
+ );
976
+ if (!response.ok) {
977
+ throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
978
+ }
979
+ if (!response.body) {
980
+ throw new Error("Response body is null");
981
+ }
982
+ const transformStream = new TransformStream({
983
+ start() {
984
+ },
985
+ async transform(chunk, controller) {
986
+ try {
987
+ const decoded = new TextDecoder().decode(chunk);
988
+ const chunks = decoded.split(RECORD_SEPARATOR2);
989
+ for (const chunk2 of chunks) {
990
+ if (chunk2) {
991
+ try {
992
+ const parsedChunk = JSON.parse(chunk2);
993
+ controller.enqueue(parsedChunk);
994
+ } catch {
995
+ }
996
+ }
997
+ }
998
+ } catch {
999
+ }
1000
+ }
1001
+ });
1002
+ return response.body.pipeThrough(transformStream);
1003
+ }
1004
+ /**
1005
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
954
1006
  * @param params - Object containing the runId, step, resumeData and runtimeContext
955
- * @returns Promise containing the vNext workflow resume results
1007
+ * @returns Promise containing the workflow resume results
956
1008
  */
957
1009
  resumeAsync(params) {
958
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
959
- return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
1010
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1011
+ return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
960
1012
  method: "POST",
961
1013
  body: {
962
1014
  step: params.step,
@@ -966,24 +1018,51 @@ var VNextWorkflow = class extends BaseResource {
966
1018
  });
967
1019
  }
968
1020
  /**
969
- * Watches vNext workflow transitions in real-time
1021
+ * Watches workflow transitions in real-time
970
1022
  * @param runId - Optional run ID to filter the watch stream
971
- * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
1023
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
972
1024
  */
973
1025
  async watch({ runId }, onRecord) {
974
- const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
1026
+ const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
975
1027
  stream: true
976
1028
  });
977
1029
  if (!response.ok) {
978
- throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
1030
+ throw new Error(`Failed to watch workflow: ${response.statusText}`);
979
1031
  }
980
1032
  if (!response.body) {
981
1033
  throw new Error("Response body is null");
982
1034
  }
983
1035
  for await (const record of this.streamProcessor(response.body)) {
984
- onRecord(record);
1036
+ if (typeof record === "string") {
1037
+ onRecord(JSON.parse(record));
1038
+ } else {
1039
+ onRecord(record);
1040
+ }
985
1041
  }
986
1042
  }
1043
+ /**
1044
+ * Creates a new ReadableStream from an iterable or async iterable of objects,
1045
+ * serializing each as JSON and separating them with the record separator (\x1E).
1046
+ *
1047
+ * @param records - An iterable or async iterable of objects to stream
1048
+ * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
1049
+ */
1050
+ static createRecordStream(records) {
1051
+ const encoder = new TextEncoder();
1052
+ return new ReadableStream({
1053
+ async start(controller) {
1054
+ try {
1055
+ for await (const record of records) {
1056
+ const json = JSON.stringify(record) + RECORD_SEPARATOR2;
1057
+ controller.enqueue(encoder.encode(json));
1058
+ }
1059
+ controller.close();
1060
+ } catch (err) {
1061
+ controller.error(err);
1062
+ }
1063
+ }
1064
+ });
1065
+ }
987
1066
  };
988
1067
 
989
1068
  // src/resources/a2a.ts
@@ -1060,6 +1139,40 @@ var A2A = class extends BaseResource {
1060
1139
  }
1061
1140
  };
1062
1141
 
1142
+ // src/resources/mcp-tool.ts
1143
+ var MCPTool = class extends BaseResource {
1144
+ serverId;
1145
+ toolId;
1146
+ constructor(options, serverId, toolId) {
1147
+ super(options);
1148
+ this.serverId = serverId;
1149
+ this.toolId = toolId;
1150
+ }
1151
+ /**
1152
+ * Retrieves details about this specific tool from the MCP server.
1153
+ * @returns Promise containing the tool's information (name, description, schema).
1154
+ */
1155
+ details() {
1156
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
1157
+ }
1158
+ /**
1159
+ * Executes this specific tool on the MCP server.
1160
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
1161
+ * @returns Promise containing the result of the tool execution.
1162
+ */
1163
+ execute(params) {
1164
+ const body = {};
1165
+ if (params.data !== void 0) body.data = params.data;
1166
+ if (params.runtimeContext !== void 0) {
1167
+ body.runtimeContext = params.runtimeContext;
1168
+ }
1169
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}/execute`, {
1170
+ method: "POST",
1171
+ body: Object.keys(body).length > 0 ? body : void 0
1172
+ });
1173
+ }
1174
+ };
1175
+
1063
1176
  // src/client.ts
1064
1177
  var MastraClient = class extends BaseResource {
1065
1178
  constructor(options) {
@@ -1152,6 +1265,21 @@ var MastraClient = class extends BaseResource {
1152
1265
  getTool(toolId) {
1153
1266
  return new Tool(this.options, toolId);
1154
1267
  }
1268
+ /**
1269
+ * Retrieves all available legacy workflows
1270
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
1271
+ */
1272
+ getLegacyWorkflows() {
1273
+ return this.request("/api/workflows/legacy");
1274
+ }
1275
+ /**
1276
+ * Gets a legacy workflow instance by ID
1277
+ * @param workflowId - ID of the legacy workflow to retrieve
1278
+ * @returns Legacy Workflow instance
1279
+ */
1280
+ getLegacyWorkflow(workflowId) {
1281
+ return new LegacyWorkflow(this.options, workflowId);
1282
+ }
1155
1283
  /**
1156
1284
  * Retrieves all available workflows
1157
1285
  * @returns Promise containing map of workflow IDs to workflow details
@@ -1167,21 +1295,6 @@ var MastraClient = class extends BaseResource {
1167
1295
  getWorkflow(workflowId) {
1168
1296
  return new Workflow(this.options, workflowId);
1169
1297
  }
1170
- /**
1171
- * Retrieves all available vNext workflows
1172
- * @returns Promise containing map of vNext workflow IDs to vNext workflow details
1173
- */
1174
- getVNextWorkflows() {
1175
- return this.request("/api/workflows/v-next");
1176
- }
1177
- /**
1178
- * Gets a vNext workflow instance by ID
1179
- * @param workflowId - ID of the vNext workflow to retrieve
1180
- * @returns vNext Workflow instance
1181
- */
1182
- getVNextWorkflow(workflowId) {
1183
- return new VNextWorkflow(this.options, workflowId);
1184
- }
1185
1298
  /**
1186
1299
  * Gets a vector instance by name
1187
1300
  * @param vectorName - Name of the vector to retrieve
@@ -1270,6 +1383,54 @@ var MastraClient = class extends BaseResource {
1270
1383
  getNetwork(networkId) {
1271
1384
  return new Network(this.options, networkId);
1272
1385
  }
1386
+ /**
1387
+ * Retrieves a list of available MCP servers.
1388
+ * @param params - Optional parameters for pagination (limit, offset).
1389
+ * @returns Promise containing the list of MCP servers and pagination info.
1390
+ */
1391
+ getMcpServers(params) {
1392
+ const searchParams = new URLSearchParams();
1393
+ if (params?.limit !== void 0) {
1394
+ searchParams.set("limit", String(params.limit));
1395
+ }
1396
+ if (params?.offset !== void 0) {
1397
+ searchParams.set("offset", String(params.offset));
1398
+ }
1399
+ const queryString = searchParams.toString();
1400
+ return this.request(`/api/mcp/v0/servers${queryString ? `?${queryString}` : ""}`);
1401
+ }
1402
+ /**
1403
+ * Retrieves detailed information for a specific MCP server.
1404
+ * @param serverId - The ID of the MCP server to retrieve.
1405
+ * @param params - Optional parameters, e.g., specific version.
1406
+ * @returns Promise containing the detailed MCP server information.
1407
+ */
1408
+ getMcpServerDetails(serverId, params) {
1409
+ const searchParams = new URLSearchParams();
1410
+ if (params?.version) {
1411
+ searchParams.set("version", params.version);
1412
+ }
1413
+ const queryString = searchParams.toString();
1414
+ return this.request(`/api/mcp/v0/servers/${serverId}${queryString ? `?${queryString}` : ""}`);
1415
+ }
1416
+ /**
1417
+ * Retrieves a list of tools for a specific MCP server.
1418
+ * @param serverId - The ID of the MCP server.
1419
+ * @returns Promise containing the list of tools.
1420
+ */
1421
+ getMcpServerTools(serverId) {
1422
+ return this.request(`/api/mcp/${serverId}/tools`);
1423
+ }
1424
+ /**
1425
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
1426
+ * This instance can then be used to fetch details or execute the tool.
1427
+ * @param serverId - The ID of the MCP server.
1428
+ * @param toolId - The ID of the tool.
1429
+ * @returns MCPTool instance.
1430
+ */
1431
+ getMcpServerTool(serverId, toolId) {
1432
+ return new MCPTool(this.options, serverId, toolId);
1433
+ }
1273
1434
  /**
1274
1435
  * Gets an A2A client for interacting with an agent via the A2A protocol
1275
1436
  * @param agentId - ID of the agent to interact with