@mastra/mcp 0.11.2 → 0.11.3-alpha.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.
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSche
12
12
  import { asyncExitHook, gracefulExit } from 'exit-hook';
13
13
  import { z } from 'zod';
14
14
  import { convertJsonSchemaToZod } from 'zod-from-json-schema';
15
+ import { convertJsonSchemaToZod as convertJsonSchemaToZod$1 } from 'zod-from-json-schema-v3';
15
16
  import equal from 'fast-deep-equal';
16
17
  import { v5 } from 'uuid';
17
18
  import { randomUUID } from 'crypto';
@@ -505,7 +506,12 @@ var InternalMastraMCPClient = class extends MastraBase {
505
506
  }
506
507
  try {
507
508
  await $RefParser.dereference(inputSchema);
508
- return convertJsonSchemaToZod(inputSchema);
509
+ const jsonSchemaToConvert = "jsonSchema" in inputSchema ? inputSchema.jsonSchema : inputSchema;
510
+ if ("toJSONSchema" in z) {
511
+ return convertJsonSchemaToZod(jsonSchemaToConvert);
512
+ } else {
513
+ return convertJsonSchemaToZod$1(jsonSchemaToConvert);
514
+ }
509
515
  } catch (error) {
510
516
  let errorDetails;
511
517
  if (error instanceof Error) {
@@ -536,7 +542,12 @@ var InternalMastraMCPClient = class extends MastraBase {
536
542
  }
537
543
  try {
538
544
  await $RefParser.dereference(outputSchema);
539
- return convertJsonSchemaToZod(outputSchema);
545
+ const jsonSchemaToConvert = "jsonSchema" in outputSchema ? outputSchema.jsonSchema : outputSchema;
546
+ if ("toJSONSchema" in z) {
547
+ return convertJsonSchemaToZod(jsonSchemaToConvert);
548
+ } else {
549
+ return convertJsonSchemaToZod$1(jsonSchemaToConvert);
550
+ }
540
551
  } catch (error) {
541
552
  let errorDetails;
542
553
  if (error instanceof Error) {
@@ -1844,12 +1855,12 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1844
1855
  inputSchema: z.object({
1845
1856
  message: z.string().describe("The question or input for the agent.")
1846
1857
  }),
1847
- execute: async ({ context, runtimeContext }) => {
1858
+ execute: async ({ context, runtimeContext, tracingContext }) => {
1848
1859
  this.logger.debug(
1849
1860
  `Executing agent tool '${agentToolName}' for agent '${agent.name}' with message: "${context.message}"`
1850
1861
  );
1851
1862
  try {
1852
- const response = await agent.generate(context.message, { runtimeContext });
1863
+ const response = await agent.generate(context.message, { runtimeContext, tracingContext });
1853
1864
  return response;
1854
1865
  } catch (error) {
1855
1866
  this.logger.error(`Error executing agent tool '${agentToolName}' for agent '${agent.name}':`, error);
@@ -1862,6 +1873,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1862
1873
  logger: this.logger,
1863
1874
  mastra: this.mastra,
1864
1875
  runtimeContext: new RuntimeContext(),
1876
+ tracingContext: {},
1865
1877
  description: agentToolDefinition.description
1866
1878
  };
1867
1879
  const coreTool = makeCoreTool(agentToolDefinition, options);
@@ -1906,14 +1918,14 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1906
1918
  id: workflowToolName,
1907
1919
  description: `Run workflow '${workflowKey}'. Workflow description: ${workflowDescription}`,
1908
1920
  inputSchema: workflow.inputSchema,
1909
- execute: async ({ context, runtimeContext }) => {
1921
+ execute: async ({ context, runtimeContext, tracingContext }) => {
1910
1922
  this.logger.debug(
1911
1923
  `Executing workflow tool '${workflowToolName}' for workflow '${workflow.id}' with input:`,
1912
1924
  context
1913
1925
  );
1914
1926
  try {
1915
1927
  const run2 = workflow.createRun({ runId: runtimeContext?.get("runId") });
1916
- const response = await run2.start({ inputData: context, runtimeContext });
1928
+ const response = await run2.start({ inputData: context, runtimeContext, tracingContext });
1917
1929
  return response;
1918
1930
  } catch (error) {
1919
1931
  this.logger.error(
@@ -1929,6 +1941,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1929
1941
  logger: this.logger,
1930
1942
  mastra: this.mastra,
1931
1943
  runtimeContext: new RuntimeContext(),
1944
+ tracingContext: {},
1932
1945
  description: workflowToolDefinition.description
1933
1946
  };
1934
1947
  const coreTool = makeCoreTool(workflowToolDefinition, options);
@@ -1967,6 +1980,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1967
1980
  const options = {
1968
1981
  name: toolName,
1969
1982
  runtimeContext: new RuntimeContext(),
1983
+ tracingContext: {},
1970
1984
  mastra: this.mastra,
1971
1985
  logger: this.logger,
1972
1986
  description: toolInstance?.description