@mastra/mcp 1.5.0 → 1.5.1-alpha.0

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
@@ -25,6 +25,31 @@ export { UnauthorizedError, auth, buildDiscoveryUrls, discoverAuthorizationServe
25
25
 
26
26
  // src/client/client.ts
27
27
 
28
+ // src/shared/mastra-tool-meta.ts
29
+ var MASTRA_META_KEY = "mastra";
30
+ var STRICT_META_KEY = "strict";
31
+ function withMastraToolStrictMeta(meta, strict) {
32
+ if (strict == null) {
33
+ return meta;
34
+ }
35
+ const mastraMeta = meta?.[MASTRA_META_KEY] && typeof meta[MASTRA_META_KEY] === "object" ? meta[MASTRA_META_KEY] : void 0;
36
+ return {
37
+ ...meta ?? {},
38
+ [MASTRA_META_KEY]: {
39
+ ...mastraMeta ?? {},
40
+ [STRICT_META_KEY]: strict
41
+ }
42
+ };
43
+ }
44
+ function getMastraToolStrictMeta(meta) {
45
+ const mastraMeta = meta?.[MASTRA_META_KEY];
46
+ if (!mastraMeta || typeof mastraMeta !== "object") {
47
+ return void 0;
48
+ }
49
+ const strict = mastraMeta[STRICT_META_KEY];
50
+ return typeof strict === "boolean" ? strict : void 0;
51
+ }
52
+
28
53
  // src/client/actions/elicitation.ts
29
54
  var ElicitationClientActions = class {
30
55
  client;
@@ -917,6 +942,7 @@ var InternalMastraMCPClient = class extends MastraBase {
917
942
  id: `${this.name}_${tool.name}`,
918
943
  description: tool.description || "",
919
944
  inputSchema: await this.convertInputSchema(tool.inputSchema),
945
+ strict: getMastraToolStrictMeta(tool._meta),
920
946
  // Don't pass outputSchema to createTool — the MCP SDK's Client.callTool()
921
947
  // already validates structuredContent against the tool's outputSchema using AJV.
922
948
  // Passing it here causes Zod to strip unrecognized keys from the CallToolResult
@@ -2774,8 +2800,9 @@ var MCPServer = class extends MCPServerBase {
2774
2800
  if (tool.mcp?.annotations) {
2775
2801
  toolSpec.annotations = tool.mcp.annotations;
2776
2802
  }
2777
- if (tool.mcp?._meta) {
2778
- toolSpec._meta = tool.mcp._meta;
2803
+ const toolMeta = withMastraToolStrictMeta(tool.mcp?._meta, tool.strict);
2804
+ if (toolMeta) {
2805
+ toolSpec._meta = toolMeta;
2779
2806
  }
2780
2807
  return toolSpec;
2781
2808
  })
@@ -4053,7 +4080,8 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
4053
4080
  description: tool.description,
4054
4081
  inputSchema: this.convertSchema(tool.parameters),
4055
4082
  outputSchema: this.convertSchema(tool.parameters),
4056
- toolType: tool.mcp?.toolType
4083
+ toolType: tool.mcp?.toolType,
4084
+ _meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
4057
4085
  }))
4058
4086
  };
4059
4087
  }
@@ -4087,7 +4115,8 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
4087
4115
  description: tool.description,
4088
4116
  inputSchema: this.convertSchema(tool.parameters),
4089
4117
  outputSchema: this.convertSchema(tool.outputSchema),
4090
- toolType: tool.mcp?.toolType
4118
+ toolType: tool.mcp?.toolType,
4119
+ _meta: withMastraToolStrictMeta(tool.mcp?._meta, tool.strict)
4091
4120
  };
4092
4121
  }
4093
4122
  /**