@mastra/mcp 2.1.0 → 2.1.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +107 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +107 -10
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/shared/json-schema-dialect.d.ts +19 -0
- package/dist/shared/json-schema-dialect.d.ts.map +1 -0
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAShE,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAG3B,kBAAkB,EAMnB,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAShE,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAG3B,kBAAkB,EAMnB,MAAM,8BAA8B,CAAC;AAOtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAA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E,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAgB/D;IAED;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAwN9B,OAAO,CAAC,mBAAmB;CAQ5B"}
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -22237,6 +22237,90 @@ function trimStartOfStream() {
|
|
|
22237
22237
|
}
|
|
22238
22238
|
require_json_schema_traverse();
|
|
22239
22239
|
//#endregion
|
|
22240
|
+
//#region src/shared/json-schema-dialect.ts
|
|
22241
|
+
const JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
22242
|
+
const JSON_SCHEMA_2019_09 = /^https?:\/\/json-schema\.org\/draft\/2019-09\/schema#?$/;
|
|
22243
|
+
/** Keywords whose value is a subschema (`items` may also be an array of subschemas). */
|
|
22244
|
+
const SCHEMA_KEYWORDS = /* @__PURE__ */ new Set([
|
|
22245
|
+
"items",
|
|
22246
|
+
"additionalItems",
|
|
22247
|
+
"contains",
|
|
22248
|
+
"additionalProperties",
|
|
22249
|
+
"propertyNames",
|
|
22250
|
+
"unevaluatedItems",
|
|
22251
|
+
"unevaluatedProperties",
|
|
22252
|
+
"if",
|
|
22253
|
+
"then",
|
|
22254
|
+
"else",
|
|
22255
|
+
"not"
|
|
22256
|
+
]);
|
|
22257
|
+
/** Keywords whose value is an array of subschemas. */
|
|
22258
|
+
const SCHEMA_ARRAY_KEYWORDS = /* @__PURE__ */ new Set([
|
|
22259
|
+
"allOf",
|
|
22260
|
+
"anyOf",
|
|
22261
|
+
"oneOf"
|
|
22262
|
+
]);
|
|
22263
|
+
/** Keywords whose values map arbitrary names to subschemas. */
|
|
22264
|
+
const SCHEMA_MAP_KEYWORDS = /* @__PURE__ */ new Set([
|
|
22265
|
+
"properties",
|
|
22266
|
+
"patternProperties",
|
|
22267
|
+
"$defs",
|
|
22268
|
+
"definitions",
|
|
22269
|
+
"dependentSchemas"
|
|
22270
|
+
]);
|
|
22271
|
+
const MAX_JSON_SCHEMA_NODES = 1e4;
|
|
22272
|
+
var Unconvertible = class extends Error {};
|
|
22273
|
+
/**
|
|
22274
|
+
* Converts a 2019-09 schema (e.g. from zod v3) into 2020-12 form. Tuples are the
|
|
22275
|
+
* only structural difference handled: array-form `items` becomes `prefixItems`,
|
|
22276
|
+
* and `additionalItems` becomes `items`.
|
|
22277
|
+
*
|
|
22278
|
+
* Returns `undefined` when the schema does not declare 2019-09, or relies on
|
|
22279
|
+
* features this conversion cannot preserve (`$recursiveRef`/`$recursiveAnchor`,
|
|
22280
|
+
* `$ref` pointers into tuple members, embedded `$schema` declarations,
|
|
22281
|
+
* `unevaluatedItems`, `prefixItems`, or `contentSchema`), or exceeds the depth/node limits.
|
|
22282
|
+
* Callers should then keep the original.
|
|
22283
|
+
*/
|
|
22284
|
+
function toJsonSchema2020(schema) {
|
|
22285
|
+
if (!schema.$schema || !JSON_SCHEMA_2019_09.test(schema.$schema)) return void 0;
|
|
22286
|
+
try {
|
|
22287
|
+
return {
|
|
22288
|
+
...rewrite(schema, 0, { nodes: 0 }, true),
|
|
22289
|
+
$schema: JSON_SCHEMA_2020_12
|
|
22290
|
+
};
|
|
22291
|
+
} catch (error) {
|
|
22292
|
+
if (error instanceof Unconvertible) return void 0;
|
|
22293
|
+
throw error;
|
|
22294
|
+
}
|
|
22295
|
+
}
|
|
22296
|
+
function checkBudget(depth, budget) {
|
|
22297
|
+
if (depth > 128 || ++budget.nodes > 1e4) throw new Unconvertible();
|
|
22298
|
+
}
|
|
22299
|
+
/** Rewrites a value in a subschema position. Only known schema keywords are walked; everything else is copied as-is. */
|
|
22300
|
+
function rewrite(schema, depth, budget, isRoot = false) {
|
|
22301
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema)) return schema;
|
|
22302
|
+
checkBudget(depth, budget);
|
|
22303
|
+
const out = { ...schema };
|
|
22304
|
+
if (!isRoot && "$schema" in out) throw new Unconvertible();
|
|
22305
|
+
if ("$recursiveRef" in out || "$recursiveAnchor" in out) throw new Unconvertible();
|
|
22306
|
+
if ("unevaluatedItems" in out || "prefixItems" in out || "contentSchema" in out) throw new Unconvertible();
|
|
22307
|
+
if (typeof out.$ref === "string" && /\/(items\/\d+|additionalItems)(\/|$)/.test(out.$ref)) throw new Unconvertible();
|
|
22308
|
+
for (const [key, child] of Object.entries(out)) if (SCHEMA_KEYWORDS.has(key)) out[key] = Array.isArray(child) ? (checkBudget(depth + 1, budget), child.map((item) => rewrite(item, depth + 2, budget))) : rewrite(child, depth + 1, budget);
|
|
22309
|
+
else if (SCHEMA_ARRAY_KEYWORDS.has(key) && Array.isArray(child)) {
|
|
22310
|
+
checkBudget(depth + 1, budget);
|
|
22311
|
+
out[key] = child.map((item) => rewrite(item, depth + 2, budget));
|
|
22312
|
+
} else if (SCHEMA_MAP_KEYWORDS.has(key) && child && typeof child === "object" && !Array.isArray(child)) {
|
|
22313
|
+
checkBudget(depth + 1, budget);
|
|
22314
|
+
out[key] = Object.fromEntries(Object.entries(child).map(([name, sub]) => [name, rewrite(sub, depth + 2, budget)]));
|
|
22315
|
+
}
|
|
22316
|
+
if (!Array.isArray(out.items)) return out;
|
|
22317
|
+
out.prefixItems = out.items;
|
|
22318
|
+
if ("additionalItems" in out) out.items = out.additionalItems;
|
|
22319
|
+
else delete out.items;
|
|
22320
|
+
delete out.additionalItems;
|
|
22321
|
+
return out;
|
|
22322
|
+
}
|
|
22323
|
+
//#endregion
|
|
22240
22324
|
//#region src/shared/mastra-tool-meta.ts
|
|
22241
22325
|
const MASTRA_META_KEY = "mastra";
|
|
22242
22326
|
const STRICT_META_KEY = "strict";
|
|
@@ -22891,9 +22975,6 @@ async function fetchFollowingAllowedRedirects(fetchImpl, url, init, allowedHosts
|
|
|
22891
22975
|
//#endregion
|
|
22892
22976
|
//#region src/client/client.ts
|
|
22893
22977
|
const DEFAULT_SERVER_CONNECT_TIMEOUT_MSEC = 3e3;
|
|
22894
|
-
const JSON_SCHEMA_2020_12 = "https://json-schema.org/draft/2020-12/schema";
|
|
22895
|
-
const MAX_JSON_SCHEMA_DEPTH = 128;
|
|
22896
|
-
const MAX_JSON_SCHEMA_NODES = 1e4;
|
|
22897
22978
|
/**
|
|
22898
22979
|
* Bounds the work a validator can be asked to do for an untrusted tool catalogue.
|
|
22899
22980
|
* Only schema-bearing keywords are walked, so deeply nested annotation data such as
|
|
@@ -22940,8 +23021,8 @@ function getJsonSchemaComplexityError(schema) {
|
|
|
22940
23021
|
if (value === null || typeof value !== "object" || Array.isArray(value) || seen.has(value)) continue;
|
|
22941
23022
|
seen.add(value);
|
|
22942
23023
|
nodes += 1;
|
|
22943
|
-
if (depth >
|
|
22944
|
-
if (nodes >
|
|
23024
|
+
if (depth > 128) return `JSON Schema exceeds the maximum depth of 128`;
|
|
23025
|
+
if (nodes > 1e4) return `JSON Schema exceeds the maximum node count of ${MAX_JSON_SCHEMA_NODES}`;
|
|
22945
23026
|
const record = value;
|
|
22946
23027
|
for (const keyword of schemaMapKeywords) {
|
|
22947
23028
|
const schemas = record[keyword];
|
|
@@ -22963,12 +23044,24 @@ function getJsonSchemaComplexityError(schema) {
|
|
|
22963
23044
|
});
|
|
22964
23045
|
}
|
|
22965
23046
|
}
|
|
22966
|
-
|
|
23047
|
+
const SUPPORTED_DIALECTS = /* @__PURE__ */ new Set([
|
|
23048
|
+
JSON_SCHEMA_2020_12,
|
|
23049
|
+
`${JSON_SCHEMA_2020_12}#`,
|
|
23050
|
+
"http://json-schema.org/draft-07/schema",
|
|
23051
|
+
"http://json-schema.org/draft-07/schema#"
|
|
23052
|
+
]);
|
|
23053
|
+
/**
|
|
23054
|
+
* MCP 2026-07-28 schemas default to JSON Schema 2020-12 when they declare no dialect.
|
|
23055
|
+
* 2019-09 schemas (e.g. from zod v3 servers) are converted to 2020-12 when that can be done
|
|
23056
|
+
* faithfully, so tool calls are not rejected before they run.
|
|
23057
|
+
*/
|
|
22967
23058
|
function withDefaultDialect(schema) {
|
|
22968
|
-
|
|
23059
|
+
if (!schema.$schema) return {
|
|
22969
23060
|
...schema,
|
|
22970
23061
|
$schema: JSON_SCHEMA_2020_12
|
|
22971
23062
|
};
|
|
23063
|
+
if (SUPPORTED_DIALECTS.has(schema.$schema)) return schema;
|
|
23064
|
+
return toJsonSchema2020(schema) ?? schema;
|
|
22972
23065
|
}
|
|
22973
23066
|
const DEFAULT_INSTRUCTIONS_MAX_LENGTH = 512;
|
|
22974
23067
|
const DEFAULT_SERVER_LOG_LEVEL = "info";
|
|
@@ -26312,14 +26405,18 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
26312
26405
|
/**
|
|
26313
26406
|
* Converts a tool schema to JSON Schema 2020-12, the dialect MCP 2026-07-28
|
|
26314
26407
|
* assumes when none is declared. The dialect declaration is kept so validators
|
|
26315
|
-
* that dispatch on `$schema` pick the same draft on both sides.
|
|
26408
|
+
* that dispatch on `$schema` pick the same draft on both sides. Some vendors
|
|
26409
|
+
* (e.g. zod v3) emit 2019-09 for this target, so it is rewritten to 2020-12.
|
|
26316
26410
|
*/
|
|
26317
26411
|
jsonSchema(schema, options) {
|
|
26318
26412
|
if (!schema) return void 0;
|
|
26319
|
-
|
|
26413
|
+
if (!(0, _mastra_core_schema.isStandardSchemaWithJSON)(schema)) return schema.jsonSchema ?? schema;
|
|
26414
|
+
const converted = (0, _mastra_core_schema.standardSchemaToJSONSchema)(schema, {
|
|
26320
26415
|
...options,
|
|
26321
26416
|
target: "draft-2020-12"
|
|
26322
|
-
})
|
|
26417
|
+
});
|
|
26418
|
+
if (!converted.$schema || converted.$schema === "https://json-schema.org/draft/2020-12/schema") return converted;
|
|
26419
|
+
return toJsonSchema2020(converted) ?? converted;
|
|
26323
26420
|
}
|
|
26324
26421
|
addTools(tools) {
|
|
26325
26422
|
const converted = this.convertTools(tools);
|