fastmcp 4.23.7 → 4.23.9
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/FastMCP.cjs +4 -4
- package/dist/FastMCP.d.cts +3 -2
- package/dist/FastMCP.d.ts +3 -2
- package/dist/FastMCP.js +3 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/bin/fastmcp.cjs +7 -1
- package/dist/bin/fastmcp.cjs.map +1 -1
- package/dist/bin/fastmcp.js +7 -1
- package/dist/bin/fastmcp.js.map +1 -1
- package/dist/{chunk-C7TBI7A5.cjs → chunk-4OWHPJEL.cjs} +16 -5
- package/dist/chunk-4OWHPJEL.cjs.map +1 -0
- package/dist/{chunk-MPFPOZ2H.cjs → chunk-6TDYSPLC.cjs} +12 -4
- package/dist/chunk-6TDYSPLC.cjs.map +1 -0
- package/dist/{chunk-7WNI6AGD.js → chunk-75ZLE5AS.js} +153 -59
- package/dist/chunk-75ZLE5AS.js.map +1 -0
- package/dist/{chunk-CA2EPNZF.js → chunk-G44SPVP7.js} +16 -5
- package/dist/chunk-G44SPVP7.js.map +1 -0
- package/dist/{chunk-YZ5QEHBX.js → chunk-OKKFL2M4.js} +11 -3
- package/dist/chunk-OKKFL2M4.js.map +1 -0
- package/dist/{chunk-TBMRFQ6M.cjs → chunk-PV5VLW7R.cjs} +208 -114
- package/dist/chunk-PV5VLW7R.cjs.map +1 -0
- package/dist/edge/index.cjs +13 -5
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.js +11 -3
- package/dist/edge/index.js.map +1 -1
- package/dist/examples/custom-routes.cjs +4 -4
- package/dist/examples/custom-routes.js +3 -3
- package/dist/openapi/index.cjs +17 -12
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +12 -7
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-7WNI6AGD.js.map +0 -1
- package/dist/chunk-C7TBI7A5.cjs.map +0 -1
- package/dist/chunk-CA2EPNZF.js.map +0 -1
- package/dist/chunk-MPFPOZ2H.cjs.map +0 -1
- package/dist/chunk-TBMRFQ6M.cjs.map +0 -1
- package/dist/chunk-YZ5QEHBX.js.map +0 -1
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
// src/strictInputSchema.ts
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
function objectRootSchema(schema) {
|
|
4
|
+
return schema.type === void 0 ? { ...schema, type: "object" } : schema;
|
|
5
|
+
}
|
|
3
6
|
function strictInputSchema(schema, nested = false) {
|
|
4
|
-
const { additionalProperties, properties } = schema;
|
|
7
|
+
const { $ref, additionalProperties, allOf, anyOf, oneOf, properties } = schema;
|
|
8
|
+
if (!nested && ($ref || allOf || anyOf || oneOf)) {
|
|
9
|
+
return objectRootSchema(schema);
|
|
10
|
+
}
|
|
5
11
|
const keepsAdditionalProperties = Object.keys(properties ?? {}).length === 0 && (typeof additionalProperties === "object" || additionalProperties === true || nested && additionalProperties === void 0 && !properties);
|
|
6
|
-
|
|
12
|
+
const strict = {
|
|
7
13
|
...schema,
|
|
8
14
|
...keepsAdditionalProperties ? {} : { additionalProperties: false },
|
|
9
15
|
...properties && {
|
|
@@ -15,6 +21,7 @@ function strictInputSchema(schema, nested = false) {
|
|
|
15
21
|
)
|
|
16
22
|
}
|
|
17
23
|
};
|
|
24
|
+
return nested ? strict : objectRootSchema(strict);
|
|
18
25
|
}
|
|
19
26
|
function zodInputSchema(schema, target) {
|
|
20
27
|
return z.toJSONSchema(schema, {
|
|
@@ -30,7 +37,8 @@ function zodInputSchema(schema, target) {
|
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
export {
|
|
40
|
+
objectRootSchema,
|
|
33
41
|
strictInputSchema,
|
|
34
42
|
zodInputSchema
|
|
35
43
|
};
|
|
36
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-OKKFL2M4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/strictInputSchema.ts"],"sourcesContent":["import type { JsonSchema } from \"xsschema\";\n\nimport { z } from \"zod\";\n\n/**\n * Gives a tool's input or output schema the `type: \"object\"` MCP requires at\n * its root, unless it states a type of its own. A union of objects converts to\n * a bare `anyOf` or `oneOf`, and the SDK client rejects a whole `tools/list`\n * that contains one, so a single such tool would hide every other. Arguments\n * and structured content are always objects, so this only rules out values a\n * tool can never be sent or return.\n */\nexport function objectRootSchema(schema: JsonSchema): JsonSchema {\n return schema.type === undefined ? { ...schema, type: \"object\" } : schema;\n}\n\n/**\n * Closes tool input objects to undeclared keys, like xsschema's\n * `strictJsonSchema`, except for objects made only of additional properties.\n * Closing one of those advertises an object that accepts nothing but `{}`,\n * while the tool's own validation still takes any key, so it keeps whatever\n * `additionalProperties` it declared — or none:\n *\n * - a dictionary, whose `additionalProperties` is a schema (`z.record()`, an\n * OpenAPI map), keeps its value schema;\n * - a free-form object, which declares `additionalProperties: true`, or, as an\n * argument, is a bare `{ type: \"object\" }` (OpenAPI's usual spelling), stays\n * open.\n *\n * A plain object that declares an empty `properties`, or a bare one at the\n * top of the input, is still closed: that is how a schema says \"no keys\" —\n * `z.object({})`, or a tool without arguments. Root schemas with `allOf`,\n * `anyOf`, `oneOf`, or `$ref` are left as declared, even with their own\n * `properties`: `additionalProperties` only sees adjacent properties, so\n * adding it would reject keys declared by a branch or reference target.\n *\n * The root is given an object type (see `objectRootSchema`).\n *\n * Shared by both runtimes, so a tool's advertised input schema does not depend\n * on whether it is served by `FastMCP` or `EdgeFastMCP`.\n */\nexport function strictInputSchema(\n schema: JsonSchema,\n nested = false,\n): JsonSchema {\n const { $ref, additionalProperties, allOf, anyOf, oneOf, properties } =\n schema;\n\n if (!nested && ($ref || allOf || anyOf || oneOf)) {\n return objectRootSchema(schema);\n }\n\n const keepsAdditionalProperties =\n Object.keys(properties ?? {}).length === 0 &&\n (typeof additionalProperties === \"object\" ||\n additionalProperties === true ||\n (nested && additionalProperties === undefined && !properties));\n\n const strict = {\n ...schema,\n ...(keepsAdditionalProperties ? {} : { additionalProperties: false }),\n ...(properties && {\n properties: Object.fromEntries(\n Object.entries(properties).map(([key, value]) => [\n key,\n typeof value === \"object\" && value.type === \"object\"\n ? strictInputSchema(value, true)\n : value,\n ]),\n ),\n }),\n };\n\n return nested ? strict : objectRootSchema(strict);\n}\n\n/**\n * Converts Zod 4 tool parameters by what a call may send (`io: \"input\"`), so a\n * transformed field advertises the type it parses and a defaulted one is\n * optional. Input-side conversion leaves a plain `z.object()` open, since it\n * strips undeclared keys rather than rejecting them; this closes it, as\n * output-side conversion did, at any depth — including inside arrays, unions\n * and record values, which `strictInputSchema` does not reach. Explicit\n * catchalls (`z.looseObject()`, `.catchall()`) keep what they declare.\n */\nexport function zodInputSchema(\n schema: z.ZodType,\n target?: \"draft-7\",\n): JsonSchema {\n return z.toJSONSchema(schema, {\n io: \"input\",\n override: ({ jsonSchema, zodSchema }) => {\n const def = zodSchema._zod.def;\n if (\n def.type === \"object\" &&\n !def.catchall &&\n jsonSchema.additionalProperties === undefined\n ) {\n jsonSchema.additionalProperties = false;\n }\n },\n target,\n }) as JsonSchema;\n}\n"],"mappings":";AAEA,SAAS,SAAS;AAUX,SAAS,iBAAiB,QAAgC;AAC/D,SAAO,OAAO,SAAS,SAAY,EAAE,GAAG,QAAQ,MAAM,SAAS,IAAI;AACrE;AA2BO,SAAS,kBACd,QACA,SAAS,OACG;AACZ,QAAM,EAAE,MAAM,sBAAsB,OAAO,OAAO,OAAO,WAAW,IAClE;AAEF,MAAI,CAAC,WAAW,QAAQ,SAAS,SAAS,QAAQ;AAChD,WAAO,iBAAiB,MAAM;AAAA,EAChC;AAEA,QAAM,4BACJ,OAAO,KAAK,cAAc,CAAC,CAAC,EAAE,WAAW,MACxC,OAAO,yBAAyB,YAC/B,yBAAyB,QACxB,UAAU,yBAAyB,UAAa,CAAC;AAEtD,QAAM,SAAS;AAAA,IACb,GAAG;AAAA,IACH,GAAI,4BAA4B,CAAC,IAAI,EAAE,sBAAsB,MAAM;AAAA,IACnE,GAAI,cAAc;AAAA,MAChB,YAAY,OAAO;AAAA,QACjB,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,UAC/C;AAAA,UACA,OAAO,UAAU,YAAY,MAAM,SAAS,WACxC,kBAAkB,OAAO,IAAI,IAC7B;AAAA,QACN,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO,SAAS,SAAS,iBAAiB,MAAM;AAClD;AAWO,SAAS,eACd,QACA,QACY;AACZ,SAAO,EAAE,aAAa,QAAQ;AAAA,IAC5B,IAAI;AAAA,IACJ,UAAU,CAAC,EAAE,YAAY,UAAU,MAAM;AACvC,YAAM,MAAM,UAAU,KAAK;AAC3B,UACE,IAAI,SAAS,YACb,CAAC,IAAI,YACL,WAAW,yBAAyB,QACpC;AACA,mBAAW,uBAAuB;AAAA,MACpC;AAAA,IACF;AAAA,IACA;AAAA,EACF,CAAC;AACH;","names":[]}
|