fastmcp 4.30.1 → 4.30.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 (39) 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-C2Z93xC5.d.cts → OAuthProvider-BuBMMpsX.d.cts} +18 -2
  6. package/dist/{OAuthProvider-C2Z93xC5.d.ts → OAuthProvider-BuBMMpsX.d.ts} +18 -2
  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/{chunk-CZGQ2WTQ.cjs → chunk-F7XD3S4L.cjs} +54 -7
  12. package/dist/chunk-F7XD3S4L.cjs.map +1 -0
  13. package/dist/{chunk-4JEDH2ON.cjs → chunk-M3SNOHIM.cjs} +156 -85
  14. package/dist/chunk-M3SNOHIM.cjs.map +1 -0
  15. package/dist/{chunk-FBDPX4H2.cjs → chunk-NYV5TK43.cjs} +125 -2
  16. package/dist/chunk-NYV5TK43.cjs.map +1 -0
  17. package/dist/{chunk-XPTUOWUT.js → chunk-P4ZFER5I.js} +50 -3
  18. package/dist/chunk-P4ZFER5I.js.map +1 -0
  19. package/dist/{chunk-5KA6SOWT.js → chunk-UEEX3RD5.js} +109 -38
  20. package/dist/chunk-UEEX3RD5.js.map +1 -0
  21. package/dist/{chunk-JCKJRUCE.js → chunk-YEXAT4PO.js} +125 -2
  22. package/dist/chunk-YEXAT4PO.js.map +1 -0
  23. package/dist/edge/index.cjs +4 -4
  24. package/dist/edge/index.js +1 -1
  25. package/dist/examples/custom-routes.cjs +4 -4
  26. package/dist/examples/custom-routes.js +3 -3
  27. package/dist/openapi/index.cjs +15 -12
  28. package/dist/openapi/index.cjs.map +1 -1
  29. package/dist/openapi/index.d.cts +4 -3
  30. package/dist/openapi/index.d.ts +4 -3
  31. package/dist/openapi/index.js +9 -6
  32. package/dist/openapi/index.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-4JEDH2ON.cjs.map +0 -1
  35. package/dist/chunk-5KA6SOWT.js.map +0 -1
  36. package/dist/chunk-CZGQ2WTQ.cjs.map +0 -1
  37. package/dist/chunk-FBDPX4H2.cjs.map +0 -1
  38. package/dist/chunk-JCKJRUCE.js.map +0 -1
  39. package/dist/chunk-XPTUOWUT.js.map +0 -1
@@ -95,9 +95,131 @@ function zodInputSchema(schema, target) {
95
95
  }
96
96
  return closed;
97
97
  }
98
+ function zodOutputSchema(schema, target) {
99
+ const jsonSchema = z.toJSONSchema(schema, {
100
+ io: "output",
101
+ target
102
+ });
103
+ return flattenClosedIntersections(jsonSchema);
104
+ }
105
+ function flattenClosedIntersections(node) {
106
+ const next = { ...node };
107
+ for (const keyword of ["allOf", "anyOf", "oneOf"]) {
108
+ const branches = next[keyword];
109
+ if (Array.isArray(branches)) {
110
+ next[keyword] = branches.map(
111
+ (branch) => isSchemaRecord(branch) ? flattenClosedIntersections(branch) : branch
112
+ );
113
+ }
114
+ }
115
+ for (const keyword of [
116
+ "$defs",
117
+ "definitions",
118
+ "patternProperties",
119
+ "properties"
120
+ ]) {
121
+ const children = next[keyword];
122
+ if (isSchemaRecord(children)) {
123
+ next[keyword] = Object.fromEntries(
124
+ Object.entries(children).map(
125
+ ([key, child]) => [
126
+ key,
127
+ isSchemaRecord(child) ? flattenClosedIntersections(child) : child
128
+ ]
129
+ )
130
+ );
131
+ }
132
+ }
133
+ for (const keyword of [
134
+ "additionalItems",
135
+ "additionalProperties",
136
+ "contains",
137
+ "else",
138
+ "if",
139
+ "items",
140
+ "not",
141
+ "prefixItems",
142
+ "propertyNames",
143
+ "then"
144
+ ]) {
145
+ const child = next[keyword];
146
+ if (Array.isArray(child)) {
147
+ next[keyword] = child.map(
148
+ (item) => isSchemaRecord(item) ? flattenClosedIntersections(item) : item
149
+ );
150
+ } else if (isSchemaRecord(child)) {
151
+ next[keyword] = flattenClosedIntersections(
152
+ child
153
+ );
154
+ }
155
+ }
156
+ return mergeClosedOperands(next);
157
+ }
158
+ function intersectSchema(left, right) {
159
+ if (JSON.stringify(left) === JSON.stringify(right)) return left;
160
+ if (isSchemaRecord(left) && isSchemaRecord(right)) {
161
+ return flattenClosedIntersections({
162
+ allOf: [left, right]
163
+ });
164
+ }
165
+ return { allOf: [left, right] };
166
+ }
98
167
  function isSchemaRecord(value) {
99
168
  return typeof value === "object" && value !== null && !Array.isArray(value);
100
169
  }
