fastmcp 4.30.0 → 4.30.2

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,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
 
4
- var _chunk4JEDH2ONcjs = require('../chunk-4JEDH2ON.cjs');
4
+ var _chunkLTBNX7PXcjs = require('../chunk-LTBNX7PX.cjs');
5
5
  require('../chunk-CZGQ2WTQ.cjs');
6
6
  require('../chunk-FBDPX4H2.cjs');
7
7
 
@@ -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, _chunkLTBNX7PXcjs.FastMCP)({
16
16
  // Simple authentication - in production, use proper tokens/JWTs
17
17
  authenticate: async (req) => {
18
18
  const authHeader = req.headers.authorization;
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  FastMCP
4
- } from "../chunk-5KA6SOWT.js";
4
+ } from "../chunk-3JQE5IXF.js";
5
5
  import "../chunk-XPTUOWUT.js";
6
6
  import "../chunk-JCKJRUCE.js";
7
7
 
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk4JEDH2ONcjs = require('../chunk-4JEDH2ON.cjs');
5
+ var _chunkLTBNX7PXcjs = require('../chunk-LTBNX7PX.cjs');
6
6
  require('../chunk-CZGQ2WTQ.cjs');
7
7
  require('../chunk-FBDPX4H2.cjs');
8
8
 
@@ -84,9 +84,10 @@ function buildFlatSchema(route, sharedDefs) {
84
84
  const requiredBodyKeys = [];
85
85
  for (const [name, { required: isRequired, schema }] of bodyProperties) {
86
86
  const key = name === "__proto__" ? allocateAlias(`${name}__body`) : name;
87
- properties[key] = omitReadOnlyRequired(
87
+ properties[key] = omitRequiredByAnnotation(
88
88
  rewriteComponentRefs(schema),
89
- "schema"
89
+ "schema",
90
+ "readOnly"
90
91
  );
91
92
  parameterMap[key] = { in: "body", name };
92
93
  bodyKeys.push(key);
@@ -109,7 +110,11 @@ function buildFlatSchema(route, sharedDefs) {
109
110
  }
110
111
  const usedDefs = sharedDefs && filterReferencedDefs(properties, sharedDefs);
111
112
  if (usedDefs) {
112
- flatSchema.$defs = omitReadOnlyRequired(usedDefs, "schemaMap");
113
+ flatSchema.$defs = omitRequiredByAnnotation(
114
+ usedDefs,
115
+ "schemaMap",
116
+ "readOnly"
117
+ );
113
118
  }
114
119
  return {
115
120
  bodyEncoding,
@@ -161,12 +166,17 @@ function buildOutputSchema(route, sharedDefs) {
161
166
  if (usedDefs && Object.keys(usedDefs).length > MAX_OUTPUT_SCHEMA_DEFS) {
162
167
  return void 0;
163
168
  }
164
- return {
169
+ const outputSchema = {
165
170
  ...normalized,
166
171
  ...usedDefs ? {
167
172
  $defs: rewriteNode(usedDefs, "schemaMap", true)
168
173
  } : {}
169
174
  };
175
+ return omitRequiredByAnnotation(
176
+ outputSchema,
177
+ "schema",
178
+ "writeOnly"
179
+ );
170
180
  }
171
181
  function resolveComponentRef(schema, sharedDefs) {
172
182
  const seen = /* @__PURE__ */ new Set();
@@ -323,29 +333,32 @@ function normalizeNullable(schema) {
323
333
  }
324
334
  return rest;
325
335
  }
326
- function omitReadOnlyRequired(value, mode) {
336
+ function omitRequiredByAnnotation(value, mode, annotation) {
327
337
  if (mode === "data" || !value || typeof value !== "object") {
328
338
  return value;
329
339
  }
330
340
  if (Array.isArray(value)) {
331
- return value.map((item) => omitReadOnlyRequired(item, "schema"));
341
+ return value.map(
342
+ (item) => omitRequiredByAnnotation(item, "schema", annotation)
343
+ );
332
344
  }
333
345
  const node = Object.fromEntries(
334
346
  Object.entries(value).map(([key, child]) => [
335
347
  key,
336
- omitReadOnlyRequired(
348
+ omitRequiredByAnnotation(
337
349
  child,
338
- mode === "schemaMap" ? "schema" : childMode(key)
350
+ mode === "schemaMap" ? "schema" : childMode(key),
351
+ annotation
339
352
  )
340
353
  ])
341
354
  );
342
355
  const { properties, required } = node;
343
356
  if (mode === "schema" && Array.isArray(required) && properties && typeof properties === "object") {
344
- const writable = required.filter(
345
- (name) => !(typeof name === "string" && Object.hasOwn(properties, name) && _optionalChain([properties, 'access', _14 => _14[name], 'optionalAccess', _15 => _15.readOnly]) === true)
357
+ const remaining = required.filter(
358
+ (name) => !(typeof name === "string" && Object.hasOwn(properties, name) && _optionalChain([properties, 'access', _14 => _14[name], 'optionalAccess', _15 => _15[annotation]]) === true)
346
359
  );
347
- if (writable.length > 0) {
348
- node.required = writable;
360
+ if (remaining.length > 0) {
361
+ node.required = remaining;
349
362
  } else {
350
363
  delete node.required;
351
364
  }
@@ -632,7 +645,7 @@ function assertNoSubstitutedDotSegments(route, resolvedPath) {
632
645
  const templateSegments = new Set(route.path.split("/"));
633
646
  for (const segment of resolvedPath.split("/")) {
634
647
  if ((segment === "." || segment === "..") && !templateSegments.has(segment)) {
635
- throw new (0, _chunk4JEDH2ONcjs.UserError)(
648
+ throw new (0, _chunkLTBNX7PXcjs.UserError)(
636
649
  `${route.method.toUpperCase()} ${route.path}: path parameter values must not produce a "${segment}" path segment.`
637
650
  );
638
651
  }
@@ -645,7 +658,7 @@ function encodeCookieValue(mapping, value) {
645
658
  return encodePathComponent(text);
646
659
  }
647
660
  if (/[;,]/.test(text)) {
648
- throw new (0, _chunk4JEDH2ONcjs.UserError)(
661
+ throw new (0, _chunkLTBNX7PXcjs.UserError)(
649
662
  `Cookie parameter "${mapping.name}" uses style "cookie" and its value contains ";" or ","`
650
663
  );
651
664
  }
@@ -658,10 +671,10 @@ function encodeFormBody(payload) {
658
671
  for (const [key, value] of Object.entries(
659
672
  payload
660
673
  )) {
661
- if (value === void 0) {
674
+ if (value === void 0 || value === null) {
662
675
  continue;
663
676
  }
664
- appendBracketPairs(params, key, value);
677
+ appendBracketPairs(params, key, withoutNullMembers(value));
665
678
  }
666
679
  }
667
680
  return params.toString();
@@ -836,7 +849,7 @@ async function fetchResponse(options) {
836
849
  });
837
850
  if (!response.ok) {
838
851
  const text = await response.text();
839
- throw new (0, _chunk4JEDH2ONcjs.UserError)(
852
+ throw new (0, _chunkLTBNX7PXcjs.UserError)(
840
853
  `${options.route.method.toUpperCase()} ${path} failed with ${response.status}: ${text.slice(0, 2e3)}`
841
854
  );
842
855
  }
@@ -1099,7 +1112,7 @@ async function fromOpenAPI(options) {
1099
1112
  const selected = selectRoutes(routes, options);
1100
1113
  const names = generateNames(selected, options.mcpNames);
1101
1114
  const sharedDefs = buildSharedDefs(document);
1102
- const server = _nullishCoalesce(options.server, () => ( new (0, _chunk4JEDH2ONcjs.FastMCP)({
1115
+ const server = _nullishCoalesce(options.server, () => ( new (0, _chunkLTBNX7PXcjs.FastMCP)({
1103
1116
  name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access', _45 => _45.info, 'optionalAccess', _46 => _46.title]))), () => ( "OpenAPI Server")),
1104
1117
  version: _nullishCoalesce(options.version, () => ( "1.0.0"))
1105
1118
  })));
@@ -1145,7 +1158,7 @@ async function fromOpenAPI(options) {
1145
1158
  continue;
1146
1159
  }
1147
1160
  const outputSchemaJson = buildOutputSchema(route, sharedDefs);
1148
- const outputSchema = outputSchemaJson ? _chunk4JEDH2ONcjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
1161
+ const outputSchema = outputSchemaJson ? _chunkLTBNX7PXcjs.jsonSchemaAdapter.call(void 0, outputSchemaJson) : void 0;
1149
1162
  server.addTool({
1150
1163
  description: _nullishCoalesce(route.summary, () => ( `${route.method.toUpperCase()} ${route.path}`)),
1151
1164
  execute: async (args, context) => {
@@ -1160,7 +1173,7 @@ async function fromOpenAPI(options) {
1160
1173
  return resolveToolResult(result, outputSchema);
1161
1174
  },
1162
1175
  name,
1163
- parameters: _chunk4JEDH2ONcjs.jsonSchemaAdapter.call(void 0, flatSchema),
1176
+ parameters: _chunkLTBNX7PXcjs.jsonSchemaAdapter.call(void 0, flatSchema),
1164
1177
  ...outputSchema ? { outputSchema } : {}
1165
1178
  });
1166
1179
  }