fastmcp 4.28.2 → 4.28.4

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 (45) hide show
  1. package/dist/FastMCP.cjs +4 -4
  2. package/dist/FastMCP.d.cts +2 -2
  3. package/dist/FastMCP.d.ts +2 -2
  4. package/dist/FastMCP.js +3 -3
  5. package/dist/{OAuthProvider-DvIxa9N1.d.cts → OAuthProvider-C2Z93xC5.d.cts} +3 -1
  6. package/dist/{OAuthProvider-DvIxa9N1.d.ts → OAuthProvider-C2Z93xC5.d.ts} +3 -1
  7. package/dist/auth/index.cjs +2 -2
  8. package/dist/auth/index.d.cts +2 -2
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +1 -1
  11. package/dist/bin/fastmcp.cjs +0 -1
  12. package/dist/bin/fastmcp.cjs.map +1 -1
  13. package/dist/bin/fastmcp.js +0 -1
  14. package/dist/bin/fastmcp.js.map +1 -1
  15. package/dist/{chunk-HZJE6ZGH.cjs → chunk-7IQ5QHVZ.cjs} +39 -19
  16. package/dist/chunk-7IQ5QHVZ.cjs.map +1 -0
  17. package/dist/{chunk-AM3HVK4Z.js → chunk-B2QUCZGV.js} +42 -18
  18. package/dist/chunk-B2QUCZGV.js.map +1 -0
  19. package/dist/{chunk-GW5MENCI.cjs → chunk-DPJW5QEO.cjs} +34 -13
  20. package/dist/chunk-DPJW5QEO.cjs.map +1 -0
  21. package/dist/{chunk-2NZFMD6I.cjs → chunk-OCCYKYIM.cjs} +42 -18
  22. package/dist/chunk-OCCYKYIM.cjs.map +1 -0
  23. package/dist/{chunk-MBIVAKUB.js → chunk-Q57EM4LH.js} +28 -7
  24. package/dist/chunk-Q57EM4LH.js.map +1 -0
  25. package/dist/{chunk-76OY4FEK.js → chunk-UFPH23EN.js} +35 -15
  26. package/dist/chunk-UFPH23EN.js.map +1 -0
  27. package/dist/edge/index.cjs +19 -8
  28. package/dist/edge/index.cjs.map +1 -1
  29. package/dist/edge/index.js +17 -6
  30. package/dist/edge/index.js.map +1 -1
  31. package/dist/examples/custom-routes.cjs +4 -4
  32. package/dist/examples/custom-routes.js +3 -3
  33. package/dist/openapi/index.cjs +23 -12
  34. package/dist/openapi/index.cjs.map +1 -1
  35. package/dist/openapi/index.d.cts +1 -1
  36. package/dist/openapi/index.d.ts +1 -1
  37. package/dist/openapi/index.js +17 -6
  38. package/dist/openapi/index.js.map +1 -1
  39. package/package.json +1 -1
  40. package/dist/chunk-2NZFMD6I.cjs.map +0 -1
  41. package/dist/chunk-76OY4FEK.js.map +0 -1
  42. package/dist/chunk-AM3HVK4Z.js.map +0 -1
  43. package/dist/chunk-GW5MENCI.cjs.map +0 -1
  44. package/dist/chunk-HZJE6ZGH.cjs.map +0 -1
  45. package/dist/chunk-MBIVAKUB.js.map +0 -1
@@ -4,23 +4,7 @@ function objectRootSchema(schema) {
4
4
  return schema.type === void 0 ? { ...schema, type: "object" } : schema;
5
5
  }
