@mastra/mcp 1.7.0 → 1.8.0-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
@@ -965,18 +965,25 @@ var InternalMastraMCPClient = class extends MastraBase {
965
965
  try {
966
966
  let requireApproval;
967
967
  let needsApprovalFn;
968
+ const annotations = tool.annotations;
968
969
  if (typeof this.requireToolApproval === "function") {
969
970
  const serverApprovalFn = this.requireToolApproval;
970
971
  const toolName = tool.name;
971
972
  requireApproval = true;
972
973
  needsApprovalFn = (args, ctx = {}) => {
973
- return serverApprovalFn({ toolName, args, ...ctx });
974
+ return serverApprovalFn({ toolName, args, ...ctx, annotations });
974
975
  };
975
976
  } else if (this.requireToolApproval === true) {
976
977
  requireApproval = true;
977
978
  }
978
979
  const rawMeta = tool._meta;
979
980
  const toolMeta = rawMeta ? this.stampServerIdInMeta(rawMeta) : void 0;
981
+ const mcpToolProps = toolMeta || annotations ? {
982
+ mcp: {
983
+ ...toolMeta ? { _meta: toolMeta } : {},
984
+ ...annotations ? { annotations } : {}
985
+ }
986
+ } : {};
980
987
  const mastraTool = createTool({
981
988
  id: `${this.name}_${tool.name}`,
982
989
  description: tool.description || "",
@@ -984,7 +991,9 @@ var InternalMastraMCPClient = class extends MastraBase {
984
991
  strict: getMastraToolStrictMeta(toolMeta),
985
992
  // Preserve the full _meta from the remote MCP server (including ui.resourceUri
986
993
  // for MCP Apps) so downstream consumers (e.g. Studio) can detect app tools.
987
- ...toolMeta ? { mcp: { _meta: toolMeta } } : {},
994
+ // Also propagate MCP tool annotations so listTools() / listToolsets() consumers
995
+ // can read them via `tool.mcp.annotations`.
996
+ ...mcpToolProps,
988
997
  // Don't pass outputSchema to createTool — the MCP SDK's Client.callTool()
989
998
  // already validates structuredContent against the tool's outputSchema using AJV.
990
999
  // Passing it here causes Zod to strip unrecognized keys from the CallToolResult
@@ -2307,7 +2316,7 @@ function createSimpleTokenProvider(accessToken, options) {
2307
2316
  });
2308
2317
  }
2309
2318
 
2310
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/utils/stream.js
2319
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/utils/stream.js
2311
2320
  var StreamingApi = class {
2312
2321
  writer;
2313
2322
  encoder;
@@ -2384,7 +2393,7 @@ var StreamingApi = class {
2384
2393
  }
2385
2394
  };
2386
2395
 
2387
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/helper/streaming/utils.js
2396
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/helper/streaming/utils.js
2388
2397
  var isOldBunVersion = () => {
2389
2398
  const version = typeof Bun !== "undefined" ? Bun.version : void 0;
2390
2399
  if (version === void 0) {
@@ -2395,7 +2404,7 @@ var isOldBunVersion = () => {
2395
2404
  return result;
2396
2405
  };
2397
2406
 
2398
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/utils/html.js
2407
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/utils/html.js
2399
2408
  var HtmlEscapedCallbackPhase = {
2400
2409
  Stringify: 1};
2401
2410
  var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
@@ -2426,7 +2435,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
2426
2435
  }
2427
2436
  };
2428
2437
 
2429
- // ../../node_modules/.pnpm/hono@4.12.14/node_modules/hono/dist/helper/streaming/sse.js
2438
+ // ../../node_modules/.pnpm/hono@4.12.18/node_modules/hono/dist/helper/streaming/sse.js
2430
2439
  var SSEStreamingApi = class extends StreamingApi {
2431
2440
  constructor(writable, readable) {
2432
2441
  super(writable, readable);
@@ -4179,6 +4188,10 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
4179
4188
  }) {
4180
4189
  try {
4181
4190
  this.logger.debug("Received SSE connection");
4191
+ if (this.sseTransport) {
4192
+ await this.sseTransport.close?.();
4193
+ this.sseTransport = void 0;
4194
+ }
4182
4195
  this.sseTransport = new SSEServerTransport(messagePath, res);
4183
4196
  await this.server.connect(this.sseTransport);
4184
4197
  this.server.onclose = async () => {