@mastra/fastify 0.0.0-feat-mcp-embedded-docs-tools-clean-20260108110334

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.cjs ADDED
@@ -0,0 +1,687 @@
1
+ 'use strict';
2
+
3
+ var busboy = require('@fastify/busboy');
4
+ var error = require('@mastra/server/handlers/error');
5
+ var serverAdapter = require('@mastra/server/server-adapter');
6
+ var auth = require('@mastra/server/auth');
7
+
8
+ // src/index.ts
9
+
10
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
11
+ var util;
12
+ (function(util2) {
13
+ util2.assertEqual = (_) => {
14
+ };
15
+ function assertIs(_arg) {
16
+ }
17
+ util2.assertIs = assertIs;
18
+ function assertNever(_x) {
19
+ throw new Error();
20
+ }
21
+ util2.assertNever = assertNever;
22
+ util2.arrayToEnum = (items) => {
23
+ const obj = {};
24
+ for (const item of items) {
25
+ obj[item] = item;
26
+ }
27
+ return obj;
28
+ };
29
+ util2.getValidEnumValues = (obj) => {
30
+ const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
31
+ const filtered = {};
32
+ for (const k of validKeys) {
33
+ filtered[k] = obj[k];
34
+ }
35
+ return util2.objectValues(filtered);
36
+ };
37
+ util2.objectValues = (obj) => {
38
+ return util2.objectKeys(obj).map(function(e) {
39
+ return obj[e];
40
+ });
41
+ };
42
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
43
+ const keys = [];
44
+ for (const key in object) {
45
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
46
+ keys.push(key);
47
+ }
48
+ }
49
+ return keys;
50
+ };
51
+ util2.find = (arr, checker) => {
52
+ for (const item of arr) {
53
+ if (checker(item))
54
+ return item;
55
+ }
56
+ return void 0;
57
+ };
58
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
59
+ function joinValues(array, separator = " | ") {
60
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
61
+ }
62
+ util2.joinValues = joinValues;
63
+ util2.jsonStringifyReplacer = (_, value) => {
64
+ if (typeof value === "bigint") {
65
+ return value.toString();
66
+ }
67
+ return value;
68
+ };
69
+ })(util || (util = {}));
70
+ var objectUtil;
71
+ (function(objectUtil2) {
72
+ objectUtil2.mergeShapes = (first, second) => {
73
+ return {
74
+ ...first,
75
+ ...second
76
+ // second overwrites first
77
+ };
78
+ };
79
+ })(objectUtil || (objectUtil = {}));
80
+ util.arrayToEnum([
81
+ "string",
82
+ "nan",
83
+ "number",
84
+ "integer",
85
+ "float",
86
+ "boolean",
87
+ "date",
88
+ "bigint",
89
+ "symbol",
90
+ "function",
91
+ "undefined",
92
+ "null",
93
+ "array",
94
+ "object",
95
+ "unknown",
96
+ "promise",
97
+ "void",
98
+ "never",
99
+ "map",
100
+ "set"
101
+ ]);
102
+
103
+ // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
104
+ util.arrayToEnum([
105
+ "invalid_type",
106
+ "invalid_literal",
107
+ "custom",
108
+ "invalid_union",
109
+ "invalid_union_discriminator",
110
+ "invalid_enum_value",
111
+ "unrecognized_keys",
112
+ "invalid_arguments",
113
+ "invalid_return_type",
114
+ "invalid_date",
115
+ "invalid_string",
116
+ "too_small",
117
+ "too_big",
118
+ "invalid_intersection_types",
119
+ "not_multiple_of",
120
+ "not_finite"
121
+ ]);
122
+ var ZodError = class _ZodError extends Error {
123
+ get errors() {
124
+ return this.issues;
125
+ }
126
+ constructor(issues) {
127
+ super();
128
+ this.issues = [];
129
+ this.addIssue = (sub) => {
130
+ this.issues = [...this.issues, sub];
131
+ };
132
+ this.addIssues = (subs = []) => {
133
+ this.issues = [...this.issues, ...subs];
134
+ };
135
+ const actualProto = new.target.prototype;
136
+ if (Object.setPrototypeOf) {
137
+ Object.setPrototypeOf(this, actualProto);
138
+ } else {
139
+ this.__proto__ = actualProto;
140
+ }
141
+ this.name = "ZodError";
142
+ this.issues = issues;
143
+ }
144
+ format(_mapper) {
145
+ const mapper = _mapper || function(issue) {
146
+ return issue.message;
147
+ };
148
+ const fieldErrors = { _errors: [] };
149
+ const processError = (error) => {
150
+ for (const issue of error.issues) {
151
+ if (issue.code === "invalid_union") {
152
+ issue.unionErrors.map(processError);
153
+ } else if (issue.code === "invalid_return_type") {
154
+ processError(issue.returnTypeError);
155
+ } else if (issue.code === "invalid_arguments") {
156
+ processError(issue.argumentsError);
157
+ } else if (issue.path.length === 0) {
158
+ fieldErrors._errors.push(mapper(issue));
159
+ } else {
160
+ let curr = fieldErrors;
161
+ let i = 0;
162
+ while (i < issue.path.length) {
163
+ const el = issue.path[i];
164
+ const terminal = i === issue.path.length - 1;
165
+ if (!terminal) {
166
+ curr[el] = curr[el] || { _errors: [] };
167
+ } else {
168
+ curr[el] = curr[el] || { _errors: [] };
169
+ curr[el]._errors.push(mapper(issue));
170
+ }
171
+ curr = curr[el];
172
+ i++;
173
+ }
174
+ }
175
+ }
176
+ };
177
+ processError(this);
178
+ return fieldErrors;
179
+ }
180
+ static assert(value) {
181
+ if (!(value instanceof _ZodError)) {
182
+ throw new Error(`Not a ZodError: ${value}`);
183
+ }
184
+ }
185
+ toString() {
186
+ return this.message;
187
+ }
188
+ get message() {
189
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
190
+ }
191
+ get isEmpty() {
192
+ return this.issues.length === 0;
193
+ }
194
+ flatten(mapper = (issue) => issue.message) {
195
+ const fieldErrors = {};
196
+ const formErrors = [];
197
+ for (const sub of this.issues) {
198
+ if (sub.path.length > 0) {
199
+ const firstEl = sub.path[0];
200
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
201
+ fieldErrors[firstEl].push(mapper(sub));
202
+ } else {
203
+ formErrors.push(mapper(sub));
204
+ }
205
+ }
206
+ return { formErrors, fieldErrors };
207
+ }
208
+ get formErrors() {
209
+ return this.flatten();
210
+ }
211
+ };
212
+ ZodError.create = (issues) => {
213
+ const error = new ZodError(issues);
214
+ return error;
215
+ };
216
+ var authenticationMiddleware = async (request, reply) => {
217
+ const mastra = request.mastra;
218
+ const authConfig = mastra.getServer()?.auth;
219
+ const customRouteAuthConfig = request.customRouteAuthConfig;
220
+ if (!authConfig) {
221
+ return;
222
+ }
223
+ const path = String(request.url.split("?")[0] || "/");
224
+ const method = String(request.method || "GET");
225
+ const getHeader = (name) => request.headers[name.toLowerCase()];
226
+ if (auth.isDevPlaygroundRequest(path, method, getHeader, authConfig)) {
227
+ return;
228
+ }
229
+ if (!auth.isProtectedPath(path, method, authConfig, customRouteAuthConfig)) {
230
+ return;
231
+ }
232
+ if (auth.canAccessPublicly(path, method, authConfig)) {
233
+ return;
234
+ }
235
+ const authHeader = request.headers.authorization;
236
+ let token = authHeader ? authHeader.replace("Bearer ", "") : null;
237
+ const query = request.query;
238
+ if (!token && query.apiKey) {
239
+ token = query.apiKey || null;
240
+ }
241
+ if (!token) {
242
+ return reply.status(401).send({ error: "Authentication required" });
243
+ }
244
+ try {
245
+ let user;
246
+ if (typeof authConfig.authenticateToken === "function") {
247
+ user = await authConfig.authenticateToken(token, request);
248
+ } else {
249
+ throw new Error("No token verification method configured");
250
+ }
251
+ if (!user) {
252
+ return reply.status(401).send({ error: "Invalid or expired token" });
253
+ }
254
+ request.requestContext.set("user", user);
255
+ return;
256
+ } catch (err) {
257
+ console.error(err);
258
+ return reply.status(401).send({ error: "Invalid or expired token" });
259
+ }
260
+ };
261
+ var authorizationMiddleware = async (request, reply) => {
262
+ const mastra = request.mastra;
263
+ const authConfig = mastra.getServer()?.auth;
264
+ const customRouteAuthConfig = request.customRouteAuthConfig;
265
+ if (!authConfig) {
266
+ return;
267
+ }
268
+ const path = String(request.url.split("?")[0] || "/");
269
+ const method = String(request.method || "GET");
270
+ const getHeader = (name) => request.headers[name.toLowerCase()];
271
+ if (auth.isDevPlaygroundRequest(path, method, getHeader, authConfig)) {
272
+ return;
273
+ }
274
+ if (!auth.isProtectedPath(path, method, authConfig, customRouteAuthConfig)) {
275
+ return;
276
+ }
277
+ if (auth.canAccessPublicly(path, method, authConfig)) {
278
+ return;
279
+ }
280
+ const user = request.requestContext.get("user");
281
+ if ("authorizeUser" in authConfig && typeof authConfig.authorizeUser === "function") {
282
+ try {
283
+ const isAuthorized = await authConfig.authorizeUser(user, request);
284
+ if (isAuthorized) {
285
+ return;
286
+ }
287
+ return reply.status(403).send({ error: "Access denied" });
288
+ } catch (err) {
289
+ console.error(err);
290
+ return reply.status(500).send({ error: "Authorization error" });
291
+ }
292
+ }
293
+ if ("authorize" in authConfig && typeof authConfig.authorize === "function") {
294
+ try {
295
+ const context = {
296
+ get: (key) => {
297
+ if (key === "mastra") return request.mastra;
298
+ if (key === "requestContext") return request.requestContext;
299
+ if (key === "tools") return request.tools;
300
+ if (key === "taskStore") return request.taskStore;
301
+ if (key === "customRouteAuthConfig") return request.customRouteAuthConfig;
302
+ return void 0;
303
+ },
304
+ req: request
305
+ };
306
+ const isAuthorized = await authConfig.authorize(path, method, user, context);
307
+ if (isAuthorized) {
308
+ return;
309
+ }
310
+ return reply.status(403).send({ error: "Access denied" });
311
+ } catch (err) {
312
+ console.error(err);
313
+ return reply.status(500).send({ error: "Authorization error" });
314
+ }
315
+ }
316
+ if ("rules" in authConfig && authConfig.rules && authConfig.rules.length > 0) {
317
+ const isAuthorized = await auth.checkRules(authConfig.rules, path, method, user);
318
+ if (isAuthorized) {
319
+ return;
320
+ }
321
+ return reply.status(403).send({ error: "Access denied" });
322
+ }
323
+ if (auth.defaultAuthConfig.rules && auth.defaultAuthConfig.rules.length > 0) {
324
+ const isAuthorized = await auth.checkRules(auth.defaultAuthConfig.rules, path, method, user);
325
+ if (isAuthorized) {
326
+ return;
327
+ }
328
+ }
329
+ return reply.status(403).send({ error: "Access denied" });
330
+ };
331
+
332
+ // src/index.ts
333
+ var MastraServer = class extends serverAdapter.MastraServer {
334
+ createContextMiddleware() {
335
+ return async (request, _reply) => {
336
+ let bodyRequestContext;
337
+ let paramsRequestContext;
338
+ if (request.method === "POST" || request.method === "PUT") {
339
+ const contentType = request.headers["content-type"];
340
+ if (contentType?.includes("application/json") && request.body) {
341
+ const body = request.body;
342
+ if (body.requestContext) {
343
+ bodyRequestContext = body.requestContext;
344
+ }
345
+ }
346
+ }
347
+ if (request.method === "GET") {
348
+ try {
349
+ const query = request.query;
350
+ const encodedRequestContext = query.requestContext;
351
+ if (typeof encodedRequestContext === "string") {
352
+ try {
353
+ paramsRequestContext = JSON.parse(encodedRequestContext);
354
+ } catch {
355
+ try {
356
+ const json = Buffer.from(encodedRequestContext, "base64").toString("utf-8");
357
+ paramsRequestContext = JSON.parse(json);
358
+ } catch {
359
+ }
360
+ }
361
+ }
362
+ } catch {
363
+ }
364
+ }
365
+ const requestContext = this.mergeRequestContext({ paramsRequestContext, bodyRequestContext });
366
+ request.requestContext = requestContext;
367
+ request.mastra = this.mastra;
368
+ request.tools = this.tools || {};
369
+ if (this.taskStore) {
370
+ request.taskStore = this.taskStore;
371
+ }
372
+ request.customRouteAuthConfig = this.customRouteAuthConfig;
373
+ const controller = new AbortController();
374
+ request.raw.on("close", () => {
375
+ if (!request.raw.complete) {
376
+ controller.abort();
377
+ }
378
+ });
379
+ request.abortSignal = controller.signal;
380
+ };
381
+ }
382
+ async stream(route, reply, result) {
383
+ reply.hijack();
384
+ reply.raw.writeHead(200, {
385
+ "Content-Type": "text/plain",
386
+ "Transfer-Encoding": "chunked"
387
+ });
388
+ const streamFormat = route.streamFormat || "stream";
389
+ const readableStream = result instanceof ReadableStream ? result : result.fullStream;
390
+ const reader = readableStream.getReader();
391
+ reply.raw.on("close", () => {
392
+ void reader.cancel("request aborted");
393
+ });
394
+ try {
395
+ while (true) {
396
+ const { done, value } = await reader.read();
397
+ if (done) break;
398
+ if (value) {
399
+ const shouldRedact = this.streamOptions?.redact ?? true;
400
+ const outputValue = shouldRedact ? serverAdapter.redactStreamChunk(value) : value;
401
+ if (streamFormat === "sse") {
402
+ reply.raw.write(`data: ${JSON.stringify(outputValue)}
403
+
404
+ `);
405
+ } else {
406
+ reply.raw.write(JSON.stringify(outputValue) + "");
407
+ }
408
+ }
409
+ }
410
+ } catch (error) {
411
+ console.error(error);
412
+ } finally {
413
+ reply.raw.end();
414
+ }
415
+ }
416
+ async getParams(route, request) {
417
+ const urlParams = request.params || {};
418
+ const queryParams = serverAdapter.normalizeQueryParams(request.query || {});
419
+ let body;
420
+ if (route.method === "POST" || route.method === "PUT" || route.method === "PATCH") {
421
+ const contentType = request.headers["content-type"] || "";
422
+ if (contentType.includes("multipart/form-data")) {
423
+ try {
424
+ const maxFileSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;
425
+ body = await this.parseMultipartFormData(request, maxFileSize);
426
+ } catch (error) {
427
+ console.error("Failed to parse multipart form data:", error);
428
+ if (error instanceof Error && error.message.toLowerCase().includes("size")) {
429
+ throw error;
430
+ }
431
+ }
432
+ } else {
433
+ body = request.body;
434
+ }
435
+ }
436
+ return { urlParams, queryParams, body };
437
+ }
438
+ /**
439
+ * Parse multipart/form-data using @fastify/busboy.
440
+ * Converts file uploads to Buffers and parses JSON field values.
441
+ *
442
+ * @param request - The Fastify request object
443
+ * @param maxFileSize - Optional maximum file size in bytes
444
+ */
445
+ parseMultipartFormData(request, maxFileSize) {
446
+ return new Promise((resolve, reject) => {
447
+ const result = {};
448
+ const busboy$1 = new busboy.Busboy({
449
+ headers: {
450
+ "content-type": request.headers["content-type"]
451
+ },
452
+ limits: maxFileSize ? { fileSize: maxFileSize } : void 0
453
+ });
454
+ busboy$1.on("file", (fieldname, file) => {
455
+ const chunks = [];
456
+ let limitExceeded = false;
457
+ file.on("data", (chunk) => {
458
+ chunks.push(chunk);
459
+ });
460
+ file.on("limit", () => {
461
+ limitExceeded = true;
462
+ reject(new Error(`File size limit exceeded${maxFileSize ? ` (max: ${maxFileSize} bytes)` : ""}`));
463
+ });
464
+ file.on("end", () => {
465
+ if (!limitExceeded) {
466
+ result[fieldname] = Buffer.concat(chunks);
467
+ }
468
+ });
469
+ });
470
+ busboy$1.on("field", (fieldname, value) => {
471
+ try {
472
+ result[fieldname] = JSON.parse(value);
473
+ } catch {
474
+ result[fieldname] = value;
475
+ }
476
+ });
477
+ busboy$1.on("finish", () => {
478
+ resolve(result);
479
+ });
480
+ busboy$1.on("error", (error) => {
481
+ reject(error);
482
+ });
483
+ request.raw.pipe(busboy$1);
484
+ });
485
+ }
486
+ async sendResponse(route, reply, result, request) {
487
+ if (route.responseType === "json") {
488
+ await reply.send(result);
489
+ } else if (route.responseType === "stream") {
490
+ await this.stream(route, reply, result);
491
+ } else if (route.responseType === "datastream-response") {
492
+ const fetchResponse = result;
493
+ fetchResponse.headers.forEach((value, key) => reply.header(key, value));
494
+ reply.status(fetchResponse.status);
495
+ if (fetchResponse.body) {
496
+ const reader = fetchResponse.body.getReader();
497
+ try {
498
+ while (true) {
499
+ const { done, value } = await reader.read();
500
+ if (done) break;
501
+ reply.raw.write(value);
502
+ }
503
+ } finally {
504
+ reply.raw.end();
505
+ }
506
+ } else {
507
+ reply.raw.end();
508
+ }
509
+ } else if (route.responseType === "mcp-http") {
510
+ if (!request) {
511
+ await reply.status(500).send({ error: "Request object required for MCP transport" });
512
+ return;
513
+ }
514
+ const { server, httpPath } = result;
515
+ try {
516
+ reply.hijack();
517
+ const rawReq = request.raw;
518
+ if (request.body !== void 0) {
519
+ rawReq.body = request.body;
520
+ }
521
+ await server.startHTTP({
522
+ url: new URL(request.url, `http://${request.headers.host}`),
523
+ httpPath,
524
+ req: rawReq,
525
+ res: reply.raw
526
+ });
527
+ } catch {
528
+ if (!reply.raw.headersSent) {
529
+ reply.raw.writeHead(500, { "Content-Type": "application/json" });
530
+ reply.raw.end(
531
+ JSON.stringify({
532
+ jsonrpc: "2.0",
533
+ error: { code: -32603, message: "Internal server error" },
534
+ id: null
535
+ })
536
+ );
537
+ }
538
+ }
539
+ } else if (route.responseType === "mcp-sse") {
540
+ if (!request) {
541
+ await reply.status(500).send({ error: "Request object required for MCP transport" });
542
+ return;
543
+ }
544
+ const { server, ssePath, messagePath } = result;
545
+ try {
546
+ reply.hijack();
547
+ const rawReq = request.raw;
548
+ if (request.body !== void 0) {
549
+ rawReq.body = request.body;
550
+ }
551
+ await server.startSSE({
552
+ url: new URL(request.url, `http://${request.headers.host}`),
553
+ ssePath,
554
+ messagePath,
555
+ req: rawReq,
556
+ res: reply.raw
557
+ });
558
+ } catch {
559
+ if (!reply.raw.headersSent) {
560
+ reply.raw.writeHead(500, { "Content-Type": "application/json" });
561
+ reply.raw.end(JSON.stringify({ error: "Error handling MCP SSE request" }));
562
+ }
563
+ }
564
+ } else {
565
+ reply.status(500);
566
+ }
567
+ }
568
+ async registerRoute(app, route, { prefix }) {
569
+ const fullPath = `${prefix}${route.path}`;
570
+ const fastifyPath = fullPath;
571
+ const handler = async (request, reply) => {
572
+ const params = await this.getParams(route, request);
573
+ if (params.queryParams) {
574
+ try {
575
+ params.queryParams = await this.parseQueryParams(route, params.queryParams);
576
+ } catch (error$1) {
577
+ console.error("Error parsing query params", error$1);
578
+ if (error$1 instanceof ZodError) {
579
+ return reply.status(400).send(error.formatZodError(error$1, "query parameters"));
580
+ }
581
+ return reply.status(400).send({
582
+ error: "Invalid query parameters",
583
+ issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
584
+ });
585
+ }
586
+ }
587
+ if (params.body) {
588
+ try {
589
+ params.body = await this.parseBody(route, params.body);
590
+ } catch (error$1) {
591
+ console.error("Error parsing body:", error$1 instanceof Error ? error$1.message : String(error$1));
592
+ if (error$1 instanceof ZodError) {
593
+ return reply.status(400).send(error.formatZodError(error$1, "request body"));
594
+ }
595
+ return reply.status(400).send({
596
+ error: "Invalid request body",
597
+ issues: [{ field: "unknown", message: error$1 instanceof Error ? error$1.message : "Unknown error" }]
598
+ });
599
+ }
600
+ }
601
+ const handlerParams = {
602
+ ...params.urlParams,
603
+ ...params.queryParams,
604
+ ...typeof params.body === "object" ? params.body : {},
605
+ requestContext: request.requestContext,
606
+ mastra: this.mastra,
607
+ tools: request.tools,
608
+ taskStore: request.taskStore,
609
+ abortSignal: request.abortSignal
610
+ };
611
+ try {
612
+ const result = await route.handler(handlerParams);
613
+ await this.sendResponse(route, reply, result, request);
614
+ } catch (error) {
615
+ console.error("Error calling handler", error);
616
+ let status = 500;
617
+ if (error && typeof error === "object") {
618
+ if ("status" in error) {
619
+ status = error.status;
620
+ } else if ("details" in error && error.details && typeof error.details === "object" && "status" in error.details) {
621
+ status = error.details.status;
622
+ }
623
+ }
624
+ await reply.status(status).send({ error: error instanceof Error ? error.message : "Unknown error" });
625
+ }
626
+ };
627
+ const shouldApplyBodyLimit = this.bodyLimitOptions && ["POST", "PUT", "PATCH"].includes(route.method.toUpperCase());
628
+ const maxSize = route.maxBodySize ?? this.bodyLimitOptions?.maxSize;
629
+ const config = shouldApplyBodyLimit && maxSize ? { bodyLimit: maxSize } : void 0;
630
+ if (route.method.toUpperCase() === "ALL") {
631
+ const methods = ["GET", "POST", "PUT", "DELETE", "PATCH"];
632
+ for (const method of methods) {
633
+ try {
634
+ app.route({
635
+ method,
636
+ url: fastifyPath,
637
+ handler,
638
+ config
639
+ });
640
+ } catch (err) {
641
+ if (err instanceof Error && err.message.includes("already declared")) {
642
+ continue;
643
+ }
644
+ throw err;
645
+ }
646
+ }
647
+ } else {
648
+ app.route({
649
+ method: route.method,
650
+ url: fastifyPath,
651
+ handler,
652
+ config
653
+ });
654
+ }
655
+ }
656
+ registerContextMiddleware() {
657
+ this.app.removeContentTypeParser("application/json");
658
+ this.app.addContentTypeParser("application/json", { parseAs: "string" }, (_request, body, done) => {
659
+ try {
660
+ if (!body || typeof body === "string" && body.trim() === "") {
661
+ done(null, void 0);
662
+ return;
663
+ }
664
+ const parsed = JSON.parse(body);
665
+ done(null, parsed);
666
+ } catch (err) {
667
+ done(err, void 0);
668
+ }
669
+ });
670
+ this.app.addContentTypeParser("multipart/form-data", (_request, _payload, done) => {
671
+ done(null, void 0);
672
+ });
673
+ this.app.addHook("preHandler", this.createContextMiddleware());
674
+ }
675
+ registerAuthMiddleware() {
676
+ const authConfig = this.mastra.getServer()?.auth;
677
+ if (!authConfig) {
678
+ return;
679
+ }
680
+ this.app.addHook("preHandler", authenticationMiddleware);
681
+ this.app.addHook("preHandler", authorizationMiddleware);
682
+ }
683
+ };
684
+
685
+ exports.MastraServer = MastraServer;
686
+ //# sourceMappingURL=index.cjs.map
687
+ //# sourceMappingURL=index.cjs.map