fastmcp 4.23.7 → 4.23.8

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.
Files changed (39) hide show
  1. package/dist/FastMCP.cjs +4 -4
  2. package/dist/FastMCP.d.cts +1 -1
  3. package/dist/FastMCP.d.ts +1 -1
  4. package/dist/FastMCP.js +3 -3
  5. package/dist/auth/index.cjs +2 -2
  6. package/dist/auth/index.js +1 -1
  7. package/dist/bin/fastmcp.cjs +7 -1
  8. package/dist/bin/fastmcp.cjs.map +1 -1
  9. package/dist/bin/fastmcp.js +7 -1
  10. package/dist/bin/fastmcp.js.map +1 -1
  11. package/dist/{chunk-C7TBI7A5.cjs → chunk-AJRXMUZR.cjs} +8 -4
  12. package/dist/chunk-AJRXMUZR.cjs.map +1 -0
  13. package/dist/{chunk-YZ5QEHBX.js → chunk-F76U45MT.js} +11 -3
  14. package/dist/chunk-F76U45MT.js.map +1 -0
  15. package/dist/{chunk-7WNI6AGD.js → chunk-PLUAEIWE.js} +42 -19
  16. package/dist/chunk-PLUAEIWE.js.map +1 -0
  17. package/dist/{chunk-MPFPOZ2H.cjs → chunk-T2F3RYH2.cjs} +12 -4
  18. package/dist/chunk-T2F3RYH2.cjs.map +1 -0
  19. package/dist/{chunk-CA2EPNZF.js → chunk-UY253ACS.js} +8 -4
  20. package/dist/chunk-UY253ACS.js.map +1 -0
  21. package/dist/{chunk-TBMRFQ6M.cjs → chunk-XEP3OP7Q.cjs} +99 -76
  22. package/dist/chunk-XEP3OP7Q.cjs.map +1 -0
  23. package/dist/edge/index.cjs +8 -4
  24. package/dist/edge/index.cjs.map +1 -1
  25. package/dist/edge/index.js +6 -2
  26. package/dist/edge/index.js.map +1 -1
  27. package/dist/examples/custom-routes.cjs +4 -4
  28. package/dist/examples/custom-routes.js +3 -3
  29. package/dist/openapi/index.cjs +17 -12
  30. package/dist/openapi/index.cjs.map +1 -1
  31. package/dist/openapi/index.js +12 -7
  32. package/dist/openapi/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-7WNI6AGD.js.map +0 -1
  35. package/dist/chunk-C7TBI7A5.cjs.map +0 -1
  36. package/dist/chunk-CA2EPNZF.js.map +0 -1
  37. package/dist/chunk-MPFPOZ2H.cjs.map +0 -1
  38. package/dist/chunk-TBMRFQ6M.cjs.map +0 -1
  39. package/dist/chunk-YZ5QEHBX.js.map +0 -1