6
6
  function strictInputSchema(schema, nested = false) {
7
- const { $ref, additionalProperties, allOf, anyOf, oneOf, properties } = schema;
8
- if (!nested && ($ref || allOf || anyOf || oneOf)) {
9
- return objectRootSchema(schema);
10
- }
11
- const keepsAdditionalProperties = Object.keys(_nullishCoalesce(properties, () => ( {}))).length === 0 && (typeof additionalProperties === "object" || additionalProperties === true || nested && additionalProperties === void 0 && !properties);
12
- const strict = {
13
- ...schema,
14
- ...keepsAdditionalProperties ? {} : { additionalProperties: false },
15
- ...properties && {
16
- properties: Object.fromEntries(
17
- Object.entries(properties).map(([key, value]) => [
18
- key,
19
- typeof value === "object" && value.type === "object" ? strictInputSchema(value, true) : value
20
- ])
21
- )
22
- }
23
- };
7
+ const strict = strictSchemaNode(schema, nested, false);
24
8
  return nested ? strict : objectRootSchema(strict);
25
9
  }
26
10
  function zodInputSchema(schema, target) {
@@ -111,10 +95,50 @@ function zodInputSchema(schema, target) {
111
95
  }
112
96
  return closed;
113
97
  }
98
+ function isSchemaRecord(value) {
99
+ return typeof value === "object" && value !== null && !Array.isArray(value);
100
+ }
101
+ function strictSchemaNode(schema, nested, operand) {
102
+ const { $ref, additionalProperties, allOf, anyOf, oneOf, properties } = schema;
103
+ const hasConditional = "if" in schema && schema.if !== void 0;
104
+ const hasComposition = Boolean(
105
+ $ref || allOf || anyOf || oneOf || hasConditional
106
+ );
107
+ const isObjectSchema = nested ? schema.type === "object" : schema.type === void 0 || schema.type === "object";
108
+ const keepsAdditionalProperties = Object.keys(_nullishCoalesce(properties, () => ( {}))).length === 0 && (typeof additionalProperties === "object" || additionalProperties === true || nested && additionalProperties === void 0 && !properties);
109
+ const closesNode = !operand && !hasComposition && isObjectSchema && !keepsAdditionalProperties;
110
+ const next = {
111
+ ...schema,
112
+ ...closesNode ? { additionalProperties: false } : {}
113
+ };
114
+ if (properties) {
115
+ next.properties = Object.fromEntries(
116
+ Object.entries(properties).map(([key, value]) => [
117
+ key,
118
+ isSchemaRecord(value) ? strictSchemaNode(value, true, false) : value
119
+ ])
120
+ );
121
+ }
122
+ for (const keyword of ["allOf", "anyOf", "oneOf"]) {
123
+ const branches = schema[keyword];
124
+ if (Array.isArray(branches)) {
125
+ next[keyword] = branches.map(
126
+ (branch) => isSchemaRecord(branch) ? strictSchemaNode(branch, true, true) : branch
127
+ );
128
+ }
129
+ }
130
+ for (const keyword of ["else", "then"]) {
131
+ const branch = schema[keyword];
132
+ if (isSchemaRecord(branch)) {
133
+ next[keyword] = strictSchemaNode(branch, true, true);
134
+ }
135
+ }
136
+ return next;
137
+ }
114
138
 
115
139
 
116
140
 
117
141
 
118
142
 
119
143
  exports.objectRootSchema = objectRootSchema; exports.strictInputSchema = strictInputSchema; exports.zodInputSchema = zodInputSchema;
