@vitemcp/server 1.9.11 → 1.9.13

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 (36) hide show
  1. package/README.md +15 -11
  2. package/dist/{OAuthProvider-B78zmLtB.d.cts → OAuthProvider-BDDi19HO.d.cts} +15 -3
  3. package/dist/{OAuthProvider-B78zmLtB.d.ts → OAuthProvider-BDDi19HO.d.ts} +15 -3
  4. package/dist/ViteMCP.cjs +4 -4
  5. package/dist/ViteMCP.d.cts +2 -2
  6. package/dist/ViteMCP.d.ts +2 -2
  7. package/dist/ViteMCP.js +3 -3
  8. package/dist/auth/index.cjs +2 -2
  9. package/dist/auth/index.d.cts +7 -2
  10. package/dist/auth/index.d.ts +7 -2
  11. package/dist/auth/index.js +1 -1
  12. package/dist/{chunk-KSEFUQF4.js → chunk-5XM67UD5.js} +35 -6
  13. package/dist/chunk-5XM67UD5.js.map +1 -0
  14. package/dist/{chunk-TYR2KJIV.js → chunk-JMDI672G.js} +44 -9
  15. package/dist/chunk-JMDI672G.js.map +1 -0
  16. package/dist/{chunk-C2VT2NXC.cjs → chunk-NCSND5TI.cjs} +8 -8
  17. package/dist/{chunk-C2VT2NXC.cjs.map → chunk-NCSND5TI.cjs.map} +1 -1
  18. package/dist/{chunk-IAT55CW3.js → chunk-QGWUABBC.js} +3 -3
  19. package/dist/{chunk-DURXYPPR.cjs → chunk-QPVEGWOL.cjs} +44 -9
  20. package/dist/chunk-QPVEGWOL.cjs.map +1 -0
  21. package/dist/{chunk-XGRRYN5Y.cjs → chunk-SKQK3QGJ.cjs} +35 -6
  22. package/dist/chunk-SKQK3QGJ.cjs.map +1 -0
  23. package/dist/edge/index.cjs +5 -5
  24. package/dist/edge/index.js +1 -1
  25. package/dist/openapi/index.cjs +103 -36
  26. package/dist/openapi/index.cjs.map +1 -1
  27. package/dist/openapi/index.d.cts +2 -2
  28. package/dist/openapi/index.d.ts +2 -2
  29. package/dist/openapi/index.js +86 -19
  30. package/dist/openapi/index.js.map +1 -1
  31. package/package.json +1 -1
  32. package/dist/chunk-DURXYPPR.cjs.map +0 -1
  33. package/dist/chunk-KSEFUQF4.js.map +0 -1
  34. package/dist/chunk-TYR2KJIV.js.map +0 -1
  35. package/dist/chunk-XGRRYN5Y.cjs.map +0 -1
  36. /package/dist/{chunk-IAT55CW3.js.map → chunk-QGWUABBC.js.map} +0 -0
@@ -3,18 +3,19 @@ import {
3
3
  ViteMCP,
4
4
  cancelResponseBody,
5
5
  jsonSchemaAdapter
6
- } from "../chunk-IAT55CW3.js";
7
- import "../chunk-KSEFUQF4.js";
8
- import "../chunk-TYR2KJIV.js";
6
+ } from "../chunk-QGWUABBC.js";
7
+ import "../chunk-5XM67UD5.js";
8
+ import "../chunk-JMDI672G.js";
9
9
 
10
10
  // src/openapi/parameters.ts