@@ -1,9 +1,15 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/strictInputSchema.ts
2
2
  var _zod2 = require('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 { additionalProperties, anyOf, oneOf, properties } = schema;
8
+ if (!nested && !properties && (anyOf || oneOf)) {
9
+ return objectRootSchema(schema);
10
+ }
5
11
  const keepsAdditionalProperties = Object.keys(_nullishCoalesce(properties, () => ( {}))).length === 0 && (typeof additionalProperties === "object" || additionalProperties === true || nested && additionalProperties === void 0 && !properties);
6
- return {
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 _zod2.z.toJSONSchema(schema, {
@@ -32,5 +39,6 @@ function zodInputSchema(schema, target) {
32
39
 
33
40
 
34
41
 
35
- exports.strictInputSchema = strictInputSchema; exports.zodInputSchema = zodInputSchema;
36
- //# sourceMappingURL=chunk-MPFPOZ2H.cjs.map
42
+
43
+ exports.objectRootSchema = objectRootSchema; exports.strictInputSchema = strictInputSchema; exports.zodInputSchema = zodInputSchema;
44
+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AA,UACA,OAAO,MAAA,IAAU,SAAA,GAAY,KAAA,CAAM,KAAA,IAAS,SAAA,EACxC,iBAAA,CAAkB,KAAA,EAAO,IAAI,EAAA,EAC7B;AAAA,QACN,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF,CAAA;AAEA,EAAA,OAAO,OAAA,EAAS,OAAA,EAAS,gBAAA,CAAiB,MAAM,CAAA;AAClD;AAWO,SAAS,cAAA,CACd,MAAA,EACA,MAAA,EACY;AACZ,EAAA,OAAO,OAAA,CAAE,YAAA,CAAa,MAAA,EAAQ;AAAA,IAC5B,EAAA,EAAI,OAAA;AAAA,IACJ,QAAA,EAAU,CAAC,EAAE,UAAA,EAAY,UAAU,CAAA,EAAA,GAAM;AACvC,MAAA,MAAM,IAAA,EAAM,SAAA,CAAU,IAAA,CAAK,GAAA;AAC3B,MAAA,GAAA,CACE,GAAA,CAAI,KAAA,IAAS,SAAA,GACb,CAAC,GAAA,CAAI,SAAA,GACL,UAAA,CAAW,qBAAA,IAAyB,KAAA,CAAA,EACpC;AACA,QAAA,UAAA,CAAW,qBAAA,EAAuB,KAAA;AAAA,MACpC;AAAA,IACF,CAAA;AAAA,IACA;AAAA,EACF,CAAC,CAAA;AACH;ADjEA;AACA;AACE;AACA;AACA;AACF,oIAAC","file":"/home/runner/work/fastmcp/fastmcp/dist/chunk-T2F3RYH2.cjs","sourcesContent":[null,"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 * An object that declares an empty `properties`, or a bare one at the top of\n * the input, is still closed: that is how a schema says \"no keys\" —\n * `z.object({})`, or a tool without arguments. A union at the top, though —\n * `anyOf` or `oneOf` with no `properties` of its own — is left as it is: its\n * branches declare its keys, and how strict they are, so closing the root\n * would reject every one of them.\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 { additionalProperties, anyOf, oneOf, properties } = schema;\n\n if (!nested && !properties && (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"]}
@@ -395,14 +395,18 @@ function expandIPv6(host) {
395
395
  return groups.every((g) => !Number.isNaN(g)) ? groups : null;
396
396
  }
397
397
  function isPrivateOrLoopbackHost(hostname) {
398
- const host = hostname.toLowerCase().replace(/^\[|\]$/g, "");
399
- if (host === "localhost" || host === "0.0.0.0") {
398
+ const host = hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
399
+ if (host === "localhost" || host.endsWith(".localhost")) {
400
400
  return true;
401
401
  }
402
402
  if (host.includes(":")) {
403
403
  return isPrivateOrLoopbackIPv6(host);
404
404
  }
405
- return host === "127.0.0.1" || /^169\.254\./.test(host) || /^10\./.test(host) || /^192\.168\./.test(host) || /^172\.(1[6-9]|2\d|3[01])\./.test(host);
405
+ return /^0\./.test(host) || // 0.0.0.0/8, "this network"
406
+ /^127\./.test(host) || // 127.0.0.0/8, all of it loopback
407
+ // 100.64.0.0/10, shared (CGNAT) space — Alibaba Cloud's metadata
408
+ // endpoint is 100.100.100.200.
409
+ /^100\.(6[4-9]|[7-9]\d|1[01]\d|12[0-7])\./.test(host) || /^169\.254\./.test(host) || /^10\./.test(host) || /^192\.168\./.test(host) || /^172\.(1[6-9]|2\d|3[01])\./.test(host);
406
410
  }
407
411
  function isPrivateOrLoopbackIPv6(host) {
408
412
  const groups = expandIPv6(host);
@@ -3142,4 +3146,4 @@ export {
3142
3146
  DiskStore,
3143
3147
  JWKSVerifier
3144
3148
  };
3145
- //# sourceMappingURL=chunk-CA2EPNZF.js.map
3149
+ //# sourceMappingURL=chunk-UY253ACS.js.map