120
- //# sourceMappingURL=chunk-2NZFMD6I.cjs.map
144
+ //# sourceMappingURL=chunk-OCCYKYIM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/fastmcp/fastmcp/dist/chunk-OCCYKYIM.cjs","../src/strictInputSchema.ts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A,MAAA;AACA,MAAA;AACC,IAAA;AAC2B,MAAA;AACH,MAAA;AAEnB,QAAA;AAEN,MAAA;AACF,IAAA;AACO,IAAA;AACT,EAAA;AAEsC,EAAA;AACf,EAAA;AACI,IAAA;AACE,MAAA;AACtB,MAAA;AACL,IAAA;AACF,EAAA;AACO,EAAA;AACT;AAE6D;AACb,EAAA;AAChD;AAMc;AACsC,EAAA;AAEF,EAAA;AACzB,EAAA;AACc,IAAA;AACrC,EAAA;AAEoB,EAAA;AAIN,EAAA;AAMmB,EAAA;AAEK,EAAA;AACjC,IAAA;AAC4C,IAAA;AACjD,EAAA;AAEgB,EAAA;AACW,IAAA;AACoB,MAAA;AACzC,QAAA;AACyC,QAAA;AAC1C,MAAA;AACH,IAAA;AACF,EAAA;AAEgD,EAAA;AACc,IAAA;AAC/B,IAAA;AACF,MAAA;AACE,QAAA;AAC3B,MAAA;AACF,IAAA;AACF,EAAA;AAEiD,EAAA;AACW,IAAA;AAC9B,IAAA;AACe,MAAA;AAC3C,IAAA;AACF,EAAA;AAEO,EAAA;AACT;ADrGoD;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/fastmcp/fastmcp/dist/chunk-OCCYKYIM.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 * 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. An object with `allOf`,\n * `anyOf`, `oneOf`, `$ref`, or `if`, at the root or nested, keeps its own\n * `additionalProperties` as declared, as do the branches of a composition and\n * the `then` and `else` of a condition: `additionalProperties` only sees\n * adjacent properties, so adding it would reject keys declared by a branch,\n * reference target, or condition. The ordinary objects among their\n * `properties` are closed like any other.\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 strict = strictSchemaNode(schema, nested, false);\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. Close ordinary object occurrences after conversion, but leave\n * intersection operands open to each other's keys. Child values start a new\n * closure context; explicit catchalls, including .strict(), stay as declared.\n */\nexport function zodInputSchema(\n schema: z.ZodType,\n target?: \"draft-7\",\n): JsonSchema {\n const jsonSchema = z.toJSONSchema(schema, {\n io: \"input\",\n target,\n }) as Record<string, unknown>;\n const definitionsKey = target === \"draft-7\" ? \"definitions\" : \"$defs\";\n const definitions: Record<string, unknown> = {};\n const operands = new Map<string, string>();\n\n const closeObjects = (value: unknown, operand = false): unknown => {\n if (!value || typeof value !== \"object\") return value;\n const result = { ...(value as Record<string, unknown>) };\n\n if (\n operand &&\n typeof result.$ref === \"string\" &&\n (result.$ref === \"#\" || result.$ref.startsWith(\"#/\"))\n ) {\n const reference = result.$ref;\n let name = operands.get(reference);\n if (!name) {\n const path = decodeURIComponent(reference.slice(1)).split(\"/\").slice(1);\n const referenced = path.reduce<unknown>(\n (node, key) =>\n node && typeof node === \"object\"\n ? (node as Record<string, unknown>)[\n key.replace(/~1/g, \"/\").replace(/~0/g, \"~\")\n ]\n : undefined,\n jsonSchema,\n );\n if (referenced && typeof referenced === \"object\") {\n name = `__fastmcp_operand_${operands.size}`;\n const existing = jsonSchema[definitionsKey] as object | undefined;\n while (\n Object.hasOwn(existing ?? {}, name) ||\n Object.hasOwn(definitions, name)\n )\n name += \"_\";\n // Reserve the reference before descending, including through child values.\n operands.set(reference, name);\n const copy = { ...(referenced as Record<string, unknown>) };\n delete copy.$schema;\n delete copy.$defs;\n delete copy.definitions;\n definitions[name] = closeObjects(copy, true);\n }\n }\n if (name) result.$ref = `#/${definitionsKey}/${name}`;\n }\n\n if (\n !operand &&\n result.type === \"object\" &&\n result.properties !== undefined &&\n result.additionalProperties === undefined\n ) {\n result.additionalProperties = false;\n }\n\n for (const keyword of [\"allOf\", \"anyOf\", \"oneOf\"]) {\n const branches = result[keyword];\n if (Array.isArray(branches)) {\n // A single allOf branch is Zod's draft-7 reference wrapper, not\n // an intersection. Only intersections introduce a new exemption.\n result[keyword] = branches.map((branch) =>\n closeObjects(\n branch,\n operand || (keyword === \"allOf\" && branches.length > 1),\n ),\n );\n }\n }\n\n for (const keyword of [\n \"$defs\",\n \"definitions\",\n \"patternProperties\",\n \"properties\",\n ]) {\n const children = result[keyword];\n if (children && typeof children === \"object\") {\n result[keyword] = Object.fromEntries(\n Object.entries(children).map(([key, child]) => [\n key,\n closeObjects(child),\n ]),\n );\n }\n }\n for (const keyword of [\n \"additionalItems\",\n \"additionalProperties\",\n \"items\",\n \"prefixItems\",\n \"propertyNames\",\n ]) {\n const child = result[keyword];\n if (child !== undefined) {\n result[keyword] = Array.isArray(child)\n ? child.map((item) => closeObjects(item))\n : closeObjects(child);\n }\n }\n return result;\n };\n\n const closed = closeObjects(jsonSchema) as Record<string, unknown>;\n if (operands.size > 0) {\n closed[definitionsKey] = {\n ...(closed[definitionsKey] as Record<string, unknown>),\n ...definitions,\n };\n }\n return closed as JsonSchema;\n}\n\nfunction isSchemaRecord(value: unknown): value is JsonSchema {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction strictSchemaNode(\n schema: JsonSchema,\n nested: boolean,\n operand: boolean,\n): JsonSchema {\n const { $ref, additionalProperties, allOf, anyOf, oneOf, properties } =\n schema;\n const hasConditional = \"if\" in schema && schema.if !== undefined;\n const hasComposition = Boolean(\n $ref || allOf || anyOf || oneOf || hasConditional,\n );\n const isObjectSchema = nested\n ? schema.type === \"object\"\n : schema.type === undefined || schema.type === \"object\";\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 closesNode =\n !operand && !hasComposition && isObjectSchema && !keepsAdditionalProperties;\n\n const next: Record<string, unknown> = {\n ...schema,\n ...(closesNode ? { additionalProperties: false } : {}),\n };\n\n if (properties) {\n next.properties = Object.fromEntries(\n Object.entries(properties).map(([key, value]) => [\n key,\n isSchemaRecord(value) ? strictSchemaNode(value, true, false) : value,\n ]),\n );\n }\n\n for (const keyword of [\"allOf\", \"anyOf\", \"oneOf\"] as const) {\n const branches = (schema as Record<string, unknown>)[keyword];\n if (Array.isArray(branches)) {\n next[keyword] = branches.map((branch) =>\n isSchemaRecord(branch) ? strictSchemaNode(branch, true, true) : branch,\n );\n }\n }\n\n for (const keyword of [\"else\", \"then\"] as const) {\n const branch = (schema as Record<string, unknown>)[keyword];\n if (isSchemaRecord(branch)) {\n next[keyword] = strictSchemaNode(branch, true, true);\n }\n }\n\n return next as JsonSchema;\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  cancelResponseBody
3
- } from "./chunk-76OY4FEK.js";
3
+ } from "./chunk-UFPH23EN.js";
4
4
  import {
5
5
  objectRootSchema,
6
6
  strictInputSchema,
7
7
  zodInputSchema
8
- } from "./chunk-AM3HVK4Z.js";
8
+ } from "./chunk-B2QUCZGV.js";
9
9
 
