@vitemcp/server 1.9.11 → 1.9.12

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.
@@ -66,6 +66,11 @@ var isPlain = (value) => {
66
66
  };
67
67
 
68
68
  // src/toSdkSchema.ts
69
+ var SDK_TARGET = "draft-2020-12";
70
+ var LENIENT_OPTIONS = /* @__PURE__ */ new Map([
71
+ ["arktype", { fallback: (context) => context.base }],
72
+ ["zod", { unrepresentable: "any" }]
73
+ ]);
69
74
  var toSdkSchema = async (schema, io, convert) => {
70
75
  if (!schema) {
71
76
  return void 0;
@@ -74,16 +79,17 @@ var toSdkSchema = async (schema, io, convert) => {
74
79
  schema["~standard"]
75
80
  );
76
81
  if (standard.jsonSchema) {
77
- return { "~standard": standard };
82
+ const { json: json2, lenient } = nativeJsonSchema(
83
+ standard.jsonSchema,
84
+ standard.vendor,
85
+ io
86
+ );
87
+ assertDescribesArguments(json2, io);
88
+ return lenient ? advertising(standard, json2) : { "~standard": standard };
78
89
  }
79
90
  const json = await convert(schema, io);
80
- const advertised = io === "input" ? strictInputSchema(json) : json;
81
- return {
82
- "~standard": {
83
- ...standard,
84
- jsonSchema: { input: () => advertised, output: () => advertised }
85
- }
86
- };
91
+ assertDescribesArguments(json, io);
92
+ return advertising(standard, io === "input" ? strictInputSchema(json) : json);
87
93
  };
88
94
  var valibotToJsonSchema = async (schema, io) => {
89
95
  let converter;
@@ -99,6 +105,35 @@ var valibotToJsonSchema = async (schema, io) => {
99
105
  typeMode: io
100
106
  });
101
107
  };
