@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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/index.cjs +20 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/integration-tests/node_modules/.bin/vitest +2 -2
- package/integration-tests/package.json +1 -1
- package/integration-tests/src/server.test.ts +1 -1
- package/package.json +8 -7
- package/src/client/client.ts +16 -3
- package/src/server/server.ts +7 -4
- package/integration-tests/node_modules/.bin/mastra +0 -21
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
|
-
|
|
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
|
-
|
|
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
|