10
10
  // src/FastMCP.ts
11
11
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -1191,7 +1191,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1191
1191
  return () => {
1192
1192
  };
1193
1193
  }
1194
- const intervalMs = config.intervalMs && config.intervalMs > 0 ? config.intervalMs : STREAM_KEEPALIVE_DEFAULT_INTERVAL_MS;
1194
+ const intervalMs = config.intervalMs && config.intervalMs >= 1 ? config.intervalMs : STREAM_KEEPALIVE_DEFAULT_INTERVAL_MS;
1195
1195
  const timer = setInterval(() => {
1196
1196
  extra.sendNotification({
1197
1197
  method: "notifications/message",
@@ -1651,7 +1651,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1651
1651
  tools: cachedToolsList
1652
1652
  };
1653
1653
  }
1654
- cachedToolsList = await Promise.all(
1654
+ const listedTools = await Promise.all(
1655
1655
  tools.map(async (tool) => {
1656
1656
  let inputSchema;
1657
1657
  try {
@@ -1669,6 +1669,12 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1669
1669
  );
1670
1670
  inputSchema = { type: "object" };
1671
1671
  }
1672
+ if (inputSchema.type !== "object") {
1673
+ this.#logger.warn(
1674
+ `[FastMCP warning] Tool '${tool.name}' parameters must describe an object. Omitting the tool from tools/list.`
1675
+ );
1676
+ return void 0;
1677
+ }
1672
1678
  let outputSchema;
1673
1679
  if (tool.outputSchema) {
1674
1680
  try {
@@ -1681,18 +1687,27 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1681
1687
  error
1682
1688
  );
1683
1689
  }
1690
+ if (outputSchema && outputSchema.type !== "object") {
1691
+ this.#logger.warn(
1692
+ `[FastMCP warning] Tool '${tool.name}' outputSchema must describe an object. Omitting the tool from tools/list.`
1693
+ );
1694
+ return void 0;
1695
+ }
1684
1696
  }
1685
1697
  return {
1686
1698
  annotations: tool.annotations,
1687
1699
  description: tool.description,
1688
1700
  inputSchema,
1689
1701
  name: tool.name,
1690
- ...outputSchema && { outputSchema },
1702
+ ...outputSchema && {
1703
+ outputSchema
1704
+ },
1691
1705
  // Pass through _meta for MCP ext-apps UI support (issue #229)
1692
1706
  ...tool._meta && { _meta: tool._meta }
1693
1707
  };
1694
1708
  })