108
+ var advertising = (standard, advertised) => ({
109
+ "~standard": {
110
+ ...standard,
111
+ jsonSchema: { input: () => advertised, output: () => advertised }
112
+ }
113
+ });
114
+ var assertDescribesArguments = (json, io) => {
115
+ if (io === "input" && json.type !== void 0 && json.type !== "object") {
116
+ throw new Error(
117
+ `A tool's arguments are an object, and this schema describes ${JSON.stringify(
118
+ json.type
119
+ )}. Wrap it in an object schema.`
120
+ );
121
+ }
122
+ };
123
+ var nativeJsonSchema = (native, vendor, io) => {
124
+ try {
125
+ return { json: native[io]({ target: SDK_TARGET }), lenient: false };
126
+ } catch (error) {
127
+ const libraryOptions = LENIENT_OPTIONS.get(vendor);
128
+ if (!libraryOptions) {
129
+ throw error;
130
+ }
131
+ return {
132
+ json: native[io]({ libraryOptions, target: SDK_TARGET }),
133
+ lenient: true
134
+ };
135
+ }
136
+ };
102
137
  var strictInputSchema = (schema) => ({
103
138
  ...schema,
104
139
  ...!(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.allOf, () => ( schema.anyOf)), () => ( schema.oneOf)), () => ( schema.$ref))) && {
@@ -120,4 +155,4 @@ var strictInputSchema = (schema) => ({
120
155
 
121
156
 
122
157
  exports.formatBytes = formatBytes; exports.ownKeysOnly = ownKeysOnly; exports.toSdkSchema = toSdkSchema; exports.valibotToJsonSchema = valibotToJsonSchema;
123
- //# sourceMappingURL=chunk-DURXYPPR.cjs.map
158
+ //# sourceMappingURL=chunk-QPVEGWOL.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/server/server/dist/chunk-QPVEGWOL.cjs","../src/formatBytes.ts","../src/ownKeysOnly.ts","../src/toSdkSchema.ts"],"names":[],"mappings":"AAAA;ACCO,IAAM,YAAA,EAAc,CAAC,KAAA,EAAA,GAA0B;AACpD,EAAA,GAAA,CAAI,MAAA,GAAS,KAAA,EAAO,KAAA,GAAQ,MAAA,EAAA,CAAS,KAAA,EAAO,IAAA,EAAA,IAAU,CAAA,EAAG;AACvD,IAAA,OAAO,CAAA,EAAA;AACT,EAAA;AAEI,EAAA;AACK,IAAA;AACT,EAAA;AAEU,EAAA;AACZ;ADDY;AACA;AEMC;AACL,EAAA;AAEC,EAAA;AACE,IAAA;AACF,MAAA;AACH,MAAA;AACF,IAAA;AACD,EAAA;AACH;AAkBa;AAGR,EAAA;AACO,EAAA;AACF,IAAA;AACA,IAAA;AAED,IAAA;AACH,MAAA;AACF,IAAA;AAEO,IAAA;AACT,EAAA;AACF;AAQM;AAIC,EAAA;AACI,IAAA;AACT,EAAA;AAEM,EAAA;AAEF,EAAA;AACK,IAAA;AACT,EAAA;AAEM,EAAA;AAIC,EAAA;AAEP,EAAA;AACU,IAAA;AACV,EAAA;AAEO,EAAA;AACT;AAMM;AAKC,EAAA;AACH,IAAA;AACF,EAAA;AAES,EAAA;AAEL,EAAA;AACK,IAAA;AACT,EAAA;AAEA,EAAA;AACE,IAAA;AACF,EAAA;AACF;AAMM;AACA,EAAA;AACK,IAAA;AACT,EAAA;AAEM,EAAA;AAGJ,EAAA;AAEJ;AFjEY;AACA;AGvCN;AAWA;AACH,EAAA;AACS,EAAA;AACX;AA8BY;AAKN,EAAA;AACI,IAAA;AACT,EAAA;AAEM,EAAA;AAOF,IAAA;AACJ,EAAA;AAEI,EAAA;AACM,IAAA;AACN,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AAEA,IAAA;AAEO,IAAA;AACT,EAAA;AAEM,EAAA;AAEN,EAAA;AAEO,EAAA;AACT;AAgBa;AACP,EAAA;AAEA,EAAA;AACF,IAAA;AACM,EAAA;AACA,IAAA;AACJ,MAAA;AAEF,IAAA;AACF,EAAA;AAEO,EAAA;AACL,IAAA;AACA,IAAA;AACD,EAAA;AACH;AAGM;AAIJ,EAAA;AACK,IAAA;AACH,IAAA;AACF,EAAA;AACF;AAQM;AAIA,EAAA;AACI,IAAA;AACJ,MAAA;AACE,QAAA;AACD,MAAA;AACH,IAAA;AACF,EAAA;AACF;AAMM;AAKA,EAAA;AACK,IAAA;AACA,EAAA;AACD,IAAA;AAED,IAAA;AACG,MAAA;AACR,IAAA;AAEO,IAAA;AACC,MAAA;AACN,MAAA;AACF,IAAA;AACF,EAAA;AACF;AAeM;AACD,EAAA;AACG,EAAA;AACJ,IAAA;AAIF,EAAA;AACW,EAAA;AACT,IAAA;AACE,MAAA;AACE,QAAA;AACA,QAAA;AAGD,MAAA;AACH,IAAA;AACF,EAAA;AACF;AH9EY;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/server/server/dist/chunk-QPVEGWOL.cjs","sourcesContent":[null,"/** Renders a byte cap the way the error message should read (e.g. \"1 MiB\"). */\nexport const formatBytes = (bytes: number): string => {\n if (bytes >= 1024 * 1024 && bytes % (1024 * 1024) === 0) {\n return `${bytes / (1024 * 1024)} MiB`;\n }\n\n if (bytes >= 1024 && bytes % 1024 === 0) {\n return `${bytes / 1024} KiB`;\n }\n\n return `${bytes} bytes`;\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/**\n * Has `schema` validate by own keys only — see `withOwnKeysOnly` — by\n * replacing its `~standard` in place. The schema keeps its `shape`, which the\n * SDK reads to complete an argument, and its JSON Schema, which `prompts/list`\n * is built from.\n *\n * For the argument schemas `ViteMCP` and `EdgeViteMCP` build for their\n * prompts. A tool's schemas belong to whoever wrote the tool, so\n * `toSdkSchema` wraps them instead.\n *\n * An argument map the request left out validates as an empty one, as the SDK\n * already arranges for a tool's. `prompts/get` may omit `arguments`, and the\n * SDK validates the map as it was sent, so a prompt whose arguments are all\n * optional refused the request as \"expected object, received undefined\".\n */\nexport const ownKeysOnly = <S extends StandardSchemaV1>(schema: S): S => {\n const standard = withOwnKeysOnly(schema[\"~standard\"]);\n\n return Object.defineProperty(schema, \"~standard\", {\n value: {\n ...standard,\n validate: (value: unknown) => standard.validate(value ?? {}),\n },\n });\n};\n\n/**\n * `standard`, with a `validate` that sees only the keys an object has of its\n * own.\n *\n * Zod and Valibot look each key up with `in` and read it with `[]`, and both\n * walk the prototype chain, so a key that was left out reads as present when\n * `Object.prototype` has a member by that name. An optional argument called\n * `toString`, `constructor` or `valueOf`, at any depth, failed every request\n * that left it out, as \"expected string, received function\", and a required\n * one was reported as the wrong type instead of as missing. Validating a copy\n * whose objects have no prototype leaves the library nothing to inherit.\n *\n * A library that hands its input back, as ArkType and `jsonSchemaAdapter` do,\n * hands back the copy, so the copied objects get their prototype back before\n * the value goes on: `execute` still receives ordinary objects.\n */\nexport const withOwnKeysOnly = <P extends StandardSchemaV1.Props>(\n standard: P,\n): P => ({\n ...standard,\n validate: async (value: unknown) => {\n const copies = new Map<object, object>();\n const result = await standard.validate(withoutPrototypes(value, copies));\n\n if (!result.issues && copies.size > 0) {\n restorePrototypes(result.value, new Set(copies.values()), new Set());\n }\n\n return result;\n },\n});\n\n/**\n * `value`, with each plain object in it, at any depth, copied onto one without\n * a prototype, and each array copied to reach them. `copies` maps every\n * original to its copy, so one that occurs twice, or inside itself, is copied\n * once.\n */\nconst withoutPrototypes = (\n value: unknown,\n copies: Map<object, object>,\n): unknown => {\n if (!isPlain(value)) {\n return value;\n }\n\n const existing = copies.get(value);\n\n if (existing) {\n return existing;\n }\n\n const copy: Record<string, unknown> = Array.isArray(value)\n ? []\n : Object.create(null);\n\n copies.set(value, copy);\n\n for (const [key, item] of Object.entries(value)) {\n copy[key] = withoutPrototypes(item, copies);\n }\n\n return copy;\n};\n\n/**\n * Gives each object copy in `copies` that `value` holds, at any depth,\n * `Object.prototype` back.\n */\nconst restorePrototypes = (\n value: unknown,\n copies: Set<object>,\n seen: Set<object>,\n): void => {\n if (!isPlain(value) || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (copies.has(value) && !Array.isArray(value)) {\n Object.setPrototypeOf(value, Object.prototype);\n }\n\n for (const item of Object.values(value)) {\n restorePrototypes(item, copies, seen);\n }\n};\n\n/**\n * An array, or an object made by a literal or without a prototype: what JSON\n * parses to, and the only kinds of object that are copied.\n */\nconst isPlain = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const prototype: unknown = Object.getPrototypeOf(value);\n\n return (\n Array.isArray(value) || prototype === Object.prototype || prototype === null\n );\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema } from \"xsschema\";\n\nimport { withOwnKeysOnly } from \"./ownKeysOnly.js\";\n\n/**\n * Turns a Standard Schema that carries no JSON Schema into one. Which\n * libraries that can be done for depends on the runtime, so each entry point\n * supplies its own.\n */\nexport type JsonSchemaConverter = (\n schema: StandardSchemaV1,\n io: \"input\" | \"output\",\n) => Promise<JsonSchema>;\n\n/**\n * `~standard.jsonSchema`, as Zod v4 and ArkType implement it. Declared here\n * because `@standard-schema/spec` 1.0 predates it.\n */\ntype NativeJsonSchema = Record<\n \"input\" | \"output\",\n (options: {\n libraryOptions?: Record<string, unknown>;\n target: string;\n }) => JsonSchema\n>;\n\n/** The draft the SDK asks a schema for when `tools/list` describes a tool. */\nconst SDK_TARGET = \"draft-2020-12\";\n\n/**\n * What a library is told so that it leaves open the parts of a schema JSON\n * Schema cannot say, rather than refuse the schema over them. Zod describes\n * such a part as `{}`. ArkType hands over what it had worked out before it\n * reached the part: `{}` for a `Date`, `{ type: \"string\" }` for a string under\n * a `narrow()`.\n *\n * A library not named here is left to refuse, and its tool is not served.\n */\nconst LENIENT_OPTIONS = new Map<string, Record<string, unknown>>([\n [\"arktype\", { fallback: (context: { base: JsonSchema }) => context.base }],\n [\"zod\", { unrepresentable: \"any\" }],\n]);\n\n/**\n * A tool's schema as the SDK registers it: one that validates by own keys only\n * (see `withOwnKeysOnly`) and carries a JSON Schema. The schema itself is left\n * as it was, since whoever wrote it may use it elsewhere.\n *\n * Zod v4 and ArkType emit JSON Schema natively, and theirs is kept; anything\n * else (Valibot, say) is converted, and the conversion is only what\n * `tools/list` advertises. Validation stays with the library the schema was\n * written in: the conversion drops what JSON Schema cannot say — a transform,\n * a `check()` — so validating against it instead would pass `execute`\n * arguments the schema never produced.\n *\n * A native schema is converted here too, once, the way the SDK will for\n * `tools/list`. The SDK converts every tool in the one handler, so a schema\n * its library refused to convert — a `z.date()`, a `z.bigint()`, an ArkType\n * `narrow()` — failed the list for every tool, though each could still be\n * called. One refused is asked for again with what JSON Schema cannot say left\n * open (see `LENIENT_OPTIONS`), which is what Valibot's converter is already\n * told, and that copy is advertised in place of the library's own.\n *\n * Converted inputs are closed with `strictInputSchema`. Outputs are left as\n * converted, since closing them would misdescribe results the schema allows.\n *\n * Shared by `ViteMCP` and `EdgeViteMCP`, so what a tool advertises does not\n * depend on which of them serves it. Rejects when `convert` does, when a\n * library refuses a schema even leniently, and for an input schema that does\n * not describe an object: each caller leaves that tool out and serves the rest.\n */\nexport const toSdkSchema = async (\n schema: unknown,\n io: \"input\" | \"output\",\n convert: JsonSchemaConverter,\n): Promise<unknown> => {\n if (!schema) {\n return undefined;\n }\n\n const standard = withOwnKeysOnly(\n (\n schema as {\n \"~standard\": {\n jsonSchema?: NativeJsonSchema;\n } & StandardSchemaV1.Props;\n }\n )[\"~standard\"],\n );\n\n if (standard.jsonSchema) {\n const { json, lenient } = nativeJsonSchema(\n standard.jsonSchema,\n standard.vendor,\n io,\n );\n\n assertDescribesArguments(json, io);\n\n return lenient ? advertising(standard, json) : { \"~standard\": standard };\n }\n\n const json = await convert(schema as StandardSchemaV1, io);\n\n assertDescribesArguments(json, io);\n\n return advertising(standard, io === \"input\" ? strictInputSchema(json) : json);\n};\n\n/**\n * JSON Schema for a Valibot schema, for advertising.\n *\n * Valibot's converter is called directly so it can be told to skip what JSON\n * Schema cannot express — a transform, a `check()` — rather than refuse the\n * whole schema. Valibot still validates, so the copy only has to describe what\n * a caller sends (`typeMode: \"input\"`, which stops at the first transform) or\n * receives (`\"output\"`).\n *\n * The `import()` has to stay inside the `try`. An edge bundle is built with\n * every import resolved ahead of time, and a bundler fails the build over one\n * it cannot resolve — unless it can see the failure is handled, in which case\n * a server that never touches Valibot builds without the converter installed.\n */\nexport const valibotToJsonSchema: JsonSchemaConverter = async (schema, io) => {\n let converter;\n\n try {\n converter = await import(\"@valibot/to-json-schema\");\n } catch {\n throw new Error(\n 'The \"@valibot/to-json-schema\" package is required to describe Valibot ' +\n \"schemas. Install it with: npm install @valibot/to-json-schema\",\n );\n }\n\n return converter.toJsonSchema(schema as never, {\n errorMode: \"ignore\",\n typeMode: io,\n }) as JsonSchema;\n};\n\n/** `standard`, carrying `advertised` as its JSON Schema, input and output. */\nconst advertising = <P extends StandardSchemaV1.Props>(\n standard: P,\n advertised: JsonSchema,\n) => ({\n \"~standard\": {\n ...standard,\n jsonSchema: { input: () => advertised, output: () => advertised },\n },\n});\n\n/**\n * Refuses an input schema that describes anything but an object. A tool's\n * arguments are always one, and the SDK will not list a schema that says\n * otherwise: `parameters: z.string()` failed `tools/list` for every tool, as an\n * unconvertible schema did.\n */\nconst assertDescribesArguments = (\n json: JsonSchema,\n io: \"input\" | \"output\",\n): void => {\n if (io === \"input\" && json.type !== undefined && json.type !== \"object\") {\n throw new Error(\n `A tool's arguments are an object, and this schema describes ${JSON.stringify(\n json.type,\n )}. Wrap it in an object schema.`,\n );\n }\n};\n\n/**\n * A schema's own JSON Schema, and whether it had to be asked for leniently.\n * Throws what the library does when it refuses the schema either way.\n */\nconst nativeJsonSchema = (\n native: NativeJsonSchema,\n vendor: string,\n io: \"input\" | \"output\",\n): { json: JsonSchema; lenient: boolean } => {\n try {\n return { json: native[io]({ target: SDK_TARGET }), lenient: false };\n } catch (error) {\n const libraryOptions = LENIENT_OPTIONS.get(vendor);\n\n if (!libraryOptions) {\n throw error;\n }\n\n return {\n json: native[io]({ libraryOptions, target: SDK_TARGET }),\n lenient: true,\n };\n }\n};\n\n/**\n * Closes an advertised input schema's objects to undeclared keys, except where\n * the schema describes those keys itself. A record's value schema, or an\n * object's rest schema, arrives as `additionalProperties`; replacing it with\n * `false` would tell clients the tool takes none of those keys, so a\n * `v.record()` argument could only ever be sent as `{}`.\n *\n * Nor is an object closed whose keys are declared elsewhere: in its `allOf`,\n * `anyOf` or `oneOf` branches — a `v.intersect()`, `v.union()` or\n * `v.variant()` — or behind a `$ref`, which is how a `v.lazy()` arrives.\n * `additionalProperties` sees only the `properties` beside it, so closing one\n * refused every key declared elsewhere, and every argument with them.\n */\nconst strictInputSchema = (schema: JsonSchema): JsonSchema => ({\n ...schema,\n ...(!(schema.allOf ?? schema.anyOf ?? schema.oneOf ?? schema.$ref) && {\n additionalProperties:\n typeof schema.additionalProperties === \"object\"\n ? schema.additionalProperties\n : false,\n }),\n ...(schema.properties && {\n properties: Object.fromEntries(\n Object.entries(schema.properties).map(([key, value]) => [\n key,\n typeof value === \"object\" && value.type === \"object\"\n ? strictInputSchema(value)\n : value,\n ]),\n ),\n }),\n});\n"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  withoutTrailingSlash
3
- } from "./chunk-KSEFUQF4.js";
3
+ } from "./chunk-NZ34AKP4.js";
4
4
  import {
5
5
  formatBytes,
6
6
  ownKeysOnly,
7
7
  toSdkSchema,
8
8
  valibotToJsonSchema
9
- } from "./chunk-TYR2KJIV.js";
9
+ } from "./chunk-JMDI672G.js";
10
10
 
