fastmcp 4.29.1 → 4.30.0

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.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- var _chunk5EEESM57cjs = require('../chunk-5EEESM57.cjs');
5
- require('../chunk-UHJQUSUX.cjs');
4
+ var _chunk4JEDH2ONcjs = require('../chunk-4JEDH2ON.cjs');
5
+ require('../chunk-CZGQ2WTQ.cjs');
6
6
  require('../chunk-FBDPX4H2.cjs');
7
7
 
8
8
  // src/examples/custom-routes.ts
@@ -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, _chunk5EEESM57cjs.FastMCP)({
15
+ var server = new (0, _chunk4JEDH2ONcjs.FastMCP)({
16
16
  // Simple authentication - in production, use proper tokens/JWTs
17
17
  authenticate: async (req) => {
18
18
  const authHeader = req.headers.authorization;
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  FastMCP
4
- } from "../chunk-VN5SZ6IE.js";
5
- import "../chunk-RWPENEKV.js";
4
+ } from "../chunk-5KA6SOWT.js";
5
+ import "../chunk-XPTUOWUT.js";
6
6
  import "../chunk-JCKJRUCE.js";
7
7
 
8
8
  // src/examples/custom-routes.ts
@@ -2,8 +2,8 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk5EEESM57cjs = require('../chunk-5EEESM57.cjs');
6
- require('../chunk-UHJQUSUX.cjs');
5
+ var _chunk4JEDH2ONcjs = require('../chunk-4JEDH2ON.cjs');
6
+ require('../chunk-CZGQ2WTQ.cjs');
7
7
  require('../chunk-FBDPX4H2.cjs');
8
8
 
9
9
  // src/openapi/loadSpec.ts
@@ -632,7 +632,7 @@ function assertNoSubstitutedDotSegments(route, resolvedPath) {
632
632
  const templateSegments = new Set(route.path.split("/"));
633
633
  for (const segment of resolvedPath.split("/")) {
634
634
  if ((segment === "." || segment === "..") && !templateSegments.has(segment)) {
635
- throw new (0, _chunk5EEESM57cjs.UserError)(
635
+ throw new (0, _chunk4JEDH2ONcjs.UserError)(
636
636
  `${route.method.toUpperCase()} ${route.path}: path parameter values must not produce a "${segment}" path segment.`
637
637
  );
638
638
  }
@@ -645,7 +645,7 @@ function encodeCookieValue(mapping, value) {
645
645
  return encodePathComponent(text);
646
646
  }
647
647
  if (/[;,]/.test(text)) {
648
- throw new (0, _chunk5EEESM57cjs.UserError)(
648
+ throw new (0, _chunk4JEDH2ONcjs.UserError)(
649
649
  `Cookie parameter "${mapping.name}" uses style "cookie" and its value contains ";" or ","`
650
650
  );
651
651
  }
@@ -672,7 +672,13 @@ function encodePathComponent(value) {
672
672
  (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
673
673
  );
674
674
  }
675
- function encodePathValue(value, style, explode) {
675
+ function encodePathValue(name, value, style, explode) {
676
+ if (style === "label" || style === "matrix") {
677
+ const prefixed = encodePrefixedPathValue(name, value, style, explode);
678
+ if (prefixed !== void 0) {
679
+ return prefixed;
680
+ }
681
+ }
676
682
  if ((style === void 0 || style === "simple") && Array.isArray(value) && value.every((item) => item === null || typeof item !== "object")) {
677
683
  return value.map((item) => encodePathComponent(String(item))).join(",");
678
684
  }
@@ -688,6 +694,51 @@ function encodePathValue(value, style, explode) {
688
694
  }
689
695
  return encodeURIComponent(String(value));
690
696
  }
697
+ function encodePrefixedPathValue(name, value, style, explode) {
698
+ const isFlat = (item) => item === null || typeof item !== "object";
699
+ const encodedName = encodePathComponent(name);
700
+ const named = (key, encoded) => encoded === "" ? key : `${key}=${encoded}`;
701
+ if (value === null) {
702
+ return void 0;
703
+ }
704
+ if (typeof value !== "object") {
705
+ const encoded = encodePathComponent(String(value));
706
+ return style === "label" ? `.${encoded}` : `;${named(encodedName, encoded)}`;
707
+ }
708
+ let items;
709
+ let pairs;
710
+ if (Array.isArray(value)) {
711
+ if (!value.every(isFlat)) {
712
+ return void 0;
713
+ }
714
+ items = value.map((item) => encodePathComponent(String(item)));
715
+ } else {
716
+ const entries = Object.entries(value);
717
+ if (!entries.every(([, item]) => isFlat(item))) {
718
+ return void 0;
719
+ }
720
+ pairs = entries.map(([key, item]) => [
721
+ encodePathComponent(key),
722
+ encodePathComponent(String(item))
723
+ ]);
724
+ items = pairs.flat();
725
+ }
726
+ if (items.length === 0) {
727
+ return "";
728
+ }
729
+ if (explode !== true) {
730
+ const joined = items.join(",");
731
+ return style === "label" ? `.${joined}` : `;${encodedName}=${joined}`;
732
+ }
733
+ if (pairs) {
734
+ return pairs.map(
735
+ ([key, encoded]) => style === "label" ? `.${key}=${encoded}` : `;${named(key, encoded)}`
736
+ ).join("");
737
+ }
738
+ return items.map(
739
+ (encoded) => style === "label" ? `.${encoded}` : `;${named(encodedName, encoded)}`
740
+ ).join("");
741
+ }
691
742
  async function fetchResponse(options) {
692
743
  const baseUrl = resolveBaseUrl(
693
744
  options.servers,
@@ -726,7 +777,12 @@ async function fetchResponse(options) {
726
777
  );
727
778
  break;
728
779
  case "path":
729
- pathParams[mapping.name] = mapping.encoding === "json" ? encodePathComponent(JSON.stringify(value)) : encodePathValue(value, mapping.style, mapping.explode);
780
+ pathParams[mapping.name] = mapping.encoding === "json" ? encodePathComponent(JSON.stringify(value)) : encodePathValue(
781
+ mapping.name,
782
+ value,
783
+ mapping.style,
784
+ mapping.explode
785
+ );
730
786
  break;
731
787
  case "query": {
732
788
  const query = new URLSearchParams();
@@ -780,7 +836,7 @@ async function fetchResponse(options) {
780
836
  });
781
837
  if (!response.ok) {
782
838
  const text = await response.text();
783
- throw new (0, _chunk5EEESM57cjs.UserError)(
839
+ throw new (0, _chunk4JEDH2ONcjs.UserError)(
784
840
  `${options.route.method.toUpperCase()} ${path} failed with ${response.status}: ${text.slice(0, 2e3)}`
785
841
  );
786
842
  }
@@ -1043,7 +1099,7 @@ async function fromOpenAPI(options) {
1043
1099
  const selected = selectRoutes(routes, options);
1044
1100
  const names = generateNames(selected, options.mcpNames);
1045
1101
  const sharedDefs = buildSharedDefs(document);
1046
- const server = _nullishCoalesce(options.server, () => ( new (0, _chunk5EEESM57cjs.FastMCP)({
1102
+ const server = _nullishCoalesce(options.server, () => ( new (0, _chunk4JEDH2ONcjs.FastMCP)({
1047
1103
  name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access', _45 => _45.info, 'optionalAccess', _46 => _46.title]))), () => ( "OpenAPI Server")),
1048
1104
  version: _nullishCoalesce(options.version, () => ( "1.0.0"))
1049
1105
  })));
@@ -1089,7 +1145,7 @@ async function fromOpenAPI(options) {
1089
1145
  continue;
1090
1146
  }
1091
1147
  const outputSchemaJson = buildOutputSchema(route, sharedDefs);
1092
- const outputSchema = outputSchemaJson ? _chunk5EEESM57cjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
1148
+ const outputSchema = outputSchemaJson ? _chunk4JEDH2ONcjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
1093
1149
  server.addTool({
1094
1150
  description: _nullishCoalesce(route.summary, () => ( `${route.method.toUpperCase()} ${route.path}`)),
1095
1151
  execute: async (args, context) => {
@@ -1104,7 +1160,7 @@ async function fromOpenAPI(options) {
1104
1160
  return resolveToolResult(result, outputSchema);
1105
1161
  },
1106
1162
  name,
1107
- parameters: _chunk5EEESM57cjs.jsonSchemaAdapter.call(void 0, flatSchema),
1163
+ parameters: _chunk4JEDH2ONcjs.jsonSchemaAdapter.call(void 0, flatSchema),
1108
1164
  ...outputSchema ? { outputSchema } : {}
1109
1165
  });
1110
1166
  }