1695
1709
  );
1710
+ cachedToolsList = listedTools.filter((tool) => tool !== void 0);
1696
1711
  return {
1697
1712
  tools: cachedToolsList
1698
1713
  };
@@ -1763,9 +1778,10 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1763
1778
  }
1764
1779
  }
1765
1780
  };
1781
+ let toolSettled = false;
1766
1782
  try {
1767
1783
  const reportProgress = async (progress) => {
1768
- if (progressToken === void 0) {
1784
+ if (toolSettled || progressToken === void 0) {
1769
1785
  return;
1770
1786
  }
1771
1787
  try {
@@ -1788,6 +1804,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1788
1804
  };
1789
1805
  const log = this.#createLog(sendNotification);
1790
1806
  const streamContent = async (content) => {
1807
+ if (toolSettled) {
1808
+ return;
1809
+ }
1791
1810
  const contentArray = Array.isArray(content) ? content : [content];
1792
1811
  try {
1793
1812
  await sendNotification({
@@ -1856,6 +1875,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1856
1875
  executeToolPromise,
1857
1876
  aborted
1858
1877
  ]).finally(() => {
1878
+ toolSettled = true;
1859
1879
  clearTimeout(timeoutId);
1860
1880
  stopWaitingForAbort();
1861
1881
  stopStreamKeepalive();
@@ -1906,6 +1926,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1906
1926
  );
1907
1927
  }
1908
1928
  } catch (error) {
1929
+ toolSettled = true;
1909
1930
  if (error instanceof UserError) {
1910
1931
  let structuredContent = error.extras;
1911
1932
  if (structuredContent && tool.outputSchema) {
@@ -3706,4 +3727,4 @@ export {
3706
3727
  FastMCPSession,
3707
3728
  FastMCP
3708
3729
  };
3709
- //# sourceMappingURL=chunk-MBIVAKUB.js.map
3730
+ //# sourceMappingURL=chunk-Q57EM4LH.js.map