11
11
  // src/ViteMCP.ts
12
12
  import {
@@ -1688,4 +1688,4 @@ export {
1688
1688
  ServerState,
1689
1689
  ViteMCP
1690
1690
  };
1691
- //# sourceMappingURL=chunk-IAT55CW3.js.map
1691
+ //# sourceMappingURL=chunk-WBP37JPX.js.map
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkDURXYPPRcjs = require('../chunk-DURXYPPR.cjs');
6
+ var _chunkQPVEGWOLcjs = require('../chunk-QPVEGWOL.cjs');
7
7
 
8
8
  // src/edge/index.ts
9
9
  var _server = require('@modelcontextprotocol/server');
@@ -16,7 +16,7 @@ var convertToJsonSchema = async (schema, io) => {
16
16
  `Schema library "${vendor}" carries no JSON Schema (\`~standard.jsonSchema\`), and EdgeViteMCP converts only Valibot's. Use Zod 4, ArkType or Valibot.`
17
17
  );
18
18
  }
19
- return _chunkDURXYPPRcjs.valibotToJsonSchema.call(void 0, schema, io);
19
+ return _chunkQPVEGWOLcjs.valibotToJsonSchema.call(void 0, schema, io);
20
20
  };
21
21
  var readCappedRequest = async (request, maxBytes) => {
22
22
  if (!request.body) {
@@ -114,7 +114,7 @@ var EdgeViteMCP = class {
114
114
  }
115
115
  if (!capped) {
116
116
  return invalidRequest(
117
- `Request body exceeds ${_chunkDURXYPPRcjs.formatBytes.call(void 0, this.#maxBodySize)}`
117
+ `Request body exceeds ${_chunkQPVEGWOLcjs.formatBytes.call(void 0, this.#maxBodySize)}`
118
118
  );
119
119
  }
120
120
  this.#handler ??= _server.createMcpHandler.call(void 0, () => this.#buildServer());
@@ -179,7 +179,7 @@ var EdgeViteMCP = class {
179
179
  for (const arg of _nullishCoalesce(prompt.arguments, () => ( []))) {
180
180
  shape[arg.name] = arg.required ? _zod.z.string() : _zod.z.string().optional();
181
181
  }
182
- const argsSchema = _optionalChain([prompt, 'access', _ => _.arguments, 'optionalAccess', _2 => _2.length]) ? _chunkDURXYPPRcjs.ownKeysOnly.call(void 0, _zod.z.object(shape)) : void 0;
182
+ const argsSchema = _optionalChain([prompt, 'access', _ => _.arguments, 'optionalAccess', _2 => _2.length]) ? _chunkQPVEGWOLcjs.ownKeysOnly.call(void 0, _zod.z.object(shape)) : void 0;
183
183
  const load = async (args) => {
184
184
  const text = await prompt.load(_nullishCoalesce(args, () => ( {})));
185
185
  return {
@@ -209,7 +209,7 @@ var EdgeViteMCP = class {
209
209
  #sdkSchemaFor(tool) {
210
210
  let schema = this.#toolSchemas.get(tool);
211
211
  if (!schema) {
212
- schema = _chunkDURXYPPRcjs.toSdkSchema.call(void 0, tool.parameters, "input", convertToJsonSchema).then(
212
+ schema = _chunkQPVEGWOLcjs.toSdkSchema.call(void 0, tool.parameters, "input", convertToJsonSchema).then(
213
213
  (inputSchema) => ({ inputSchema }),
214
214
  (error) => {
215
215
  this.#logger.error(
@@ -3,7 +3,7 @@ import {
3
3
  ownKeysOnly,
4
4
  toSdkSchema,
5
5
  valibotToJsonSchema
6
- } from "../chunk-TYR2KJIV.js";
6
+ } from "../chunk-JMDI672G.js";
7
7
 
8
8
  // src/edge/index.ts
9
9
  import { createMcpHandler, McpServer } from "@modelcontextprotocol/server";
@@ -3,9 +3,9 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkC2VT2NXCcjs = require('../chunk-C2VT2NXC.cjs');
7
- require('../chunk-XGRRYN5Y.cjs');
8
- require('../chunk-DURXYPPR.cjs');
6
+ var _chunk7T5D57AMcjs = require('../chunk-7T5D57AM.cjs');
7
+ require('../chunk-2X4JCSQQ.cjs');
8
+ require('../chunk-QPVEGWOL.cjs');
9
9
 
10
10
  // src/openapi/parameters.ts
11
11
  var appendQueryParameter = (query, parameter, value) => {
@@ -141,6 +141,9 @@ var executeRequest = async (options) => {
141
141
  continue;
142
142
  }
143
143
  const { parameter } = binder;
144
+ if (value === null && parameter.in !== "path") {
145
+ continue;
146
+ }
144
147
  switch (parameter.in) {
145
148
  case "cookie":
146
149
  cookies.push(
@@ -271,7 +274,7 @@ var buildBody = (binding, values, headers) => {
271
274
  var buildPath = (route, values) => {
272
275
  const unfilled = [...route.path.matchAll(/\{([^{}]*)\}/g)].filter(([, name]) => !values.has(name)).map(([placeholder]) => placeholder);
273
276
  if (unfilled.length > 0) {
274
- throw new (0, _chunkC2VT2NXCcjs.UserError)(
277
+ throw new (0, _chunk7T5D57AMcjs.UserError)(
275
278
  `${route.method.toUpperCase()} ${route.path} cannot be called: the OpenAPI document declares no path parameter for ${unfilled.join(", ")}.`
276
279
  );
277
280
  }
@@ -282,7 +285,7 @@ var buildPath = (route, values) => {
282
285
  const written = new Set(route.path.split("/").filter(isDotSegment));
283
286
  const introduced = path.split("/").find((segment) => isDotSegment(segment) && !written.has(segment));
284
287
  if (introduced !== void 0) {
285
- throw new (0, _chunkC2VT2NXCcjs.UserError)(
288
+ throw new (0, _chunk7T5D57AMcjs.UserError)(
286
289
  `${route.method.toUpperCase()} ${route.path} cannot be called with a path segment of "${introduced}": a URL resolves it as a step through the path, so the request would reach a different endpoint.`
287
290
  );
288
291
  }
@@ -300,7 +303,7 @@ var readResponse = async (response, options) => {
300
303
  const mediaType = contentType.split(";")[0].trim().toLowerCase();
301
304
  const label = `${route.method.toUpperCase()} ${route.path}`;
302
305
  if (!response.ok) {
303
- throw new (0, _chunkC2VT2NXCcjs.UserError)(
306
+ throw new (0, _chunk7T5D57AMcjs.UserError)(
304
307
  `${label} failed with ${response.status} ${response.statusText}: ${truncate(
305
308
  await response.text(),
306
309
  2e3
@@ -312,7 +315,7 @@ var readResponse = async (response, options) => {
312
315
  if (bytes.byteLength <= MAX_INLINE_MEDIA_BYTES) {
313
316
  return mediaType.startsWith("image/") ? { data: toBase64(bytes), mimeType: mediaType, type: "image" } : { data: toBase64(bytes), mimeType: mediaType, type: "audio" };
314
317
  }
315
- throw new (0, _chunkC2VT2NXCcjs.UserError)(
318
+ throw new (0, _chunk7T5D57AMcjs.UserError)(
316
319
  `${label} returned ${bytes.byteLength} bytes of ${contentType}, too large to return inline.`
317
320
  );
318
321
  }
@@ -322,7 +325,7 @@ var readResponse = async (response, options) => {
322
325
  return { structuredContent: parsed };
323
326
  }
324
327
  if (binding.outputSchema) {
325
- throw new (0, _chunkC2VT2NXCcjs.UserError)(
328
+ throw new (0, _chunk7T5D57AMcjs.UserError)(
326
329
  `${label} declares a JSON object response but returned ${contentType || "an untyped body"}. Set \`outputSchema: false\` if this document's response schemas do not match the API.`
327
330
  );
328
331
  }
@@ -344,7 +347,7 @@ var setHeader = (headers, name, value) => {
344
347
  try {
345
348
  headers.set(name, value);
346
349
  } catch (e2) {
347
- throw new (0, _chunkC2VT2NXCcjs.UserError)(
350
+ throw new (0, _chunk7T5D57AMcjs.UserError)(
348
351
  `"${name}" is not a valid header name, or the value given for it is not a valid header value.`
349
352
  );
350
353
  }
@@ -451,7 +454,7 @@ var readSpecText = async (spec) => {
451
454
  headers: { accept: "application/json, text/yaml, */*" }
452
455
  });
453
456
  if (!response.ok) {
454
- await _chunkC2VT2NXCcjs.cancelResponseBody.call(void 0, response);
457
+ await _chunk7T5D57AMcjs.cancelResponseBody.call(void 0, response);
455
458
  throw new Error(
456
459
  `Failed to fetch the OpenAPI document from ${spec}: ${response.status} ${response.statusText}`
457
460
  );
@@ -1039,7 +1042,7 @@ var fromOpenAPI = async (options) => {
1039
1042
  const selected = selectRoutes(extractRoutes(document), options);
1040
1043
  const names = generateToolNames(selected, options.toolNames);
1041
1044
  const normalizer = createSchemaNormalizer(document);
1042
- const server = _nullishCoalesce(options.server, () => ( new (0, _chunkC2VT2NXCcjs.ViteMCP)({
1045
+ const server = _nullishCoalesce(options.server, () => ( new (0, _chunk7T5D57AMcjs.ViteMCP)({
1043
1046
  description: _optionalChain([document, 'access', _23 => _23.info, 'optionalAccess', _24 => _24.description]),
1044
1047
  name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access', _25 => _25.info, 'optionalAccess', _26 => _26.title]))), () => ( "OpenAPI")),
1045
1048
  version: _nullishCoalesce(options.version, () => ( semanticVersion(_optionalChain([document, 'access', _27 => _27.info, 'optionalAccess', _28 => _28.version]))))
@@ -1078,8 +1081,8 @@ var fromOpenAPI = async (options) => {
1078
1081
  route
1079
1082
  }),
1080
1083
  name,
1081
- outputSchema: binding.outputSchema ? _chunkC2VT2NXCcjs.jsonSchemaAdapter.call(void 0, binding.outputSchema) : void 0,
1082
- parameters: _chunkC2VT2NXCcjs.jsonSchemaAdapter.call(void 0, binding.inputSchema),
1084
+ outputSchema: binding.outputSchema ? _chunk7T5D57AMcjs.jsonSchemaAdapter.call(void 0, binding.outputSchema) : void 0,
1085
+ parameters: _chunk7T5D57AMcjs.jsonSchemaAdapter.call(void 0, binding.inputSchema),
1083
1086
  timeoutMs: options.timeoutMs
1084
1087
  });
1085
1088
  }