170
+ function mergeClosedOperands(node) {
171
+ const branches = node.allOf;
172
+ if (!Array.isArray(branches) || branches.length < 2)
173
+ return node;
174
+ for (const keyword of [
175
+ "additionalProperties",
176
+ "anyOf",
177
+ "if",
178
+ "oneOf",
179
+ "patternProperties",
180
+ "properties",
181
+ "required",
182
+ "$ref"
183
+ ]) {
184
+ if (keyword in node) return node;
185
+ }
186
+ const properties = {};
187
+ const required = [];
188
+ let closes = false;
189
+ for (const branch of branches) {
190
+ if (!isSchemaRecord(branch) || branch.type !== "object" || "$ref" in branch || "allOf" in branch || "anyOf" in branch || "if" in branch || "oneOf" in branch || branch.patternProperties !== void 0) {
191
+ return node;
192
+ }
193
+ const additionalProperties = branch.additionalProperties;
194
+ if (additionalProperties !== false && additionalProperties !== void 0) {
195
+ return node;
196
+ }
197
+ if (additionalProperties === false) closes = true;
198
+ const branchProperties = branch.properties;
199
+ if (branchProperties !== void 0 && !isSchemaRecord(branchProperties)) {
200
+ return node;
201
+ }
202
+ for (const [key, value] of Object.entries(
203
+ branchProperties ?? {}
204
+ )) {
205
+ const existing = properties[key];
206
+ properties[key] = existing === void 0 ? value : intersectSchema(existing, value);
207
+ }
208
+ for (const key of Array.isArray(branch.required) ? branch.required : []) {
209
+ if (typeof key === "string" && !required.includes(key))
210
+ required.push(key);
211
+ }
212
+ }
213
+ const rest = { ...node };
214
+ delete rest.allOf;
215
+ return {
216
+ ...rest,
217
+ ...required.length > 0 ? { required } : {},
218
+ ...closes ? { additionalProperties: false } : {},
219
+ properties,
220
+ type: "object"
221
+ };
222
+ }
101
223
  function strictSchemaNode(schema, nested, operand, preserve = false) {
102
224
  const { $ref, additionalProperties, allOf, anyOf, oneOf, properties } = schema;
103
225
  const hasConditional = "if" in schema && schema.if !== void 0;
@@ -166,6 +288,7 @@ function strictSchemaNode(schema, nested, operand, preserve = false) {
166
288
  export {
167
289
  objectRootSchema,
168
290
  strictInputSchema,
169
- zodInputSchema
291
+ zodInputSchema,
292
+ zodOutputSchema
170
293
  };
171
- //# sourceMappingURL=chunk-JCKJRUCE.js.map
294
+ //# sourceMappingURL=chunk-YEXAT4PO.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\n/**\n * Converts Zod 4 tool output schemas by what a call returns (`io: \"output\"`),\n * then flattens closed object intersections, because Zod before 4.2 lists the\n * operands of `a.and(b)` as `allOf` branches that each appear closed\n * (`additionalProperties: false`). Every branch then rejects the properties of\n * the other, so the advertised schema cannot be satisfied and the SDK client\n * rejects the server's own structured content with\n * `data must NOT have additional properties`. Zod 4.2 and later flatten the\n * intersection into one closed object instead; this keeps the locked floor\n * (`zod`: `^4.1.13`) advertising what later versions would.\n *\n * Only operand lists made up entirely of plain object branches are flattened.\n * A branch that references a definition, composes further, or opens its\n * additional properties is left as Zod converted it.\n */\nexport function zodOutputSchema(\n schema: z.ZodType,\n target?: \"draft-7\",\n): JsonSchema {\n const jsonSchema = z.toJSONSchema(schema, {\n io: \"output\",\n target,\n }) as Record<string, unknown>;\n\n return flattenClosedIntersections(jsonSchema);\n}\n\n/** Merges the closed object operands of `allOf` into the object they describe. */\nfunction flattenClosedIntersections(node: Record<string, unknown>): JsonSchema {\n const next: Record<string, unknown> = { ...node };\n\n for (const keyword of [\"allOf\", \"anyOf\", \"oneOf\"] as const) {\n const branches = next[keyword];\n if (Array.isArray(branches)) {\n next[keyword] = branches.map((branch) =>\n isSchemaRecord(branch)\n ? flattenClosedIntersections(branch as Record<string, unknown>)\n : branch,\n );\n }\n }\n for (const keyword of [\n \"$defs\",\n \"definitions\",\n \"patternProperties\",\n \"properties\",\n ] as const) {\n const children = next[keyword];\n if (isSchemaRecord(children)) {\n next[keyword] = Object.fromEntries(\n Object.entries(children as Record<string, unknown>).map(\n ([key, child]) => [\n key,\n isSchemaRecord(child)\n ? flattenClosedIntersections(child as Record<string, unknown>)\n : child,\n ],\n ),\n );\n }\n }\n for (const keyword of [\n \"additionalItems\",\n \"additionalProperties\",\n \"contains\",\n \"else\",\n \"if\",\n \"items\",\n \"not\",\n \"prefixItems\",\n \"propertyNames\",\n \"then\",\n ] as const) {\n const child = next[keyword];\n if (Array.isArray(child)) {\n next[keyword] = child.map((item) =>\n isSchemaRecord(item)\n ? flattenClosedIntersections(item as Record<string, unknown>)\n : item,\n );\n } else if (isSchemaRecord(child)) {\n next[keyword] = flattenClosedIntersections(\n child as Record<string, unknown>,\n );\n }\n }\n\n return mergeClosedOperands(next);\n}\n\n/** Keeps both declarations of a property two operands share. */\nfunction intersectSchema(left: unknown, right: unknown): unknown {\n if (JSON.stringify(left) === JSON.stringify(right)) return left;\n if (isSchemaRecord(left) && isSchemaRecord(right)) {\n return flattenClosedIntersections({\n allOf: [left, right],\n } as Record<string, unknown>);\n }\n return { allOf: [left, right] };\n}\n\nfunction isSchemaRecord(value: unknown): value is JsonSchema {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction mergeClosedOperands(node: Record<string, unknown>): JsonSchema {\n const branches = node.allOf;\n if (!Array.isArray(branches) || branches.length < 2)\n return node as JsonSchema;\n // The node itself must describe nothing but the intersection, so that\n // moving the operands' declarations onto it preserves its meaning.\n for (const keyword of [\n \"additionalProperties\",\n \"anyOf\",\n \"if\",\n \"oneOf\",\n \"patternProperties\",\n \"properties\",\n \"required\",\n \"$ref\",\n ]) {\n if (keyword in node) return node as JsonSchema;\n }\n\n const properties: Record<string, unknown> = {};\n const required: string[] = [];\n let closes = false;\n for (const branch of branches) {\n if (\n !isSchemaRecord(branch) ||\n branch.type !== \"object\" ||\n \"$ref\" in branch ||\n \"allOf\" in branch ||\n \"anyOf\" in branch ||\n \"if\" in branch ||\n \"oneOf\" in branch ||\n branch.patternProperties !== undefined\n ) {\n return node as JsonSchema;\n }\n const additionalProperties = branch.additionalProperties;\n if (additionalProperties !== false && additionalProperties !== undefined) {\n return node as JsonSchema;\n }\n if (additionalProperties === false) closes = true;\n const branchProperties = branch.properties;\n if (branchProperties !== undefined && !isSchemaRecord(branchProperties)) {\n return node as JsonSchema;\n }\n for (const [key, value] of Object.entries(\n (branchProperties ?? {}) as Record<string, unknown>,\n )) {\n const existing = properties[key];\n properties[key] =\n existing === undefined ? value : intersectSchema(existing, value);\n }\n for (const key of Array.isArray(branch.required) ? branch.required : []) {\n if (typeof key === \"string\" && !required.includes(key))\n required.push(key);\n }\n }\n\n const rest: Record<string, unknown> = { ...node };\n delete rest.allOf;\n return {\n ...rest,\n ...(required.length > 0 ? { required } : {}),\n ...(closes ? { additionalProperties: false } : {}),\n properties,\n type: \"object\",\n } as JsonSchema;\n}\n\nfunction strictSchemaNode(\n schema: JsonSchema,\n nested: boolean,\n operand: boolean,\n preserve = false,\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 // Child-value positions keep an `additionalProperties` the node declares:\n // a value schema's openness is part of what the collection means, while a\n // property's own openness is normalized like the root's.\n const closesNode =\n !operand &&\n !hasComposition &&\n isObjectSchema &&\n !keepsAdditionalProperties &&\n (!preserve || additionalProperties === undefined);\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 // Value positions hold ordinary object occurrences, so their nested objects\n // are closed like any property. Matching positions (`if`, `not`, `contains`,\n // `propertyNames`, `unevaluated*`) stay as declared: closing them would\n // change what the constraint matches. `$defs` and `definitions` are also\n // left alone: a definition may be referenced from a composition operand,\n // which must keep its own `additionalProperties` to accept keys declared by\n // sibling branches.\n for (const keyword of [\"items\", \"additionalItems\", \"prefixItems\"] as const) {\n const child = (schema as Record<string, unknown>)[keyword];\n if (Array.isArray(child)) {\n next[keyword] = child.map((item) =>\n isSchemaRecord(item) ? strictSchemaNode(item, true, false, true) : item,\n );\n } else if (isSchemaRecord(child)) {\n next[keyword] = strictSchemaNode(child, true, false, true);\n }\n }\n\n const patternProperties = (schema as Record<string, unknown>)\n .patternProperties;\n if (isSchemaRecord(patternProperties)) {\n next.patternProperties = Object.fromEntries(\n Object.entries(patternProperties).map(([key, value]) => [\n key,\n isSchemaRecord(value)\n ? strictSchemaNode(value, true, false, true)\n : value,\n ]),\n );\n }\n\n if (isSchemaRecord(next.additionalProperties)) {\n next.additionalProperties = strictSchemaNode(\n next.additionalProperties,\n true,\n false,\n true,\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,WA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AAChC,WAAK,OAAO,IAAI,iBAAiB,OAAO,MAAM,OAAO,IAAI;AAAA,IAC3D;AAAA,EACF;AAEA,QAAM,oBAAqB,OACxB;AACH,MAAI,eAAe,iBAAiB,GAAG;AACrC,SAAK,oBAAoB,OAAO;AAAA,MAC9B,OAAO,QAAQ,iBAAiB,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,QACtD;AAAA,QACA,eAAe,KAAK,IAChB,iBAAiB,OAAO,MAAM,OAAO,IAAI,IACzC;AAAA,MACN,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,eAAe,KAAK,oBAAoB,GAAG;AAC7C,SAAK,uBAAuB;AAAA,MAC1B,KAAK;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;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,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
3
 
4
- var _chunkFBDPX4H2cjs = require('../chunk-FBDPX4H2.cjs');
4
+ var _chunkNYV5TK43cjs = require('../chunk-NYV5TK43.cjs');
5
5
 
6
6
  // src/edge/index.ts
7
7
 
@@ -1378,12 +1378,12 @@ var EdgeFastMCP = class {
1378
1378
  #schemaToJsonSchema(schema) {
1379
1379
  try {
1380
1380
  if (schema["~standard"].vendor === "zod") {
1381
- const jsonSchema = "_zod" in schema ? _chunkFBDPX4H2cjs.zodInputSchema.call(void 0, schema) : _zodtojsonschema.zodToJsonSchema.call(void 0, schema);
1382
- return _chunkFBDPX4H2cjs.strictInputSchema.call(void 0, jsonSchema);
1381
+ const jsonSchema = "_zod" in schema ? _chunkNYV5TK43cjs.zodInputSchema.call(void 0, schema) : _zodtojsonschema.zodToJsonSchema.call(void 0, schema);
1382
+ return _chunkNYV5TK43cjs.strictInputSchema.call(void 0, jsonSchema);
1383
1383
  }
1384
1384
  const standard = schema["~standard"];
1385
1385
  if (standard.jsonSchema) {
1386
- return _chunkFBDPX4H2cjs.strictInputSchema.call(void 0,
1386
+ return _chunkNYV5TK43cjs.strictInputSchema.call(void 0,
1387
1387
  standard.jsonSchema.input({ target: "draft-07" })
1388
1388
  );
1389
1389
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  strictInputSchema,
3
3
  zodInputSchema
4
- } from "../chunk-JCKJRUCE.js";
4
+ } from "../chunk-YEXAT4PO.js";
5
5
 
6
6
  // src/edge/index.ts
7
7
  import {
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- var _chunk4JEDH2ONcjs = require('../chunk-4JEDH2ON.cjs');
5
- require('../chunk-CZGQ2WTQ.cjs');
6
- require('../chunk-FBDPX4H2.cjs');
4
+ var _chunkM3SNOHIMcjs = require('../chunk-M3SNOHIM.cjs');
5
+ require('../chunk-F7XD3S4L.cjs');
6
+ require('../chunk-NYV5TK43.cjs');
7
7
 
8
8
  // src/examples/custom-routes.ts
9
9
  var _zod = require('zod');
@@ -12,7 +12,7 @@ var users = /* @__PURE__ */ new Map([
12
12
  ["2", { email: "bob@example.com", id: "2", name: "Bob" }]
13
13
  ]);
14
14
  var requestCount = 0;
15
- var server = new (0, _chunk4JEDH2ONcjs.FastMCP)({
15
+ var server = new (0, _chunkM3SNOHIMcjs.FastMCP)({
16
16
  // Simple authentication - in production, use proper tokens/JWTs
17
17
  authenticate: async (req) => {
18
18
  const authHeader = req.headers.authorization;
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  FastMCP
4
- } from "../chunk-5KA6SOWT.js";
5
- import "../chunk-XPTUOWUT.js";
6
- import "../chunk-JCKJRUCE.js";
4
+ } from "../chunk-UEEX3RD5.js";
5
+ import "../chunk-P4ZFER5I.js";
6
+ import "../chunk-YEXAT4PO.js";
7
7
 
8
8
  // src/examples/custom-routes.ts
9
9
  import { z } from "zod";
@@ -2,9 +2,9 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk4JEDH2ONcjs = require('../chunk-4JEDH2ON.cjs');
6
- require('../chunk-CZGQ2WTQ.cjs');
7
- require('../chunk-FBDPX4H2.cjs');
5
+ var _chunkM3SNOHIMcjs = require('../chunk-M3SNOHIM.cjs');
6
+ require('../chunk-F7XD3S4L.cjs');
7
+ require('../chunk-NYV5TK43.cjs');
8
8
 
9
9
  // src/openapi/loadSpec.ts
10
10
  var _swaggerparser = require('@apidevtools/swagger-parser'); var _swaggerparser2 = _interopRequireDefault(_swaggerparser);
@@ -131,7 +131,7 @@ function buildSharedDefs(document) {
131
131
  }
132
132
  return rewriteNode(schemas, "schemaMap");
133
133
  }
134
- var SUCCESS_STATUS_PATTERN = /^2\d\d$/;
134
+ var SUCCESS_STATUS_PATTERN = /^2(?:\d\d|XX)$/;
135
135
  var MAX_OUTPUT_SCHEMA_DEFS = 50;
136
136
  function buildOutputSchema(route, sharedDefs) {
137
137
  if (route.method === "head") {
@@ -563,6 +563,9 @@ function resolveBaseUrl(servers, origin, overrideUrl) {
563
563
  }
564
564
  const server = _optionalChain([servers, 'optionalAccess', _29 => _29[0]]);
565
565
  if (!server) {
566
+ if (origin) {
567
+ return new URL("/", origin).toString().replace(/\/$/, "");
568
+ }
566
569
  throw new Error(
567
570
  "The OpenAPI document has no `servers` entry. Pass `baseUrl` to fromOpenAPI() explicitly."
568
571
  );
@@ -645,7 +648,7 @@ function assertNoSubstitutedDotSegments(route, resolvedPath) {
645
648
  const templateSegments = new Set(route.path.split("/"));
646
649
  for (const segment of resolvedPath.split("/")) {
647
650
  if ((segment === "." || segment === "..") && !templateSegments.has(segment)) {
648
- throw new (0, _chunk4JEDH2ONcjs.UserError)(
651
+ throw new (0, _chunkM3SNOHIMcjs.UserError)(
649
652
  `${route.method.toUpperCase()} ${route.path}: path parameter values must not produce a "${segment}" path segment.`
650
653
  );
651
654
  }
@@ -658,7 +661,7 @@ function encodeCookieValue(mapping, value) {
658
661
  return encodePathComponent(text);
659
662
  }
660
663
  if (/[;,]/.test(text)) {
661
- throw new (0, _chunk4JEDH2ONcjs.UserError)(
664
+ throw new (0, _chunkM3SNOHIMcjs.UserError)(
662
665
  `Cookie parameter "${mapping.name}" uses style "cookie" and its value contains ";" or ","`
663
666
  );
664
667
  }
@@ -671,10 +674,10 @@ function encodeFormBody(payload) {
671
674
  for (const [key, value] of Object.entries(
672
675
  payload
673
676
  )) {
674
- if (value === void 0) {
677
+ if (value === void 0 || value === null) {
675
678
  continue;
676
679
  }
677
- appendBracketPairs(params, key, value);
680
+ appendBracketPairs(params, key, withoutNullMembers(value));
678
681
  }
679
682
  }
680
683
  return params.toString();
@@ -849,7 +852,7 @@ async function fetchResponse(options) {
849
852
  });
850
853
  if (!response.ok) {
851
854
  const text = await response.text();
852
- throw new (0, _chunk4JEDH2ONcjs.UserError)(
855
+ throw new (0, _chunkM3SNOHIMcjs.UserError)(
853
856
  `${options.route.method.toUpperCase()} ${path} failed with ${response.status}: ${text.slice(0, 2e3)}`
854
857
  );
855
858
  }
@@ -1112,7 +1115,7 @@ async function fromOpenAPI(options) {
1112
1115
  const selected = selectRoutes(routes, options);
1113
1116
  const names = generateNames(selected, options.mcpNames);
1114
1117
  const sharedDefs = buildSharedDefs(document);
1115
- const server = _nullishCoalesce(options.server, () => ( new (0, _chunk4JEDH2ONcjs.FastMCP)({
1118
+ const server = _nullishCoalesce(options.server, () => ( new (0, _chunkM3SNOHIMcjs.FastMCP)({
1116
1119
  name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access', _45 => _45.info, 'optionalAccess', _46 => _46.title]))), () => ( "OpenAPI Server")),
1117
1120
  version: _nullishCoalesce(options.version, () => ( "1.0.0"))
1118
1121
  })));
@@ -1158,7 +1161,7 @@ async function fromOpenAPI(options) {
1158
1161
  continue;
1159
1162
  }
1160
1163
  const outputSchemaJson = buildOutputSchema(route, sharedDefs);
1161
- const outputSchema = outputSchemaJson ? _chunk4JEDH2ONcjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
1164
+ const outputSchema = outputSchemaJson ? _chunkM3SNOHIMcjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
1162
1165
  server.addTool({
1163
1166
  description: _nullishCoalesce(route.summary, () => ( `${route.method.toUpperCase()} ${route.path}`)),
1164
1167
  execute: async (args, context) => {
@@ -1173,7 +1176,7 @@ async function fromOpenAPI(options) {
1173
1176
  return resolveToolResult(result, outputSchema);
1174
1177
  },
1175
1178
  name,
1176
- parameters: _chunk4JEDH2ONcjs.jsonSchemaAdapter.call(void 0, flatSchema),
1179
+ parameters: _chunkM3SNOHIMcjs.jsonSchemaAdapter.call(void 0, flatSchema),
1177
1180
  ...outputSchema ? { outputSchema } : {}
1178
1181
  });
1179
1182
  }