@mastra/mcp 2.5.0 → 2.6.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/cli/generate-D0K0N5WQ.js +218 -0
- package/dist/cli/generate-D0K0N5WQ.js.map +1 -0
- package/dist/cli/generate.d.ts +18 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +32 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/json-schema-dialect-CdIOPBiC.js +132 -0
- package/dist/cli/json-schema-dialect-CdIOPBiC.js.map +1 -0
- package/dist/cli/typegen-B5dH_z0t.js +363 -0
- package/dist/cli/typegen-B5dH_z0t.js.map +1 -0
- package/dist/cli/typegen.d.ts +14 -0
- package/dist/cli/typegen.d.ts.map +1 -0
- package/dist/client/client.d.ts +2 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +30 -10
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +38 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/docs/SKILL.md +2 -3
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-connections-mcp.md +159 -50
- package/dist/docs/references/docs-connections-overview.md +1 -1
- package/dist/docs/references/docs-guides-mcp-authentication-authorization.md +2 -2
- package/dist/docs/references/reference-migrations-mcp-v2.md +1 -1
- package/dist/docs/references/reference-tools-mcp-client.md +207 -16
- package/dist/docs/references/reference-tools-mcp-server.md +9 -7
- package/dist/index.cjs +270 -257
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +269 -255
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts +13 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/shared/json-schema-dialect.d.ts +34 -0
- package/dist/shared/json-schema-dialect.d.ts.map +1 -1
- package/package.json +25 -20
- package/dist/docs/references/docs-guides-mcp-events.md +0 -306
package/dist/index.js
CHANGED
|
@@ -27,11 +27,10 @@ import { CLIENT_INFO_META_KEY, PROTOCOL_VERSION_META_KEY, ProtocolError as Proto
|
|
|
27
27
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
28
28
|
import https from "https";
|
|
29
29
|
import { SignalProvider } from "@mastra/core/signals";
|
|
30
|
-
|
|
30
|
+
// src/client/types.ts
|
|
31
31
|
/** The current protocol revision; the one `/mcp` servers speak. */
|
|
32
32
|
const MCP_CLIENT_PROTOCOL_VERSION = "2026-07-28";
|
|
33
|
-
|
|
34
|
-
//#region ../schema-compat/dist/json-schema-traverse-Jrimn_T_.js
|
|
33
|
+
// ../schema-compat/dist/json-schema-traverse-D0CId4oM.js
|
|
35
34
|
var __create$1 = Object.create;
|
|
36
35
|
var __defProp$2 = Object.defineProperty;
|
|
37
36
|
var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
@@ -126,8 +125,7 @@ var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin$1(((exports, mo
|
|
|
126
125
|
return str.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
127
126
|
}
|
|
128
127
|
}));
|
|
129
|
-
|
|
130
|
-
//#region ../schema-compat/dist/esm-DA8owk0L.js
|
|
128
|
+
// ../schema-compat/dist/esm-BG70JlG8.js
|
|
131
129
|
const ignoreOverride$1 = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
132
130
|
const defaultOptions$1 = {
|
|
133
131
|
name: void 0,
|
|
@@ -1133,8 +1131,7 @@ const zodToJsonSchema$1 = (schema, options) => {
|
|
|
1133
1131
|
return combined;
|
|
1134
1132
|
};
|
|
1135
1133
|
var esm_default$1 = zodToJsonSchema$1;
|
|
1136
|
-
|
|
1137
|
-
//#region ../schema-compat/dist/zod-to-json.js
|
|
1134
|
+
// ../schema-compat/dist/zod-to-json.js
|
|
1138
1135
|
const PATCHED = Symbol("__mastra_patched__");
|
|
1139
1136
|
/**
|
|
1140
1137
|
* Recursively patch Zod v4 record schemas that are missing valueType.
|
|
@@ -1185,8 +1182,7 @@ function patchRecordSchemas(schema) {
|
|
|
1185
1182
|
if (def.innerType) patchRecordSchemas(def.innerType);
|
|
1186
1183
|
return schema;
|
|
1187
1184
|
}
|
|
1188
|
-
|
|
1189
|
-
//#region ../schema-compat/dist/standard-schema/adapters/ai-sdk.js
|
|
1185
|
+
// ../schema-compat/dist/standard-schema/adapters/ai-sdk.js
|
|
1190
1186
|
/**
|
|
1191
1187
|
* Vendor name for AI SDK wrapped schemas.
|
|
1192
1188
|
*/
|
|
@@ -1334,8 +1330,7 @@ var AiSdkSchemaWrapper = class {
|
|
|
1334
1330
|
function toStandardSchema$4(schema) {
|
|
1335
1331
|
return new AiSdkSchemaWrapper(schema);
|
|
1336
1332
|
}
|
|
1337
|
-
|
|
1338
|
-
//#region ../schema-compat/dist/json-schema-DcMkkbbI.js
|
|
1333
|
+
// ../schema-compat/dist/json-schema-BdCwqjfN.js
|
|
1339
1334
|
var require_code$1 = /* @__PURE__ */ __commonJSMin$1(((exports) => {
|
|
1340
1335
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1341
1336
|
exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
|
|
@@ -4230,6 +4225,38 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4230
4225
|
return output.join("");
|
|
4231
4226
|
}
|
|
4232
4227
|
/**
|
|
4228
|
+
* Removes dot segments from the path of a relative reference (a path that does
|
|
4229
|
+
* not start with "/") without changing what it resolves to against any base.
|
|
4230
|
+
* Unlike `removeDotSegments`, leading ".." segments that cannot be collapsed
|
|
4231
|
+
* are kept, the result never becomes root-relative, and a result that would be
|
|
4232
|
+
* empty or start with an empty segment is prefixed with "." (an empty path
|
|
4233
|
+
* means "same document" and a leading "//" would introduce an authority).
|
|
4234
|
+
*
|
|
4235
|
+
* @param {string} path
|
|
4236
|
+
* @returns {string}
|
|
4237
|
+
*/
|
|
4238
|
+
function removeDotSegmentsRelative(path) {
|
|
4239
|
+
if (path === "" || path[0] === "/") return removeDotSegments(path);
|
|
4240
|
+
const segments = path.split("/");
|
|
4241
|
+
const last = segments.length - 1;
|
|
4242
|
+
/** @type {string[]} */
|
|
4243
|
+
const output = [];
|
|
4244
|
+
let trailingDirectory = false;
|
|
4245
|
+
for (let i = 0; i <= last; i++) {
|
|
4246
|
+
const segment = segments[i];
|
|
4247
|
+
if (segment === "." || segment === "..") {
|
|
4248
|
+
if (segment === "..") {
|
|
4249
|
+
if (output.length !== 0 && output[output.length - 1] !== "..") output.pop();
|
|
4250
|
+
else output.push("..");
|
|
4251
|
+
}
|
|
4252
|
+
trailingDirectory = i === last;
|
|
4253
|
+
} else output.push(segment);
|
|
4254
|
+
}
|
|
4255
|
+
if (trailingDirectory && output[output.length - 1] !== "..") output.push("");
|
|
4256
|
+
if (output.length === 0 || output[0] === "" || output[0].includes(":")) output.unshift(".");
|
|
4257
|
+
return output.join("/");
|
|
4258
|
+
}
|
|
4259
|
+
/**
|
|
4233
4260
|
* Re-escape RFC 3986 gen-delims that must not appear literally in the host.
|
|
4234
4261
|
* After the URI regex parses, these characters cannot be literal in the host
|
|
4235
4262
|
* field, so any that appear after decoding came from percent-encoding and
|
|
@@ -4533,6 +4560,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4533
4560
|
encodeFragment,
|
|
4534
4561
|
escapePreservingEscapes,
|
|
4535
4562
|
removeDotSegments,
|
|
4563
|
+
removeDotSegmentsRelative,
|
|
4536
4564
|
isIPv4,
|
|
4537
4565
|
isUUID,
|
|
4538
4566
|
normalizeIPv6,
|
|
@@ -4722,18 +4750,24 @@ var require_schemes = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4722
4750
|
};
|
|
4723
4751
|
}));
|
|
4724
4752
|
var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
4725
|
-
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
4753
|
+
const { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
4726
4754
|
const { SCHEMES, getSchemeHandler } = require_schemes();
|
|
4727
4755
|
const VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
4728
4756
|
const MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
4757
|
+
const MALFORMED_HOST_ERROR = "URI host is malformed.";
|
|
4758
|
+
const FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
|
|
4729
4759
|
/**
|
|
4760
|
+
* RFC 3986 section 3.1 does not allow percent-encoding in a scheme, so the
|
|
4761
|
+
* scheme is validated as-is and never decoded. Decoding would let inert input
|
|
4762
|
+
* such as `%6Aavascript:` become a live `javascript:` scheme.
|
|
4763
|
+
*
|
|
4730
4764
|
* @param {string} scheme
|
|
4731
4765
|
* @returns {string}
|
|
4732
4766
|
*/
|
|
4733
|
-
function
|
|
4734
|
-
const
|
|
4735
|
-
if (!VALID_SCHEME.test(
|
|
4736
|
-
return
|
|
4767
|
+
function validateScheme(scheme) {
|
|
4768
|
+
const stringScheme = String(scheme);
|
|
4769
|
+
if (!VALID_SCHEME.test(stringScheme)) throw new TypeError(MALFORMED_SCHEME_ERROR);
|
|
4770
|
+
return stringScheme;
|
|
4737
4771
|
}
|
|
4738
4772
|
/**
|
|
4739
4773
|
* @template {import('./types/index').URIComponent|string} T
|
|
@@ -4761,6 +4795,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4761
4795
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
4762
4796
|
const resolvedHost = resolved.host;
|
|
4763
4797
|
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
4798
|
+
if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) throw new Error(MALFORMED_HOST_ERROR);
|
|
4764
4799
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
4765
4800
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
|
|
4766
4801
|
if (resolved.error && !encodedASCIIHost) throw new Error(resolved.error);
|
|
@@ -4804,10 +4839,11 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4804
4839
|
} else {
|
|
4805
4840
|
if (relative.path[0] === "/") target.path = removeDotSegments(relative.path);
|
|
4806
4841
|
else {
|
|
4807
|
-
|
|
4842
|
+
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
4843
|
+
if (baseHasAuthority && !base.path) target.path = "/" + relative.path;
|
|
4808
4844
|
else if (!base.path) target.path = relative.path;
|
|
4809
4845
|
else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
|
4810
|
-
target.path = removeDotSegments(target.path);
|
|
4846
|
+
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
4811
4847
|
}
|
|
4812
4848
|
target.query = relative.query;
|
|
4813
4849
|
}
|
|
@@ -4855,17 +4891,18 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4855
4891
|
};
|
|
4856
4892
|
const options = Object.assign({}, opts);
|
|
4857
4893
|
const uriTokens = [];
|
|
4858
|
-
if (component.scheme) component.scheme =
|
|
4894
|
+
if (component.scheme) component.scheme = validateScheme(component.scheme);
|
|
4859
4895
|
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
4860
4896
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
4861
4897
|
const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
|
|
4862
|
-
const
|
|
4898
|
+
const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
|
|
4899
|
+
const pathNoScheme = !options.skipEscape && schemelessReference;
|
|
4863
4900
|
if (component.path !== void 0) {
|
|
4864
4901
|
if (!options.skipEscape) component.path = serializePathEncoding(component.path, pathNoScheme);
|
|
4865
4902
|
else component.path = normalizePercentEncoding(component.path);
|
|
4866
4903
|
}
|
|
4867
4904
|
if (options.reference !== "suffix" && component.scheme) {
|
|
4868
|
-
component.scheme =
|
|
4905
|
+
component.scheme = validateScheme(component.scheme);
|
|
4869
4906
|
uriTokens.push(component.scheme, ":");
|
|
4870
4907
|
}
|
|
4871
4908
|
const authority = recomposeAuthority(component);
|
|
@@ -4876,8 +4913,8 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4876
4913
|
}
|
|
4877
4914
|
if (component.path !== void 0) {
|
|
4878
4915
|
let s = component.path;
|
|
4879
|
-
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) s = removeDotSegments(s);
|
|
4880
|
-
if (
|
|
4916
|
+
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) s = schemelessReference && s[0] !== "/" ? removeDotSegmentsRelative(s) : removeDotSegments(s);
|
|
4917
|
+
if (schemelessReference) s = serializePathEncoding(s, true);
|
|
4881
4918
|
if (authority === void 0 && s[0] === "/" && s[1] === "/") s = "/%2F" + s.slice(2);
|
|
4882
4919
|
uriTokens.push(s);
|
|
4883
4920
|
}
|
|
@@ -4941,15 +4978,50 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
4941
4978
|
* @returns {boolean} whether host conversion failed
|
|
4942
4979
|
*/
|
|
4943
4980
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
4944
|
-
if (
|
|
4945
|
-
parsed.
|
|
4946
|
-
} catch (e) {
|
|
4947
|
-
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
4981
|
+
if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
|
|
4982
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4948
4983
|
return true;
|
|
4949
4984
|
}
|
|
4985
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
4986
|
+
let url;
|
|
4987
|
+
try {
|
|
4988
|
+
url = new URL("http://" + parsed.host);
|
|
4989
|
+
} catch (e) {
|
|
4990
|
+
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
4991
|
+
return true;
|
|
4992
|
+
}
|
|
4993
|
+
if (!isHostOnlyURL(url)) {
|
|
4994
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4995
|
+
return true;
|
|
4996
|
+
}
|
|
4997
|
+
parsed.host = url.hostname;
|
|
4998
|
+
}
|
|
4950
4999
|
return false;
|
|
4951
5000
|
}
|
|
4952
5001
|
/**
|
|
5002
|
+
* Whether a domain host contains an ASCII character that RFC 3986 does not
|
|
5003
|
+
* allow in a reg-name (unreserved, sub-delims, or pct-encoded). Such a host is
|
|
5004
|
+
* rejected instead of being handed to the WHATWG URL parser, which would treat
|
|
5005
|
+
* "@" as a userinfo delimiter (silently dropping the data before it) and strip
|
|
5006
|
+
* TAB, LF, and CR. Non-ASCII characters remain allowed for IDNs.
|
|
5007
|
+
*
|
|
5008
|
+
* @param {import('./types/index').URIComponent} parsed
|
|
5009
|
+
* @param {import('./types/index').Options} options
|
|
5010
|
+
* @param {{ domainHost?: boolean }|undefined} schemeHandler
|
|
5011
|
+
* @param {boolean} isIP
|
|
5012
|
+
* @returns {boolean}
|
|
5013
|
+
*/
|
|
5014
|
+
function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
|
|
5015
|
+
return Boolean(parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host));
|
|
5016
|
+
}
|
|
5017
|
+
/**
|
|
5018
|
+
* @param {URL} url
|
|
5019
|
+
* @returns {boolean}
|
|
5020
|
+
*/
|
|
5021
|
+
function isHostOnlyURL(url) {
|
|
5022
|
+
return url.username === "" && url.password === "" && url.port === "" && url.pathname === "/" && url.search === "" && url.hash === "" && url.hostname !== "";
|
|
5023
|
+
}
|
|
5024
|
+
/**
|
|
4953
5025
|
* @param {string} uri
|
|
4954
5026
|
* @param {import('./types/index').Options} [opts]
|
|
4955
5027
|
* @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean, malformedPercentEncoding: boolean, malformedSchemeSpecific: boolean, malformedHost: boolean, malformedScheme: boolean }}
|
|
@@ -5006,8 +5078,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
5006
5078
|
parsed.query = matches[7];
|
|
5007
5079
|
parsed.fragment = matches[8];
|
|
5008
5080
|
if (parsed.scheme !== void 0) {
|
|
5009
|
-
|
|
5010
|
-
if (VALID_SCHEME.test(decodedScheme)) parsed.scheme = decodedScheme.toLowerCase();
|
|
5081
|
+
if (VALID_SCHEME.test(parsed.scheme)) parsed.scheme = parsed.scheme.toLowerCase();
|
|
5011
5082
|
else {
|
|
5012
5083
|
parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
|
|
5013
5084
|
malformedScheme = true;
|
|
@@ -5030,7 +5101,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
5030
5101
|
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
5031
5102
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
5032
5103
|
if (malformedIPLiteral) {
|
|
5033
|
-
parsed.error = parsed.error ||
|
|
5104
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
5034
5105
|
malformedAuthorityOrPort = true;
|
|
5035
5106
|
}
|
|
5036
5107
|
} else isIP = true;
|
|
@@ -5045,7 +5116,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
|
5045
5116
|
if (uri.indexOf("%") !== -1 && parsed.host !== void 0 && !malformedIPLiteral) {
|
|
5046
5117
|
let host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
|
|
5047
5118
|
if (!isIP) host = normalizePercentEncoding(host.toLowerCase());
|
|
5048
|
-
parsed.host = reescapeHostDelimiters(host, isIP);
|
|
5119
|
+
parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
|
|
5049
5120
|
}
|
|
5050
5121
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
5051
5122
|
if (parsed.path) parsed.path = normalizePathEncoding(parsed.path);
|
|
@@ -8291,8 +8362,7 @@ var JsonSchemaWrapper = class {
|
|
|
8291
8362
|
function toStandardSchema$3(schema, options) {
|
|
8292
8363
|
return new JsonSchemaWrapper(schema, options);
|
|
8293
8364
|
}
|
|
8294
|
-
|
|
8295
|
-
//#region ../schema-compat/dist/standard-schema/adapters/zod-v3.js
|
|
8365
|
+
// ../schema-compat/dist/standard-schema/adapters/zod-v3.js
|
|
8296
8366
|
var import_json_schema_traverse$1 = /* @__PURE__ */ __toESM$1(require_json_schema_traverse(), 1);
|
|
8297
8367
|
/**
|
|
8298
8368
|
* Target mapping from Standard Schema targets to zod-to-json-schema targets.
|
|
@@ -8386,8 +8456,7 @@ function toStandardSchema$2(zodSchema) {
|
|
|
8386
8456
|
});
|
|
8387
8457
|
return wrapper;
|
|
8388
8458
|
}
|
|
8389
|
-
|
|
8390
|
-
//#region ../schema-compat/dist/schema-CzbEIyhE.js
|
|
8459
|
+
// ../schema-compat/dist/schema-Bf12g7KC.js
|
|
8391
8460
|
/**
|
|
8392
8461
|
* Supported JSON Schema targets for z.toJSONSchema().
|
|
8393
8462
|
* Works with both real Zod v4 and Zod 3.25's v4 compat layer.
|
|
@@ -8594,8 +8663,7 @@ function isStandardJSONSchema(value) {
|
|
|
8594
8663
|
function isStandardSchemaWithJSON$1(value) {
|
|
8595
8664
|
return isStandardSchema(value) && isStandardJSONSchema(value);
|
|
8596
8665
|
}
|
|
8597
|
-
|
|
8598
|
-
//#region ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-from-json-schema/0.5.2/938b1a90632b5c19aade6e212477c764befeb6d6e1cdb7cfde7de2557cd03f99/node_modules/zod-from-json-schema/dist/index.mjs
|
|
8666
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-from-json-schema/0.5.2/938b1a90632b5c19aade6e212477c764befeb6d6e1cdb7cfde7de2557cd03f99/node_modules/zod-from-json-schema/dist/index.mjs
|
|
8599
8667
|
var TypeHandler = class {
|
|
8600
8668
|
apply(types, schema) {
|
|
8601
8669
|
if (!schema.type) return;
|
|
@@ -9151,8 +9219,7 @@ function convertJsonSchemaToZod(schema) {
|
|
|
9151
9219
|
for (const handler of refinementHandlers) zodSchema = handler.apply(zodSchema, schema);
|
|
9152
9220
|
return zodSchema;
|
|
9153
9221
|
}
|
|
9154
|
-
|
|
9155
|
-
//#region ../schema-compat/dist/index.js
|
|
9222
|
+
// ../schema-compat/dist/index.js
|
|
9156
9223
|
var marker$1 = "vercel.ai.error";
|
|
9157
9224
|
var symbol$1 = Symbol.for(marker$1);
|
|
9158
9225
|
var _a$1;
|
|
@@ -12376,8 +12443,7 @@ function trimStartOfStream() {
|
|
|
12376
12443
|
};
|
|
12377
12444
|
}
|
|
12378
12445
|
require_json_schema_traverse();
|
|
12379
|
-
|
|
12380
|
-
//#region src/shared/events/constants.ts
|
|
12446
|
+
// src/shared/events/constants.ts
|
|
12381
12447
|
/**
|
|
12382
12448
|
* Wire constants for the MCP Events extension (SEP-3415).
|
|
12383
12449
|
*
|
|
@@ -12433,8 +12499,7 @@ const WEBHOOK_HEADERS = {
|
|
|
12433
12499
|
signature: "webhook-signature",
|
|
12434
12500
|
subscriptionId: "x-mcp-subscription-id"
|
|
12435
12501
|
};
|
|
12436
|
-
|
|
12437
|
-
//#region src/shared/events/schemas.ts
|
|
12502
|
+
// src/shared/events/schemas.ts
|
|
12438
12503
|
/**
|
|
12439
12504
|
* Zod schemas for the MCP Events extension (SEP-3415) wire format.
|
|
12440
12505
|
*
|
|
@@ -12640,8 +12705,7 @@ function parseWebhookBody(body) {
|
|
|
12640
12705
|
event: EventOccurrenceSchema.parse(body)
|
|
12641
12706
|
};
|
|
12642
12707
|
}
|
|
12643
|
-
|
|
12644
|
-
//#region src/shared/events/capability.ts
|
|
12708
|
+
// src/shared/events/capability.ts
|
|
12645
12709
|
/**
|
|
12646
12710
|
* Read the negotiated events extension settings from a capabilities object.
|
|
12647
12711
|
* Returns `undefined` when the peer did not advertise the extension (or advertised a malformed entry).
|
|
@@ -12657,8 +12721,7 @@ function getEventsCapability(capabilities) {
|
|
|
12657
12721
|
const parsed = EventsCapabilitySchema.safeParse(entry);
|
|
12658
12722
|
return parsed.success ? parsed.data : void 0;
|
|
12659
12723
|
}
|
|
12660
|
-
|
|
12661
|
-
//#region src/shared/events/webhook.ts
|
|
12724
|
+
// src/shared/events/webhook.ts
|
|
12662
12725
|
/**
|
|
12663
12726
|
* Standard Webhooks signing and verification for MCP Events webhook delivery (SEP-3415).
|
|
12664
12727
|
*
|
|
@@ -12746,8 +12809,7 @@ function verifyWebhook({ secret, headers, body, toleranceSec = DEFAULT_TOLERANCE
|
|
|
12746
12809
|
reason: "invalid_signature"
|
|
12747
12810
|
};
|
|
12748
12811
|
}
|
|
12749
|
-
|
|
12750
|
-
//#region src/shared/events/webhook-url.ts
|
|
12812
|
+
// src/shared/events/webhook-url.ts
|
|
12751
12813
|
/**
|
|
12752
12814
|
* SSRF policy for MCP Events webhook callback URLs (SEP-3415 "Webhook security").
|
|
12753
12815
|
*
|
|
@@ -12917,8 +12979,7 @@ async function resolveAndValidate(url, opts = {}) {
|
|
|
12917
12979
|
family: first.family
|
|
12918
12980
|
};
|
|
12919
12981
|
}
|
|
12920
|
-
|
|
12921
|
-
//#region src/shared/json-schema-dialect.ts
|
|
12982
|
+
// src/shared/json-schema-dialect.ts
|
|
12922
12983
|
const JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
12923
12984
|
const JSON_SCHEMA_2019_09 = /^https?:\/\/json-schema\.org\/draft\/2019-09\/schema#?$/;
|
|
12924
12985
|
/** Keywords whose value is a subschema (`items` may also be an array of subschemas). */
|
|
@@ -12952,6 +13013,89 @@ const SCHEMA_MAP_KEYWORDS$1 = /* @__PURE__ */ new Set([
|
|
|
12952
13013
|
const MAX_JSON_SCHEMA_NODES = 1e4;
|
|
12953
13014
|
var Unconvertible = class extends Error {};
|
|
12954
13015
|
/**
|
|
13016
|
+
* Bounds the work a validator or type generator can be asked to do for an untrusted schema.
|
|
13017
|
+
* Only schema-bearing keywords are walked, so deeply nested annotation data such as `default`
|
|
13018
|
+
* or `examples` does not count. The counted nodes are returned so callers can also budget
|
|
13019
|
+
* across a whole catalogue rather than one schema at a time.
|
|
13020
|
+
*
|
|
13021
|
+
* The keyword lists are intentionally wider than the conversion sets above: this walk has to
|
|
13022
|
+
* reach every position that can carry validation rules, including `dependencies`,
|
|
13023
|
+
* `prefixItems`, and `contentSchema`.
|
|
13024
|
+
*/
|
|
13025
|
+
function jsonSchemaComplexity(schema) {
|
|
13026
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13027
|
+
let nodes = 0;
|
|
13028
|
+
const stack = [{
|
|
13029
|
+
value: schema,
|
|
13030
|
+
depth: 0
|
|
13031
|
+
}];
|
|
13032
|
+
const schemaMapKeywords = [
|
|
13033
|
+
"$defs",
|
|
13034
|
+
"definitions",
|
|
13035
|
+
"properties",
|
|
13036
|
+
"patternProperties",
|
|
13037
|
+
"dependentSchemas",
|
|
13038
|
+
"dependencies"
|
|
13039
|
+
];
|
|
13040
|
+
const schemaArrayKeywords = [
|
|
13041
|
+
"prefixItems",
|
|
13042
|
+
"allOf",
|
|
13043
|
+
"anyOf",
|
|
13044
|
+
"oneOf",
|
|
13045
|
+
"items"
|
|
13046
|
+
];
|
|
13047
|
+
const schemaKeywords = [
|
|
13048
|
+
"additionalProperties",
|
|
13049
|
+
"unevaluatedProperties",
|
|
13050
|
+
"additionalItems",
|
|
13051
|
+
"unevaluatedItems",
|
|
13052
|
+
"items",
|
|
13053
|
+
"contains",
|
|
13054
|
+
"propertyNames",
|
|
13055
|
+
"not",
|
|
13056
|
+
"if",
|
|
13057
|
+
"then",
|
|
13058
|
+
"else",
|
|
13059
|
+
"contentSchema"
|
|
13060
|
+
];
|
|
13061
|
+
while (stack.length > 0) {
|
|
13062
|
+
const { value, depth } = stack.pop();
|
|
13063
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || seen.has(value)) continue;
|
|
13064
|
+
seen.add(value);
|
|
13065
|
+
nodes += 1;
|
|
13066
|
+
if (depth > 128) return {
|
|
13067
|
+
error: `JSON Schema exceeds the maximum depth of 128`,
|
|
13068
|
+
limit: "depth",
|
|
13069
|
+
nodes
|
|
13070
|
+
};
|
|
13071
|
+
if (nodes > 1e4) return {
|
|
13072
|
+
error: `JSON Schema exceeds the maximum node count of ${MAX_JSON_SCHEMA_NODES}`,
|
|
13073
|
+
limit: "nodes",
|
|
13074
|
+
nodes
|
|
13075
|
+
};
|
|
13076
|
+
const record = value;
|
|
13077
|
+
for (const keyword of schemaMapKeywords) {
|
|
13078
|
+
const schemas = record[keyword];
|
|
13079
|
+
if (schemas && typeof schemas === "object" && !Array.isArray(schemas)) for (const child of Object.values(schemas)) stack.push({
|
|
13080
|
+
value: child,
|
|
13081
|
+
depth: depth + 1
|
|
13082
|
+
});
|
|
13083
|
+
}
|
|
13084
|
+
for (const keyword of schemaArrayKeywords) {
|
|
13085
|
+
const schemas = record[keyword];
|
|
13086
|
+
if (Array.isArray(schemas)) for (const child of schemas) stack.push({
|
|
13087
|
+
value: child,
|
|
13088
|
+
depth: depth + 1
|
|
13089
|
+
});
|
|
13090
|
+
}
|
|
13091
|
+
for (const keyword of schemaKeywords) if (record[keyword] !== void 0) stack.push({
|
|
13092
|
+
value: record[keyword],
|
|
13093
|
+
depth: depth + 1
|
|
13094
|
+
});
|
|
13095
|
+
}
|
|
13096
|
+
return { nodes };
|
|
13097
|
+
}
|
|
13098
|
+
/**
|
|
12955
13099
|
* Converts a 2019-09 schema (e.g. from zod v3) into 2020-12 form. Tuples are the
|
|
12956
13100
|
* only structural difference handled: array-form `items` becomes `prefixItems`,
|
|
12957
13101
|
* and `additionalItems` becomes `items`.
|
|
@@ -13001,8 +13145,7 @@ function rewrite(schema, depth, budget, isRoot = false) {
|
|
|
13001
13145
|
delete out.additionalItems;
|
|
13002
13146
|
return out;
|
|
13003
13147
|
}
|
|
13004
|
-
|
|
13005
|
-
//#region src/shared/mastra-tool-meta.ts
|
|
13148
|
+
// src/shared/mastra-tool-meta.ts
|
|
13006
13149
|
const MASTRA_META_KEY$1 = "mastra";
|
|
13007
13150
|
const STRICT_META_KEY = "strict";
|
|
13008
13151
|
function withMastraToolStrictMeta(meta, strict) {
|
|
@@ -13022,8 +13165,7 @@ function getMastraToolStrictMeta(meta) {
|
|
|
13022
13165
|
const strict = mastraMeta[STRICT_META_KEY];
|
|
13023
13166
|
return typeof strict === "boolean" ? strict : void 0;
|
|
13024
13167
|
}
|
|
13025
|
-
|
|
13026
|
-
//#region src/shared/oauth-types.ts
|
|
13168
|
+
// src/shared/oauth-types.ts
|
|
13027
13169
|
/**
|
|
13028
13170
|
* Escapes backslashes and double quotes in a string for use in HTTP header quoted-string values.
|
|
13029
13171
|
*/
|
|
@@ -13082,8 +13224,7 @@ function extractBearerToken(authHeader) {
|
|
|
13082
13224
|
if (authHeader.slice(0, 7).toLowerCase() !== prefix) return void 0;
|
|
13083
13225
|
return authHeader.slice(7).trim() || void 0;
|
|
13084
13226
|
}
|
|
13085
|
-
|
|
13086
|
-
//#region src/shared/trace-context.ts
|
|
13227
|
+
// src/shared/trace-context.ts
|
|
13087
13228
|
/** `_meta` keys defined by the MCP specification for W3C trace propagation. */
|
|
13088
13229
|
const TRACEPARENT_META_KEY = "traceparent";
|
|
13089
13230
|
const TRACESTATE_META_KEY = "tracestate";
|
|
@@ -13227,8 +13368,7 @@ function takeServerTraceContext(result) {
|
|
|
13227
13368
|
} } : {}
|
|
13228
13369
|
};
|
|
13229
13370
|
}
|
|
13230
|
-
|
|
13231
|
-
//#region src/client/events/errors.ts
|
|
13371
|
+
// src/client/events/errors.ts
|
|
13232
13372
|
function eventsError(id, text, details = {}, cause) {
|
|
13233
13373
|
return new MastraError({
|
|
13234
13374
|
id,
|
|
@@ -13260,8 +13400,7 @@ function toTransientError(error, details) {
|
|
|
13260
13400
|
if (error instanceof MastraError) return error;
|
|
13261
13401
|
return eventsError("MCP_EVENTS_DELIVERY_INTERRUPTED", `Event delivery interrupted: ${error instanceof Error ? error.message : String(error)}`, details, error);
|
|
13262
13402
|
}
|
|
13263
|
-
|
|
13264
|
-
//#region src/client/events/mode.ts
|
|
13403
|
+
// src/client/events/mode.ts
|
|
13265
13404
|
/**
|
|
13266
13405
|
* Modes this client can drive, most preferred first. Webhook comes first, as the SEP recommends,
|
|
13267
13406
|
* but only when the caller configured a receiver.
|
|
@@ -13322,8 +13461,7 @@ const pollDriver = {
|
|
|
13322
13461
|
}
|
|
13323
13462
|
}
|
|
13324
13463
|
};
|
|
13325
|
-
|
|
13326
|
-
//#region src/client/events/push-driver.ts
|
|
13464
|
+
// src/client/events/push-driver.ts
|
|
13327
13465
|
/**
|
|
13328
13466
|
* Delivers a subscription over one `events/stream` request. The session ends when the stream
|
|
13329
13467
|
* closes, fails, goes silent for `heartbeatTimeoutMs`, or the server terminates it.
|
|
@@ -13404,8 +13542,7 @@ const pushDriver = {
|
|
|
13404
13542
|
}
|
|
13405
13543
|
}
|
|
13406
13544
|
};
|
|
13407
|
-
|
|
13408
|
-
//#region src/client/events/webhook-driver.ts
|
|
13545
|
+
// src/client/events/webhook-driver.ts
|
|
13409
13546
|
const DAY_MS = 864e5;
|
|
13410
13547
|
const MAX_MARGIN_MS = 6e4;
|
|
13411
13548
|
const MIN_REFRESH_DELAY_MS = 1e3;
|
|
@@ -13601,8 +13738,7 @@ var WebhookShare = class {
|
|
|
13601
13738
|
}
|
|
13602
13739
|
};
|
|
13603
13740
|
const sharesByPort = /* @__PURE__ */ new WeakMap();
|
|
13604
|
-
|
|
13605
|
-
//#region src/client/actions/events.ts
|
|
13741
|
+
// src/client/actions/events.ts
|
|
13606
13742
|
const DRIVERS = {
|
|
13607
13743
|
webhook: {
|
|
13608
13744
|
mode: "webhook",
|
|
@@ -13779,8 +13915,7 @@ var EventClientActions = class {
|
|
|
13779
13915
|
return events;
|
|
13780
13916
|
}
|
|
13781
13917
|
};
|
|
13782
|
-
|
|
13783
|
-
//#region src/client/actions/progress.ts
|
|
13918
|
+
// src/client/actions/progress.ts
|
|
13784
13919
|
/**
|
|
13785
13920
|
* Client-side progress actions for handling progress notifications from MCP servers.
|
|
13786
13921
|
*/
|
|
@@ -13799,8 +13934,7 @@ var ProgressClientActions = class {
|
|
|
13799
13934
|
this.client.setProgressNotificationHandler(handler);
|
|
13800
13935
|
}
|
|
13801
13936
|
};
|
|
13802
|
-
|
|
13803
|
-
//#region src/client/actions/prompt.ts
|
|
13937
|
+
// src/client/actions/prompt.ts
|
|
13804
13938
|
/**
|
|
13805
13939
|
* Client-side prompt actions for interacting with MCP server prompts.
|
|
13806
13940
|
*
|
|
@@ -13905,8 +14039,7 @@ var PromptClientActions = class {
|
|
|
13905
14039
|
await this.client.setPromptListChangedNotificationHandler(handler);
|
|
13906
14040
|
}
|
|
13907
14041
|
};
|
|
13908
|
-
|
|
13909
|
-
//#region src/client/actions/resource.ts
|
|
14042
|
+
// src/client/actions/resource.ts
|
|
13910
14043
|
/**
|
|
13911
14044
|
* Client-side resource actions for interacting with MCP server resources.
|
|
13912
14045
|
*
|
|
@@ -14073,8 +14206,7 @@ var ResourceClientActions = class {
|
|
|
14073
14206
|
await this.client.setResourceListChangedNotificationHandler(handler);
|
|
14074
14207
|
}
|
|
14075
14208
|
};
|
|
14076
|
-
|
|
14077
|
-
//#region src/client/error-utils.ts
|
|
14209
|
+
// src/client/error-utils.ts
|
|
14078
14210
|
/**
|
|
14079
14211
|
* Whether a failed MCP call is worth one transport reconnect and retry.
|
|
14080
14212
|
*
|
|
@@ -14155,8 +14287,7 @@ function getMCPDiscoveryErrorDetails(error) {
|
|
|
14155
14287
|
...code !== void 0 ? { code } : {}
|
|
14156
14288
|
};
|
|
14157
14289
|
}
|
|
14158
|
-
|
|
14159
|
-
//#region src/client/events/stream-router.ts
|
|
14290
|
+
// src/client/events/stream-router.ts
|
|
14160
14291
|
/**
|
|
14161
14292
|
* Routes push-stream notifications for one MCP server to the subscription that owns them.
|
|
14162
14293
|
*
|
|
@@ -14279,8 +14410,7 @@ var EventStreamRouter = class {
|
|
|
14279
14410
|
});
|
|
14280
14411
|
}
|
|
14281
14412
|
};
|
|
14282
|
-
|
|
14283
|
-
//#region src/client/events/subscription.ts
|
|
14413
|
+
// src/client/events/subscription.ts
|
|
14284
14414
|
const DEFAULT_DEDUP_WINDOW = 1e3;
|
|
14285
14415
|
const DEFAULT_MAX_BUFFERED_EVENTS = 1e3;
|
|
14286
14416
|
const DEFAULT_RETRY = {
|
|
@@ -14653,8 +14783,7 @@ var EventSubscription = class EventSubscription {
|
|
|
14653
14783
|
this.end();
|
|
14654
14784
|
}
|
|
14655
14785
|
};
|
|
14656
|
-
|
|
14657
|
-
//#region src/client/input-schema-meta-schema.ts
|
|
14786
|
+
// src/client/input-schema-meta-schema.ts
|
|
14658
14787
|
/**
|
|
14659
14788
|
* Structural JSON Schema meta-schema, used to check that a server-supplied tool input schema is
|
|
14660
14789
|
* shaped like a JSON Schema before it is handed to a model provider.
|
|
@@ -14973,8 +15102,7 @@ function getInputSchemaError(schema) {
|
|
|
14973
15102
|
}
|
|
14974
15103
|
return result.valid ? void 0 : result.errorMessage.split("; ").at(-1);
|
|
14975
15104
|
}
|
|
14976
|
-
|
|
14977
|
-
//#region src/client/url-policy.ts
|
|
15105
|
+
// src/client/url-policy.ts
|
|
14978
15106
|
/**
|
|
14979
15107
|
* Redirect status codes the manual redirect loop follows. Other 3xx statuses
|
|
14980
15108
|
* (e.g. 304) are not redirects and are returned to the caller as-is.
|
|
@@ -15139,78 +15267,8 @@ async function fetchFollowingAllowedRedirects(fetchImpl, url, init, allowedHosts
|
|
|
15139
15267
|
currentUrl = nextUrl;
|
|
15140
15268
|
}
|
|
15141
15269
|
}
|
|
15142
|
-
|
|
15143
|
-
//#region src/client/client.ts
|
|
15270
|
+
// src/client/client.ts
|
|
15144
15271
|
const DEFAULT_SERVER_CONNECT_TIMEOUT_MSEC = 3e3;
|
|
15145
|
-
/**
|
|
15146
|
-
* Bounds the work a validator can be asked to do for an untrusted tool catalogue.
|
|
15147
|
-
* Only schema-bearing keywords are walked, so deeply nested annotation data such as
|
|
15148
|
-
* `default` or `examples` does not count.
|
|
15149
|
-
*/
|
|
15150
|
-
function getJsonSchemaComplexityError(schema) {
|
|
15151
|
-
const seen = /* @__PURE__ */ new Set();
|
|
15152
|
-
let nodes = 0;
|
|
15153
|
-
const stack = [{
|
|
15154
|
-
value: schema,
|
|
15155
|
-
depth: 0
|
|
15156
|
-
}];
|
|
15157
|
-
const schemaMapKeywords = [
|
|
15158
|
-
"$defs",
|
|
15159
|
-
"definitions",
|
|
15160
|
-
"properties",
|
|
15161
|
-
"patternProperties",
|
|
15162
|
-
"dependentSchemas",
|
|
15163
|
-
"dependencies"
|
|
15164
|
-
];
|
|
15165
|
-
const schemaArrayKeywords = [
|
|
15166
|
-
"prefixItems",
|
|
15167
|
-
"allOf",
|
|
15168
|
-
"anyOf",
|
|
15169
|
-
"oneOf",
|
|
15170
|
-
"items"
|
|
15171
|
-
];
|
|
15172
|
-
const schemaKeywords = [
|
|
15173
|
-
"additionalProperties",
|
|
15174
|
-
"unevaluatedProperties",
|
|
15175
|
-
"additionalItems",
|
|
15176
|
-
"unevaluatedItems",
|
|
15177
|
-
"items",
|
|
15178
|
-
"contains",
|
|
15179
|
-
"propertyNames",
|
|
15180
|
-
"not",
|
|
15181
|
-
"if",
|
|
15182
|
-
"then",
|
|
15183
|
-
"else",
|
|
15184
|
-
"contentSchema"
|
|
15185
|
-
];
|
|
15186
|
-
while (stack.length > 0) {
|
|
15187
|
-
const { value, depth } = stack.pop();
|
|
15188
|
-
if (value === null || typeof value !== "object" || Array.isArray(value) || seen.has(value)) continue;
|
|
15189
|
-
seen.add(value);
|
|
15190
|
-
nodes += 1;
|
|
15191
|
-
if (depth > 128) return `JSON Schema exceeds the maximum depth of 128`;
|
|
15192
|
-
if (nodes > 1e4) return `JSON Schema exceeds the maximum node count of ${MAX_JSON_SCHEMA_NODES}`;
|
|
15193
|
-
const record = value;
|
|
15194
|
-
for (const keyword of schemaMapKeywords) {
|
|
15195
|
-
const schemas = record[keyword];
|
|
15196
|
-
if (schemas && typeof schemas === "object" && !Array.isArray(schemas)) for (const child of Object.values(schemas)) stack.push({
|
|
15197
|
-
value: child,
|
|
15198
|
-
depth: depth + 1
|
|
15199
|
-
});
|
|
15200
|
-
}
|
|
15201
|
-
for (const keyword of schemaArrayKeywords) {
|
|
15202
|
-
const schemas = record[keyword];
|
|
15203
|
-
if (Array.isArray(schemas)) for (const child of schemas) stack.push({
|
|
15204
|
-
value: child,
|
|
15205
|
-
depth: depth + 1
|
|
15206
|
-
});
|
|
15207
|
-
}
|
|
15208
|
-
for (const keyword of schemaKeywords) if (record[keyword] !== void 0) stack.push({
|
|
15209
|
-
value: record[keyword],
|
|
15210
|
-
depth: depth + 1
|
|
15211
|
-
});
|
|
15212
|
-
}
|
|
15213
|
-
}
|
|
15214
15272
|
const SUPPORTED_DIALECTS = /* @__PURE__ */ new Set([
|
|
15215
15273
|
JSON_SCHEMA_2020_12,
|
|
15216
15274
|
`${JSON_SCHEMA_2020_12}#`,
|
|
@@ -15416,6 +15474,7 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
15416
15474
|
name;
|
|
15417
15475
|
client;
|
|
15418
15476
|
timeout;
|
|
15477
|
+
processHooks;
|
|
15419
15478
|
logHandler;
|
|
15420
15479
|
serverLogLevel;
|
|
15421
15480
|
enableProgressTracking;
|
|
@@ -15452,12 +15511,13 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
15452
15511
|
/**
|
|
15453
15512
|
* @internal
|
|
15454
15513
|
*/
|
|
15455
|
-
constructor({ name, version = "1.0.0", clientInfo, server, timeout = DEFAULT_REQUEST_TIMEOUT_MSEC, webhook }) {
|
|
15514
|
+
constructor({ name, version = "1.0.0", clientInfo, server, timeout = DEFAULT_REQUEST_TIMEOUT_MSEC, registerProcessHooks = true, webhook }) {
|
|
15456
15515
|
super({ name: "MastraMCPClient" });
|
|
15457
15516
|
this.webhook = webhook;
|
|
15458
15517
|
loadInputSchemaMetaValidator();
|
|
15459
15518
|
this.name = name;
|
|
15460
15519
|
this.timeout = timeout;
|
|
15520
|
+
this.processHooks = registerProcessHooks;
|
|
15461
15521
|
this.logHandler = server.logger;
|
|
15462
15522
|
this.serverLogLevel = server.enableServerLogs ?? true ? server.serverLogLevel ?? DEFAULT_SERVER_LOG_LEVEL : void 0;
|
|
15463
15523
|
this.serverConfig = server;
|
|
@@ -15800,7 +15860,7 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
15800
15860
|
reject(e);
|
|
15801
15861
|
}
|
|
15802
15862
|
});
|
|
15803
|
-
this.registerProcessHooks();
|
|
15863
|
+
if (this.processHooks) this.registerProcessHooks();
|
|
15804
15864
|
return this.isConnected;
|
|
15805
15865
|
}
|
|
15806
15866
|
/**
|
|
@@ -16343,7 +16403,7 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
16343
16403
|
buildToolFromListEntry(tool, serverMeta) {
|
|
16344
16404
|
const rawInputSchema = tool.inputSchema;
|
|
16345
16405
|
const inputSchema = rawInputSchema && typeof rawInputSchema === "object" && "jsonSchema" in rawInputSchema ? rawInputSchema.jsonSchema : rawInputSchema;
|
|
16346
|
-
const inputSchemaError =
|
|
16406
|
+
const inputSchemaError = jsonSchemaComplexity(inputSchema).error ?? getInputSchemaError(inputSchema);
|
|
16347
16407
|
if (inputSchemaError) {
|
|
16348
16408
|
const details = {
|
|
16349
16409
|
serverName: this.name,
|
|
@@ -16385,7 +16445,7 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
16385
16445
|
...annotations ? { annotations } : {}
|
|
16386
16446
|
} } : {};
|
|
16387
16447
|
const outputSchema = tool.outputSchema ? withDefaultDialect("jsonSchema" in tool.outputSchema ? tool.outputSchema.jsonSchema : tool.outputSchema) : void 0;
|
|
16388
|
-
const outputSchemaComplexityError = outputSchema ?
|
|
16448
|
+
const outputSchemaComplexityError = outputSchema ? jsonSchemaComplexity(outputSchema).error : void 0;
|
|
16389
16449
|
let outputValidationSchema;
|
|
16390
16450
|
const getOutputValidationSchema = async () => {
|
|
16391
16451
|
if (!outputSchema) return void 0;
|
|
@@ -16532,8 +16592,7 @@ var InternalMastraMCPClient = class extends MastraBase {
|
|
|
16532
16592
|
};
|
|
16533
16593
|
}
|
|
16534
16594
|
};
|
|
16535
|
-
|
|
16536
|
-
//#region src/client/events/webhook-receiver.ts
|
|
16595
|
+
// src/client/events/webhook-receiver.ts
|
|
16537
16596
|
function respond(status, body) {
|
|
16538
16597
|
return body ? new Response(JSON.stringify(body), {
|
|
16539
16598
|
status,
|
|
@@ -16641,8 +16700,7 @@ async function readBody(request, limit) {
|
|
|
16641
16700
|
}
|
|
16642
16701
|
return body;
|
|
16643
16702
|
}
|
|
16644
|
-
|
|
16645
|
-
//#region src/client/oauth-callback-server.ts
|
|
16703
|
+
// src/client/oauth-callback-server.ts
|
|
16646
16704
|
/**
|
|
16647
16705
|
* Loopback OAuth Callback Server for MCP Client
|
|
16648
16706
|
*
|
|
@@ -16854,8 +16912,7 @@ async function createOAuthCallbackServer(options) {
|
|
|
16854
16912
|
}
|
|
16855
16913
|
};
|
|
16856
16914
|
}
|
|
16857
|
-
|
|
16858
|
-
//#region src/client/oauth-provider.ts
|
|
16915
|
+
// src/client/oauth-provider.ts
|
|
16859
16916
|
/**
|
|
16860
16917
|
* OAuth Client Provider Implementation for MCP Client
|
|
16861
16918
|
*
|
|
@@ -17204,8 +17261,7 @@ function createSimpleTokenProvider(accessToken, options) {
|
|
|
17204
17261
|
storage
|
|
17205
17262
|
});
|
|
17206
17263
|
}
|
|
17207
|
-
|
|
17208
|
-
//#region src/client/server-proxy.ts
|
|
17264
|
+
// src/client/server-proxy.ts
|
|
17209
17265
|
/**
|
|
17210
17266
|
* Wraps a single MCPClient server connection as an `MCPServerBase` so external
|
|
17211
17267
|
* (non-Mastra) MCP servers connected through MCPClient can be registered in Mastra's
|
|
@@ -17324,9 +17380,12 @@ var MCPClientServerProxy = class extends MCPServerBase {
|
|
|
17324
17380
|
};
|
|
17325
17381
|
}
|
|
17326
17382
|
};
|
|
17327
|
-
|
|
17328
|
-
//#region src/client/configuration.ts
|
|
17383
|
+
// src/client/configuration.ts
|
|
17329
17384
|
const mcpClientInstances = /* @__PURE__ */ new Map();
|
|
17385
|
+
/** Reads the shared cache without promising the snapshot shape it was created with. */
|
|
17386
|
+
function cachedClient(id) {
|
|
17387
|
+
return mcpClientInstances.get(id);
|
|
17388
|
+
}
|
|
17330
17389
|
const TOOL_DISCOVERY_MAX_ATTEMPTS = 2;
|
|
17331
17390
|
const LOOPBACK_IPV4 = /^127\.(?:\d{1,3})\.(?:\d{1,3})\.(?:\d{1,3})$/;
|
|
17332
17391
|
function isLoopbackHostname(hostname) {
|
|
@@ -17359,10 +17418,12 @@ function isLoopbackHostname(hostname) {
|
|
|
17359
17418
|
* if packaged docs are unavailable.
|
|
17360
17419
|
*/
|
|
17361
17420
|
var MCPClient = class extends MastraBase {
|
|
17421
|
+
typegen;
|
|
17362
17422
|
serverConfigs = {};
|
|
17363
17423
|
id;
|
|
17364
17424
|
defaultTimeout;
|
|
17365
17425
|
defaultClientInfo;
|
|
17426
|
+
registerProcessHooks;
|
|
17366
17427
|
webhook;
|
|
17367
17428
|
mcpClientsById = /* @__PURE__ */ new Map();
|
|
17368
17429
|
disconnectPromise = null;
|
|
@@ -17407,6 +17468,7 @@ var MCPClient = class extends MastraBase {
|
|
|
17407
17468
|
super({ name: "MCPClient" });
|
|
17408
17469
|
this.defaultTimeout = args.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
17409
17470
|
this.defaultClientInfo = args.clientInfo && { ...args.clientInfo };
|
|
17471
|
+
this.registerProcessHooks = args.registerProcessHooks ?? true;
|
|
17410
17472
|
this.serverConfigs = args.servers;
|
|
17411
17473
|
this.webhook = args.webhook && {
|
|
17412
17474
|
options: { ...args.webhook },
|
|
@@ -17415,16 +17477,13 @@ var MCPClient = class extends MastraBase {
|
|
|
17415
17477
|
this.id = args.id ?? this.makeId();
|
|
17416
17478
|
if (args.id) {
|
|
17417
17479
|
this.id = args.id;
|
|
17418
|
-
const cached =
|
|
17419
|
-
if (cached && (!equal(cached.serverConfigs, args.servers) || !equal(cached.defaultClientInfo, args.clientInfo))) {
|
|
17420
|
-
|
|
17421
|
-
|
|
17422
|
-
existingInstance.disconnect();
|
|
17423
|
-
mcpClientInstances.delete(this.id);
|
|
17424
|
-
}
|
|
17480
|
+
const cached = cachedClient(this.id);
|
|
17481
|
+
if (cached && (!equal(cached.serverConfigs, args.servers) || !equal(cached.defaultClientInfo, args.clientInfo) || cached.registerProcessHooks !== this.registerProcessHooks || cached.typegen?.outFile !== args.typegen?.outFile)) {
|
|
17482
|
+
cached.disconnect();
|
|
17483
|
+
mcpClientInstances.delete(this.id);
|
|
17425
17484
|
}
|
|
17426
17485
|
} else this.id = this.makeId();
|
|
17427
|
-
const existingInstance =
|
|
17486
|
+
const existingInstance = cachedClient(this.id);
|
|
17428
17487
|
if (existingInstance) {
|
|
17429
17488
|
if (!args.id) throw new Error(`MCPClient was initialized multiple times with the same configuration options.
|
|
17430
17489
|
|
|
@@ -17437,6 +17496,11 @@ To fix this you have three different options:
|
|
|
17437
17496
|
`);
|
|
17438
17497
|
return existingInstance;
|
|
17439
17498
|
}
|
|
17499
|
+
const { typegen } = args;
|
|
17500
|
+
if (typegen !== void 0) {
|
|
17501
|
+
if (!typegen || typeof typegen.outFile !== "string" || !typegen.outFile.trim() || typegen.outFile.includes("\0")) throw new Error("typegen.outFile must be a nonempty file path");
|
|
17502
|
+
this.typegen = Object.freeze({ outFile: typegen.outFile });
|
|
17503
|
+
}
|
|
17440
17504
|
mcpClientInstances.set(this.id, this);
|
|
17441
17505
|
this.addToInstanceCache();
|
|
17442
17506
|
return this;
|
|
@@ -17900,9 +17964,10 @@ onListChanged: async (serverName, handler) => {
|
|
|
17900
17964
|
if (!mcpClientInstances.has(this.id)) mcpClientInstances.set(this.id, this);
|
|
17901
17965
|
}
|
|
17902
17966
|
makeId() {
|
|
17903
|
-
const text = JSON.stringify(this.defaultClientInfo === void 0 ? this.serverConfigs : {
|
|
17967
|
+
const text = JSON.stringify(this.defaultClientInfo === void 0 && this.registerProcessHooks ? this.serverConfigs : {
|
|
17904
17968
|
servers: this.serverConfigs,
|
|
17905
|
-
clientInfo: this.defaultClientInfo
|
|
17969
|
+
...this.defaultClientInfo === void 0 ? {} : { clientInfo: this.defaultClientInfo },
|
|
17970
|
+
...this.registerProcessHooks ? {} : { registerProcessHooks: false }
|
|
17906
17971
|
}).normalize("NFKC");
|
|
17907
17972
|
return createHash("sha256").update("MCPClient").update(text).digest("hex");
|
|
17908
17973
|
}
|
|
@@ -18143,24 +18208,6 @@ onListChanged: async (serverName, handler) => {
|
|
|
18143
18208
|
async listTools() {
|
|
18144
18209
|
return (await this.listToolsWithErrors()).tools;
|
|
18145
18210
|
}
|
|
18146
|
-
/**
|
|
18147
|
-
* Retrieves all tools from all configured servers with namespaced names,
|
|
18148
|
-
* along with any per-server errors.
|
|
18149
|
-
*
|
|
18150
|
-
* Like listTools(), but also returns errors for servers that failed to connect
|
|
18151
|
-
* or list tools. This allows callers to report specific failure reasons per server.
|
|
18152
|
-
*
|
|
18153
|
-
* @returns Object with successful `tools`, legacy string `errors`, and structured `errorDetails`.
|
|
18154
|
-
* Transient connection failures are retried once after reconnecting the affected server.
|
|
18155
|
-
*
|
|
18156
|
-
* @example
|
|
18157
|
-
* ```typescript
|
|
18158
|
-
* const { tools, errors, errorDetails } = await mcp.listToolsWithErrors();
|
|
18159
|
-
* for (const [name, err] of Object.entries(errors)) {
|
|
18160
|
-
* console.error(`Server ${name} failed: ${err}`, errorDetails[name]);
|
|
18161
|
-
* }
|
|
18162
|
-
* ```
|
|
18163
|
-
*/
|
|
18164
18211
|
async listToolsWithErrors(options) {
|
|
18165
18212
|
this.addToInstanceCache();
|
|
18166
18213
|
const connectedTools = {};
|
|
@@ -18216,23 +18263,6 @@ onListChanged: async (serverName, handler) => {
|
|
|
18216
18263
|
async listToolsets() {
|
|
18217
18264
|
return (await this.listToolsetsWithErrors()).toolsets;
|
|
18218
18265
|
}
|
|
18219
|
-
/**
|
|
18220
|
-
* Returns toolsets organized by server name, along with any per-server errors.
|
|
18221
|
-
*
|
|
18222
|
-
* Like listToolsets(), but also returns errors for servers that failed to connect
|
|
18223
|
-
* or list tools. This allows callers to report specific failure reasons per server.
|
|
18224
|
-
*
|
|
18225
|
-
* @returns Object with successful `toolsets`, legacy string `errors`, and structured `errorDetails`.
|
|
18226
|
-
* Transient connection failures are retried once after reconnecting the affected server.
|
|
18227
|
-
*
|
|
18228
|
-
* @example
|
|
18229
|
-
* ```typescript
|
|
18230
|
-
* const { toolsets, errors, errorDetails } = await mcp.listToolsetsWithErrors();
|
|
18231
|
-
* for (const [name, err] of Object.entries(errors)) {
|
|
18232
|
-
* console.error(`Server ${name} failed: ${err}`, errorDetails[name]);
|
|
18233
|
-
* }
|
|
18234
|
-
* ```
|
|
18235
|
-
*/
|
|
18236
18266
|
async listToolsetsWithErrors(options) {
|
|
18237
18267
|
this.addToInstanceCache();
|
|
18238
18268
|
const connectedToolsets = {};
|
|
@@ -18563,6 +18593,7 @@ onListChanged: async (serverName, handler) => {
|
|
|
18563
18593
|
name,
|
|
18564
18594
|
server: config,
|
|
18565
18595
|
timeout: config.timeout ?? this.defaultTimeout,
|
|
18596
|
+
registerProcessHooks: this.registerProcessHooks,
|
|
18566
18597
|
clientInfo: {
|
|
18567
18598
|
name: config.clientInfo?.name ?? this.defaultClientInfo?.name,
|
|
18568
18599
|
version: config.clientInfo?.version ?? this.defaultClientInfo?.version
|
|
@@ -18619,8 +18650,7 @@ onListChanged: async (serverName, handler) => {
|
|
|
18619
18650
|
return {};
|
|
18620
18651
|
}
|
|
18621
18652
|
};
|
|
18622
|
-
|
|
18623
|
-
//#region src/server/actions.ts
|
|
18653
|
+
// src/server/actions.ts
|
|
18624
18654
|
/** Runtime tool catalogue mutations. Every change is published to listening clients. */
|
|
18625
18655
|
var ServerToolActions = class {
|
|
18626
18656
|
deps;
|
|
@@ -18664,8 +18694,7 @@ var ServerPromptActions = class {
|
|
|
18664
18694
|
this.deps.getNotifier()?.promptsChanged();
|
|
18665
18695
|
}
|
|
18666
18696
|
};
|
|
18667
|
-
|
|
18668
|
-
//#region src/server/events/actions.ts
|
|
18697
|
+
// src/server/events/actions.ts
|
|
18669
18698
|
/**
|
|
18670
18699
|
* `server.events`: publishes occurrences of the event types configured in `MCPServer`'s `events`.
|
|
18671
18700
|
*
|
|
@@ -18704,8 +18733,7 @@ var ServerEventActions = class {
|
|
|
18704
18733
|
return this.describe();
|
|
18705
18734
|
}
|
|
18706
18735
|
};
|
|
18707
|
-
|
|
18708
|
-
//#region src/server/request.ts
|
|
18736
|
+
// src/server/request.ts
|
|
18709
18737
|
const unavailable = (feature, replacement) => () => Promise.reject(/* @__PURE__ */ new Error(`${feature} is not available on a 2026-07-28 server; ${replacement}`));
|
|
18710
18738
|
/**
|
|
18711
18739
|
* The `context.mcp` a 2026-07-28 request hands to tools: the 1.x shape, with the
|
|
@@ -18818,8 +18846,7 @@ function readContinuation(ctx, requestContext, expected) {
|
|
|
18818
18846
|
resumeData: answer.action === "accept" ? answer.content ?? {} : void 0
|
|
18819
18847
|
};
|
|
18820
18848
|
}
|
|
18821
|
-
|
|
18822
|
-
//#region src/server/events/ring-buffer.ts
|
|
18849
|
+
// src/server/events/ring-buffer.ts
|
|
18823
18850
|
/**
|
|
18824
18851
|
* Bounded, in-memory history of one event type's emitted occurrences.
|
|
18825
18852
|
*
|
|
@@ -18920,8 +18947,7 @@ var EventRingBuffer = class {
|
|
|
18920
18947
|
return seq <= this.seq ? seq : void 0;
|
|
18921
18948
|
}
|
|
18922
18949
|
};
|
|
18923
|
-
|
|
18924
|
-
//#region src/server/events/registry.ts
|
|
18950
|
+
// src/server/events/registry.ts
|
|
18925
18951
|
const DEFAULT_BUFFER_SIZE = 1e3;
|
|
18926
18952
|
/**
|
|
18927
18953
|
* Delivery modes advertised for a definition. They are fixed at construction because clients
|
|
@@ -19066,8 +19092,7 @@ function toDescriptor(event, convert) {
|
|
|
19066
19092
|
if (payloadSchema) descriptor.payloadSchema = payloadSchema;
|
|
19067
19093
|
return descriptor;
|
|
19068
19094
|
}
|
|
19069
|
-
|
|
19070
|
-
//#region src/server/events/stream.ts
|
|
19095
|
+
// src/server/events/stream.ts
|
|
19071
19096
|
/**
|
|
19072
19097
|
* Server side of one push subscription (`events/stream`).
|
|
19073
19098
|
*
|
|
@@ -19178,8 +19203,7 @@ var EventStream = class {
|
|
|
19178
19203
|
}, this.options.heartbeatIntervalMs);
|
|
19179
19204
|
}
|
|
19180
19205
|
};
|
|
19181
|
-
|
|
19182
|
-
//#region src/server/events/handlers.ts
|
|
19206
|
+
// src/server/events/handlers.ts
|
|
19183
19207
|
const DEFAULT_MAX_EVENTS = 100;
|
|
19184
19208
|
const DEFAULT_LIST_PAGE_SIZE = 100;
|
|
19185
19209
|
/**
|
|
@@ -19410,8 +19434,7 @@ function decodeListCursor(cursor) {
|
|
|
19410
19434
|
} catch {}
|
|
19411
19435
|
throw new ProtocolError$1(ProtocolErrorCode$1.InvalidParams, "Invalid events/list cursor");
|
|
19412
19436
|
}
|
|
19413
|
-
|
|
19414
|
-
//#region src/server/events/inspector.ts
|
|
19437
|
+
// src/server/events/inspector.ts
|
|
19415
19438
|
/** Prefix of the `eventId` of occurrences sent with the inspector's `emit`. */
|
|
19416
19439
|
const TEST_EMIT_EVENT_ID_PREFIX = "mastra-test-";
|
|
19417
19440
|
let localStreamIds = 0;
|
|
@@ -19528,8 +19551,7 @@ function protocolErrorId(code) {
|
|
|
19528
19551
|
default: return;
|
|
19529
19552
|
}
|
|
19530
19553
|
}
|
|
19531
|
-
|
|
19532
|
-
//#region src/server/events/webhook-store.ts
|
|
19554
|
+
// src/server/events/webhook-store.ts
|
|
19533
19555
|
/**
|
|
19534
19556
|
* Default {@link WebhookSubscriptionStore}: a process-local map.
|
|
19535
19557
|
*
|
|
@@ -19550,8 +19572,7 @@ var InMemoryWebhookSubscriptionStore = class {
|
|
|
19550
19572
|
return [...this.records.values()].filter((record) => record.name === name);
|
|
19551
19573
|
}
|
|
19552
19574
|
};
|
|
19553
|
-
|
|
19554
|
-
//#region src/server/events/webhook-transport.ts
|
|
19575
|
+
// src/server/events/webhook-transport.ts
|
|
19555
19576
|
/** Largest response body read from a callback endpoint. Enough for a verification echo. */
|
|
19556
19577
|
const MAX_RESPONSE_BYTES = 4096;
|
|
19557
19578
|
/** Maps a non-2xx status to its failure category. */
|
|
@@ -19626,8 +19647,7 @@ const nodeWebhookTransport = (request) => new Promise((resolve) => {
|
|
|
19626
19647
|
});
|
|
19627
19648
|
req.end(request.body);
|
|
19628
19649
|
});
|
|
19629
|
-
|
|
19630
|
-
//#region src/server/events/webhook-dispatcher.ts
|
|
19650
|
+
// src/server/events/webhook-dispatcher.ts
|
|
19631
19651
|
const MINUTE = 6e4;
|
|
19632
19652
|
const HOUR = 60 * MINUTE;
|
|
19633
19653
|
const MAX_TIMER_MS = 2147483647;
|
|
@@ -20184,8 +20204,7 @@ function echoes(body, challenge) {
|
|
|
20184
20204
|
const b = Buffer.from(challenge);
|
|
20185
20205
|
return a.length === b.length && timingSafeEqual(a, b);
|
|
20186
20206
|
}
|
|
20187
|
-
|
|
20188
|
-
//#region src/server/server.ts
|
|
20207
|
+
// src/server/server.ts
|
|
20189
20208
|
const EMPTY_OBJECT_SCHEMA = {
|
|
20190
20209
|
type: "object",
|
|
20191
20210
|
properties: {}
|
|
@@ -20243,6 +20262,7 @@ var MCPServer = class extends MCPServerBase {
|
|
|
20243
20262
|
eventsOptions;
|
|
20244
20263
|
eventsInspector;
|
|
20245
20264
|
webhooks;
|
|
20265
|
+
legacy;
|
|
20246
20266
|
httpHandler;
|
|
20247
20267
|
nodeHandler;
|
|
20248
20268
|
stdioHandle;
|
|
@@ -20258,6 +20278,7 @@ var MCPServer = class extends MCPServerBase {
|
|
|
20258
20278
|
this.loadAppResources(config.appResources);
|
|
20259
20279
|
this.requestStateCodec = this.createRequestStateCodec(config.requestState);
|
|
20260
20280
|
this.eventsOptions = config.eventsOptions ?? {};
|
|
20281
|
+
this.legacy = config.legacy ?? "reject";
|
|
20261
20282
|
const webhook = this.eventsOptions.webhook;
|
|
20262
20283
|
this.eventRegistry = new ServerEventRegistry(config.events, { webhook: webhook !== void 0 });
|
|
20263
20284
|
if (webhook && this.eventRegistry.size > 0) this.webhooks = new WebhookDispatcher({
|
|
@@ -20787,7 +20808,7 @@ var MCPServer = class extends MCPServerBase {
|
|
|
20787
20808
|
resumeSchema: execution.resumeSchema
|
|
20788
20809
|
});
|
|
20789
20810
|
}
|
|
20790
|
-
const result = this.toCallToolResult(name, tool, execution.output);
|
|
20811
|
+
const result = server.projectCallToolResult(this.toCallToolResult(name, tool, execution.output), this.toolInfo(name, tool).outputSchema);
|
|
20791
20812
|
this.logger.info(`Tool '${name}' finished in ${Date.now() - startedAt}ms.`);
|
|
20792
20813
|
return result;
|
|
20793
20814
|
} catch (error) {
|
|
@@ -21053,7 +21074,7 @@ var MCPServer = class extends MCPServerBase {
|
|
|
21053
21074
|
getNodeHandler() {
|
|
21054
21075
|
if (!this.nodeHandler) {
|
|
21055
21076
|
this.httpHandler = createMcpHandler(() => this.createServerInstance(), {
|
|
21056
|
-
legacy:
|
|
21077
|
+
legacy: this.legacy,
|
|
21057
21078
|
onerror: (error) => this.logger.error("MCP handler error", { error: error.toString() })
|
|
21058
21079
|
});
|
|
21059
21080
|
this.nodeHandler = toNodeHandler(this.httpHandler, { onerror: (error) => this.logger.error("MCP Node handler adapter error", { error: error.toString() }) });
|
|
@@ -21073,7 +21094,8 @@ var MCPServer = class extends MCPServerBase {
|
|
|
21073
21094
|
}
|
|
21074
21095
|
/**
|
|
21075
21096
|
* Handles one Streamable HTTP request at `httpPath`. Every request is
|
|
21076
|
-
* self-contained; requests without a 2026-07-28 envelope are rejected
|
|
21097
|
+
* self-contained; requests without a 2026-07-28 envelope are rejected unless
|
|
21098
|
+
* `legacy: 'stateless'` is configured.
|
|
21077
21099
|
*/
|
|
21078
21100
|
async startHTTP({ url, httpPath, req, res, options }) {
|
|
21079
21101
|
if (url.pathname !== httpPath) {
|
|
@@ -21297,12 +21319,10 @@ function normalizeUiMeta(meta) {
|
|
|
21297
21319
|
[RESOURCE_URI_META_KEY]: resourceUri
|
|
21298
21320
|
};
|
|
21299
21321
|
}
|
|
21300
|
-
|
|
21301
|
-
//#region src/server/types.ts
|
|
21322
|
+
// src/server/types.ts
|
|
21302
21323
|
/** The only protocol revision `@mastra/mcp` serves. */
|
|
21303
21324
|
const MCP_PROTOCOL_VERSION = "2026-07-28";
|
|
21304
|
-
|
|
21305
|
-
//#region src/server/oauth-middleware.ts
|
|
21325
|
+
// src/server/oauth-middleware.ts
|
|
21306
21326
|
/**
|
|
21307
21327
|
* Creates an OAuth middleware function for protecting MCP server endpoints.
|
|
21308
21328
|
*
|
|
@@ -21547,8 +21567,7 @@ function createIntrospectionValidator(introspectionEndpoint, clientCredentials)
|
|
|
21547
21567
|
}
|
|
21548
21568
|
};
|
|
21549
21569
|
}
|
|
21550
|
-
|
|
21551
|
-
//#region src/server/events/define-event.ts
|
|
21570
|
+
// src/server/events/define-event.ts
|
|
21552
21571
|
/**
|
|
21553
21572
|
* Declares an event type for `MCPServer`'s `events` option. An identity helper: it types `match`
|
|
21554
21573
|
* and `poll` from `inputSchema` and `payloadSchema`.
|
|
@@ -21568,8 +21587,7 @@ function createIntrospectionValidator(introspectionEndpoint, clientCredentials)
|
|
|
21568
21587
|
function defineEvent(definition) {
|
|
21569
21588
|
return definition;
|
|
21570
21589
|
}
|
|
21571
|
-
|
|
21572
|
-
//#region src/integrations/events-cursor-store.ts
|
|
21590
|
+
// src/integrations/events-cursor-store.ts
|
|
21573
21591
|
/**
|
|
21574
21592
|
* Process-local {@link MCPEventCursorStore}. Cursors survive a provider restart within the same
|
|
21575
21593
|
* process, not a process restart.
|
|
@@ -21588,8 +21606,7 @@ var InMemoryMCPEventCursorStore = class {
|
|
|
21588
21606
|
this.#cursors.delete(key);
|
|
21589
21607
|
}
|
|
21590
21608
|
};
|
|
21591
|
-
|
|
21592
|
-
//#region src/integrations/events-utils.ts
|
|
21609
|
+
// src/integrations/events-utils.ts
|
|
21593
21610
|
function canonicalize(value) {
|
|
21594
21611
|
if (Array.isArray(value)) return value.map(canonicalize);
|
|
21595
21612
|
if (value !== null && typeof value === "object") {
|
|
@@ -21632,8 +21649,7 @@ function formatUntrustedEvent({ header, data, footer }) {
|
|
|
21632
21649
|
...footer ? [footer] : []
|
|
21633
21650
|
].join("\n");
|
|
21634
21651
|
}
|
|
21635
|
-
|
|
21636
|
-
//#region src/integrations/events-tools.ts
|
|
21652
|
+
// src/integrations/events-tools.ts
|
|
21637
21653
|
function decodeArguments(value) {
|
|
21638
21654
|
try {
|
|
21639
21655
|
const parsed = JSON.parse(value);
|
|
@@ -21741,8 +21757,7 @@ function createMCPEventsTools({ provider, client, servers }) {
|
|
|
21741
21757
|
})
|
|
21742
21758
|
};
|
|
21743
21759
|
}
|
|
21744
|
-
|
|
21745
|
-
//#region src/integrations/events-signals.ts
|
|
21760
|
+
// src/integrations/events-signals.ts
|
|
21746
21761
|
const GAP_NOTE = "Some events may have been skipped (gap); re-fetch authoritative state with tools if it matters.";
|
|
21747
21762
|
/**
|
|
21748
21763
|
* Delivers MCP Events (SEP-3415) occurrences into agent threads as notification signals.
|
|
@@ -21995,7 +22010,6 @@ var MCPEventsSignalProvider = class MCPEventsSignalProvider extends SignalProvid
|
|
|
21995
22010
|
else console.warn(`[${this.id}] ${info.key}:`, error);
|
|
21996
22011
|
}
|
|
21997
22012
|
};
|
|
21998
|
-
//#endregion
|
|
21999
22013
|
export { InMemoryMCPEventCursorStore, InMemoryOAuthStorage, InMemoryWebhookSubscriptionStore, InternalMastraMCPClient, MCPClient, MCPClientServerProxy, MCPEventsSignalProvider, MCPOAuthClientProvider, MCPServer, MCP_CALL_TOOL_CONTENT, MCP_CALL_TOOL_META, MCP_CLIENT_PROTOCOL_VERSION, MCP_PROTOCOL_VERSION, ServerEventActions, ServerPromptActions, ServerResourceActions, ServerToolActions, UnauthorizedError, auth, buildDiscoveryUrls, createIntrospectionValidator, createOAuthCallbackServer, createOAuthMiddleware, createSimpleTokenProvider, createStaticTokenValidator, defineEvent, discoverAuthorizationServerMetadata, discoverOAuthMetadata, discoverOAuthProtectedResourceMetadata, exchangeAuthorization, extractBearerToken, extractResourceMetadataUrl, generateProtectedResourceMetadata, generateWWWAuthenticateHeader, getCallbackUrlCandidates, getMcpCallToolContent, getMcpCallToolMeta, parseErrorResponse, refreshAuthorization, selectResourceURL, startAuthorization, traceContextFromMeta, traceContextToMeta };
|
|
22000
22014
|
|
|
22001
22015
|
//# sourceMappingURL=index.js.map
|