fastmcp 4.28.2 → 4.28.3

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 (43) 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-D9JYSSem.d.cts} +1 -0
  6. package/dist/{OAuthProvider-DvIxa9N1.d.ts → OAuthProvider-D9JYSSem.d.ts} +1 -0
  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-76OY4FEK.js → chunk-2RLFFOY2.js} +32 -15
  16. package/dist/chunk-2RLFFOY2.js.map +1 -0
  17. package/dist/{chunk-HZJE6ZGH.cjs → chunk-A2TZVOOY.cjs} +36 -19
  18. package/dist/chunk-A2TZVOOY.cjs.map +1 -0
  19. package/dist/{chunk-AM3HVK4Z.js → chunk-B2QUCZGV.js} +42 -18
  20. package/dist/chunk-B2QUCZGV.js.map +1 -0
  21. package/dist/{chunk-MBIVAKUB.js → chunk-GAPP6V64.js} +11 -5
  22. package/dist/chunk-GAPP6V64.js.map +1 -0
  23. package/dist/{chunk-2NZFMD6I.cjs → chunk-OCCYKYIM.cjs} +42 -18
  24. package/dist/chunk-OCCYKYIM.cjs.map +1 -0
  25. package/dist/{chunk-GW5MENCI.cjs → chunk-SQS3SIW7.cjs} +17 -11
  26. package/dist/chunk-SQS3SIW7.cjs.map +1 -0
  27. package/dist/edge/index.cjs +3 -3
  28. package/dist/edge/index.js +1 -1
  29. package/dist/examples/custom-routes.cjs +4 -4
  30. package/dist/examples/custom-routes.js +3 -3
  31. package/dist/openapi/index.cjs +23 -12
  32. package/dist/openapi/index.cjs.map +1 -1
  33. package/dist/openapi/index.d.cts +1 -1
  34. package/dist/openapi/index.d.ts +1 -1
  35. package/dist/openapi/index.js +17 -6
  36. package/dist/openapi/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-2NZFMD6I.cjs.map +0 -1
  39. package/dist/chunk-76OY4FEK.js.map +0 -1
  40. package/dist/chunk-AM3HVK4Z.js.map +0 -1
  41. package/dist/chunk-GW5MENCI.cjs.map +0 -1
  42. package/dist/chunk-HZJE6ZGH.cjs.map +0 -1
  43. 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(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(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
  export {
116
140
  objectRootSchema,
117
141
  strictInputSchema,
118
142
  zodInputSchema
119
143
  };
120
- //# sourceMappingURL=chunk-AM3HVK4Z.js.map
144
+ //# sourceMappingURL=chunk-B2QUCZGV.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. 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"],"mappings":";AAEA,SAAS,SAAS;AAUX,SAAS,iBAAiB,QAAgC;AAC/D,SAAO,OAAO,SAAS,SAAY,EAAE,GAAG,QAAQ,MAAM,SAAS,IAAI;AACrE;AA8BO,SAAS,kBACd,QACA,SAAS,OACG;AACZ,QAAM,SAAS,iBAAiB,QAAQ,QAAQ,KAAK;AACrD,SAAO,SAAS,SAAS,iBAAiB,MAAM;AAClD;AASO,SAAS,eACd,QACA,QACY;AACZ,QAAM,aAAa,EAAE,aAAa,QAAQ;AAAA,IACxC,IAAI;AAAA,IACJ;AAAA,EACF,CAAC;AACD,QAAM,iBAAiB,WAAW,YAAY,gBAAgB;AAC9D,QAAM,cAAuC,CAAC;AAC9C,QAAM,WAAW,oBAAI,IAAoB;AAEzC,QAAM,eAAe,CAAC,OAAgB,UAAU,UAAmB;AACjE,QAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,UAAM,SAAS,EAAE,GAAI,MAAkC;AAEvD,QACE,WACA,OAAO,OAAO,SAAS,aACtB,OAAO,SAAS,OAAO,OAAO,KAAK,WAAW,IAAI,IACnD;AACA,YAAM,YAAY,OAAO;AACzB,UAAI,OAAO,SAAS,IAAI,SAAS;AACjC,UAAI,CAAC,MAAM;AACT,cAAM,OAAO,mBAAmB,UAAU,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,MAAM,CAAC;AACtE,cAAM,aAAa,KAAK;AAAA,UACtB,CAAC,MAAM,QACL,QAAQ,OAAO,SAAS,WACnB,KACC,IAAI,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,CAC5C,IACA;AAAA,UACN;AAAA,QACF;AACA,YAAI,cAAc,OAAO,eAAe,UAAU;AAChD,iBAAO,qBAAqB,SA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jE,CAAC;AAAA,IACH;AAAA,EACF;AAEA,aAAW,WAAW,CAAC,SAAS,SAAS,OAAO,GAAY;AAC1D,UAAM,WAAY,OAAmC,OAAO;AAC5D,QAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,WAAK,OAAO,IAAI,SAAS;AAAA,QAAI,CAAC,WAC5B,eAAe,MAAM,IAAI,iBAAiB,QAAQ,MAAM,IAAI,IAAI;AAAA,MAClE;AAAA,IACF;AAAA,EACF;AAEA,aAAW,WAAW,CAAC,QAAQ,MAAM,GAAY;AAC/C,UAAM,SAAU,OAAmC,OAAO;AAC1D,QAAI,eAAe,MAAM,GAAG;AAC1B,WAAK,OAAO,IAAI,iBAAiB,QAAQ,MAAM,IAAI;AAAA,IACrD;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  cancelResponseBody
3
- } from "./chunk-76OY4FEK.js";
3
+ } from "./chunk-2RLFFOY2.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",
@@ -1763,9 +1763,10 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1763
1763
  }
1764
1764
  }
1765
1765
  };
1766
+ let toolSettled = false;
1766
1767
  try {
1767
1768
  const reportProgress = async (progress) => {
1768
- if (progressToken === void 0) {
1769
+ if (toolSettled || progressToken === void 0) {
1769
1770
  return;
1770
1771
  }
1771
1772
  try {
@@ -1788,6 +1789,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1788
1789
  };
1789
1790
  const log = this.#createLog(sendNotification);
1790
1791
  const streamContent = async (content) => {
1792
+ if (toolSettled) {
1793
+ return;
1794
+ }
1791
1795
  const contentArray = Array.isArray(content) ? content : [content];
1792
1796
  try {
1793
1797
  await sendNotification({
@@ -1856,6 +1860,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1856
1860
  executeToolPromise,
1857
1861
  aborted
1858
1862
  ]).finally(() => {
1863
+ toolSettled = true;
1859
1864
  clearTimeout(timeoutId);
1860
1865
  stopWaitingForAbort();
1861
1866
  stopStreamKeepalive();
@@ -1906,6 +1911,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
1906
1911
  );
1907
1912
  }
1908
1913
  } catch (error) {
1914
+ toolSettled = true;
1909
1915
  if (error instanceof UserError) {
1910
1916
  let structuredContent = error.extras;
1911
1917
  if (structuredContent && tool.outputSchema) {
@@ -3706,4 +3712,4 @@ export {
3706
3712
  FastMCPSession,
3707
3713
  FastMCP
3708
3714
  };
3709
- //# sourceMappingURL=chunk-MBIVAKUB.js.map
3715
+ //# sourceMappingURL=chunk-GAPP6V64.js.map