11
- var appendQueryParameter = (query, parameter, value) => {
11
+ var appendQueryParameter = (query, parameter, given) => {
12
12
  const style = parameter.style ?? "form";
13
13
  const explode = parameter.explode ?? style === "form";
14
14
  const name = parameter.name;
15
- if (value === null || value === void 0) {
15
+ if (given === null || given === void 0) {
16
16
  return;
17
17
  }
18
+ const value = withoutNullMembers(given);
18
19
  if (style === "deepObject") {
19
20
  if (isRecord(value)) {
20
21
  for (const [key, entry] of Object.entries(value)) {
@@ -74,8 +75,9 @@ var serializePathParameter = (parameter, value) => {
74
75
  }
75
76
  return body;
76
77
  };
77
- var serializeSimpleParameter = (parameter, value) => {
78
+ var serializeSimpleParameter = (parameter, given) => {
78
79
  const explode = parameter.explode ?? false;
80
+ const value = withoutNullMembers(given);
79
81
  if (Array.isArray(value)) {
80
82
  return value.map(stringify).join(",");
81
83
  }
@@ -95,6 +97,17 @@ var DELIMITERS = {
95
97
  spaceDelimited: " "
96
98
  };
97
99
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
100
+ var withoutNullMembers = (value) => {
101
+ if (Array.isArray(value)) {
102
+ return value.filter((entry) => entry !== null);
103
+ }
104
+ if (isRecord(value)) {
105
+ return Object.fromEntries(
106
+ Object.entries(value).filter(([, entry]) => entry !== null)
107
+ );
108
+ }
109
+ return value;
110
+ };
98
111
  var serializeSimple = (value, explode, name, style) => {
99
112
  const encode = (entry) => encodeURIComponent(stringify(entry));
100
113
  if (Array.isArray(value)) {
@@ -141,6 +154,9 @@ var executeRequest = async (options) => {
141
154
  continue;
142
155
  }
143
156
  const { parameter } = binder;
157
+ if (value === null && parameter.in !== "path") {
158
+ continue;
159
+ }
144
160
  switch (parameter.in) {
145
161
  case "cookie":
146
162
  cookies.push(
@@ -729,6 +745,41 @@ var collectDefinitions = (schema, definitions) => {
729
745
  [...referenced].sort().map((name) => [name, definitions[name]])
730
746
  );
731
747
  };
748
+ var schemaFor = (schema, direction) => {
749
+ if (Array.isArray(schema)) {
750
+ return schema.map((entry) => schemaFor(entry, direction));
751
+ }
752
+ if (!schema || typeof schema !== "object") {
753
+ return schema;
754
+ }
755
+ const result = {};
756
+ for (const [key, entry] of Object.entries(schema)) {
757
+ if (VALUE_KEYWORDS.has(key)) {
758
+ result[key] = entry;
759
+ } else if (SCHEMA_MAP_KEYWORDS.has(key) && entry && typeof entry === "object") {
760
+ result[key] = Object.fromEntries(
761
+ Object.entries(entry).map(
762
+ ([name, member]) => [name, schemaFor(member, direction)]
763
+ )
764
+ );
765
+ } else {
766
+ result[key] = schemaFor(entry, direction);
767
+ }
768
+ }
769
+ const { properties, required } = result;
770
+ if (Array.isArray(required) && properties && typeof properties === "object") {
771
+ const otherDirectionOnly = direction === "request" ? "readOnly" : "writeOnly";
772
+ const kept = required.filter(
773
+ (name) => typeof name !== "string" || !Object.hasOwn(properties, name) || properties[name]?.[otherDirectionOnly] !== true
774
+ );
775
+ if (kept.length > 0) {
776
+ result.required = kept;
777
+ } else {
778
+ delete result.required;
779
+ }
780
+ }
781
+ return result;
782
+ };
732
783
  var normalizeKeywords = (schema) => {
733
784
  if (!("nullable" in schema) && !("required" in schema) && typeof schema.exclusiveMaximum !== "boolean" && typeof schema.exclusiveMinimum !== "boolean") {
734
785
  return schema;
@@ -827,7 +878,7 @@ var buildToolBinding = (route, normalizer, withOutputSchema) => {
827
878
  const requiredOnceSent = [];
828
879
  for (const [name, property] of body.properties) {
829
880
  const key = name === "__proto__" ? claimKey(`${name}__body`) : name;
830
- properties[key] = property.schema;
881
+ properties[key] = schemaFor(property.schema, "request");
831
882
  parameters[key] = { kind: "body", name };
832
883
  bodyKeys.push(key);
833
884
  if (property.required) {
@@ -846,7 +897,7 @@ var buildToolBinding = (route, normalizer, withOutputSchema) => {
846
897
  }
847
898
  const definitions = collectDefinitions(properties, normalizer.definitions);
848
899
  if (definitions) {
849
- inputSchema.$defs = definitions;
900
+ inputSchema.$defs = definitionsFor(definitions, "request");
850
901
  }
851
902
  return {
852
903
  bodyEncoding: body.encoding,
@@ -887,7 +938,8 @@ var describeBody = (route, normalizer) => {
887
938
  if (object && Object.keys(object.properties).length > 0) {
888
939
  for (const [name, property] of Object.entries(object.properties)) {
889
940
  properties.set(name, {
890
- required: object.required.has(name),
941
+ // The server's to fill in; see `schemaFor`.
942
+ required: object.required.has(name) && property.readOnly !== true,
891
943
  schema: property
892
944
  });
893
945
  }
@@ -898,27 +950,42 @@ var describeBody = (route, normalizer) => {
898
950
  };
899
951
  var MAX_OUTPUT_SCHEMA_DEFINITIONS = 100;
900
952
  var buildOutputSchema = (route, normalizer) => {
901
- const status = Object.keys(route.responses).filter((code) => /^2\d\d$/.test(code)).sort()[0];
902
- const content = status ? route.responses[status]?.content : void 0;
903
- const contentType = content && findJsonContentType(Object.keys(content));
904
- const raw = contentType ? content?.[contentType]?.schema : void 0;
905
- if (!raw) {
906
- return void 0;
953
+ const statuses = Object.keys(route.responses).filter((code) => /^2\d\d$/.test(code)).sort();
954
+ const alternatives = /* @__PURE__ */ new Map();
955
+ for (const status of statuses) {
956
+ const content = route.responses[status]?.content;
957
+ const contentType = content && findJsonContentType(Object.keys(content));
958
+ const raw = contentType ? content?.[contentType]?.schema : void 0;
959
+ if (!raw) {
960
+ return void 0;
961
+ }
962
+ const schema2 = normalizer.normalize(raw);
963
+ if (!resolvesToObject(schema2, normalizer.definitions)) {
964
+ return void 0;
965
+ }
966
+ alternatives.set(JSON.stringify(schema2), schema2);
907
967
  }
908
- const schema = normalizer.normalize(raw);
909
- if (!resolvesToObject(schema, normalizer.definitions)) {
968
+ if (alternatives.size === 0) {
910
969
  return void 0;
911
970
  }
971
+ const [first, ...others] = alternatives.values();
972
+ const schema = others.length === 0 ? first : { anyOf: [first, ...others] };
912
973
  const definitions = collectDefinitions(schema, normalizer.definitions);
913
974
  if (definitions && Object.keys(definitions).length > MAX_OUTPUT_SCHEMA_DEFINITIONS) {
914
975
  return void 0;
915
976
  }
916
977
  return {
917
- ...schema,
978
+ ...schemaFor(schema, "response"),
918
979
  type: "object",
919
- ...definitions ? { $defs: definitions } : {}
980
+ ...definitions ? { $defs: definitionsFor(definitions, "response") } : {}
920
981
  };
921
982
  };
983
+ var definitionsFor = (definitions, direction) => Object.fromEntries(
984
+ Object.entries(definitions).map(([name, definition]) => [
985
+ name,
986
+ schemaFor(definition, direction)
987
+ ])
988
+ );
922
989
  var describeParameter = (parameter, normalizer) => {
923
990
  const schema = normalizer.normalize(parameter.schema ?? { type: "string" });
924
991
  const description = [