@mastra/mcp 1.4.2 → 1.5.0-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
@@ -425,6 +425,7 @@ var InternalMastraMCPClient = class extends MastraBase {
425
425
  sigTermHandler;
426
426
  sigHupHandler;
427
427
  _roots;
428
+ requireToolApproval;
428
429
  /** Provides access to resource operations (list, read, subscribe, etc.) */
429
430
  resources;
430
431
  /** Provides access to prompt operations (list, get, notifications) */
@@ -450,6 +451,7 @@ var InternalMastraMCPClient = class extends MastraBase {
450
451
  this.enableServerLogs = server.enableServerLogs ?? true;
451
452
  this.serverConfig = server;
452
453
  this.enableProgressTracking = !!server.enableProgressTracking;
454
+ this.requireToolApproval = server.requireToolApproval;
453
455
  this._roots = server.roots ?? [];
454
456
  const hasRoots = this._roots.length > 0 || !!capabilities.roots;
455
457
  const clientCapabilities = {
@@ -896,6 +898,18 @@ var InternalMastraMCPClient = class extends MastraBase {
896
898
  for (const tool of tools) {
897
899
  this.log("debug", `Processing tool: ${tool.name}`);
898
900
  try {
901
+ let requireApproval;
902
+ let needsApprovalFn;
903
+ if (typeof this.requireToolApproval === "function") {
904
+ const serverApprovalFn = this.requireToolApproval;
905
+ const toolName = tool.name;
906
+ requireApproval = true;
907
+ needsApprovalFn = (args, ctx = {}) => {
908
+ return serverApprovalFn({ toolName, args, ...ctx });
909
+ };
910
+ } else if (this.requireToolApproval === true) {
911
+ requireApproval = true;
912
+ }
899
913
  const mastraTool = createTool({
900
914
  id: `${this.name}_${tool.name}`,
901
915
  description: tool.description || "",
@@ -904,6 +918,7 @@ var InternalMastraMCPClient = class extends MastraBase {
904
918
  // already validates structuredContent against the tool's outputSchema using AJV.
905
919
  // Passing it here causes Zod to strip unrecognized keys from the CallToolResult
906
920
  // envelope, returning {} for tools without structuredContent.
921
+ requireApproval,
907
922
  mcpMetadata: {
908
923
  serverName: this.name,
909
924
  serverVersion: this.client.getServerVersion()?.version
@@ -963,6 +978,9 @@ var InternalMastraMCPClient = class extends MastraBase {
963
978
  });
964
979
  }
965
980
  });
981
+ if (needsApprovalFn) {
982
+ mastraTool.needsApprovalFn = needsApprovalFn;
983
+ }
966
984
  if (tool.name) {
967
985
  toolsRes[tool.name] = mastraTool;
968
986
  }
@@ -2040,7 +2058,7 @@ function createSimpleTokenProvider(accessToken, options) {
2040
2058
  });
2041
2059
  }
2042
2060
 
2043
- // ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/stream.js
2061
+ // ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/utils/stream.js
2044
2062
  var StreamingApi = class {
2045
2063
  writer;
2046
2064
  encoder;
@@ -2117,7 +2135,7 @@ var StreamingApi = class {
2117
2135
  }
2118
2136
  };
2119
2137
 
2120
- // ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/helper/streaming/utils.js
2138
+ // ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/helper/streaming/utils.js
2121
2139
  var isOldBunVersion = () => {
2122
2140
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
2123
2141
  if (version === void 0) {
@@ -2128,7 +2146,7 @@ var isOldBunVersion = () => {
2128
2146
  return result;
2129
2147
  };
2130
2148
 
2131
- // ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/utils/html.js
2149
+ // ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/utils/html.js
2132
2150
  var HtmlEscapedCallbackPhase = {
2133
2151
  Stringify: 1};
2134
2152
  var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
@@ -2159,7 +2177,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
2159
2177
  }
2160
2178
  };
2161
2179
 
2162
- // ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/helper/streaming/sse.js
2180
+ // ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/helper/streaming/sse.js
2163
2181
  var SSEStreamingApi = class extends StreamingApi {
2164
2182
  constructor(writable, readable) {
2165
2183
  super(writable, readable);