fastmcp 4.28.2 → 4.28.4
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.
- package/dist/FastMCP.cjs +4 -4
- package/dist/FastMCP.d.cts +2 -2
- package/dist/FastMCP.d.ts +2 -2
- package/dist/FastMCP.js +3 -3
- package/dist/{OAuthProvider-DvIxa9N1.d.cts → OAuthProvider-C2Z93xC5.d.cts} +3 -1
- package/dist/{OAuthProvider-DvIxa9N1.d.ts → OAuthProvider-C2Z93xC5.d.ts} +3 -1
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.d.cts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/bin/fastmcp.cjs +0 -1
- package/dist/bin/fastmcp.cjs.map +1 -1
- package/dist/bin/fastmcp.js +0 -1
- package/dist/bin/fastmcp.js.map +1 -1
- package/dist/{chunk-HZJE6ZGH.cjs → chunk-7IQ5QHVZ.cjs} +39 -19
- package/dist/chunk-7IQ5QHVZ.cjs.map +1 -0
- package/dist/{chunk-AM3HVK4Z.js → chunk-B2QUCZGV.js} +42 -18
- package/dist/chunk-B2QUCZGV.js.map +1 -0
- package/dist/{chunk-GW5MENCI.cjs → chunk-DPJW5QEO.cjs} +34 -13
- package/dist/chunk-DPJW5QEO.cjs.map +1 -0
- package/dist/{chunk-2NZFMD6I.cjs → chunk-OCCYKYIM.cjs} +42 -18
- package/dist/chunk-OCCYKYIM.cjs.map +1 -0
- package/dist/{chunk-MBIVAKUB.js → chunk-Q57EM4LH.js} +28 -7
- package/dist/chunk-Q57EM4LH.js.map +1 -0
- package/dist/{chunk-76OY4FEK.js → chunk-UFPH23EN.js} +35 -15
- package/dist/chunk-UFPH23EN.js.map +1 -0
- package/dist/edge/index.cjs +19 -8
- package/dist/edge/index.cjs.map +1 -1
- package/dist/edge/index.js +17 -6
- package/dist/edge/index.js.map +1 -1
- package/dist/examples/custom-routes.cjs +4 -4
- package/dist/examples/custom-routes.js +3 -3
- package/dist/openapi/index.cjs +23 -12
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.d.cts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.js +17 -6
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2NZFMD6I.cjs.map +0 -1
- package/dist/chunk-76OY4FEK.js.map +0 -1
- package/dist/chunk-AM3HVK4Z.js.map +0 -1
- package/dist/chunk-GW5MENCI.cjs.map +0 -1
- package/dist/chunk-HZJE6ZGH.cjs.map +0 -1
- package/dist/chunk-MBIVAKUB.js.map +0 -1
|
@@ -4,23 +4,7 @@ function objectRootSchema(schema) {
|
|
|
4
4
|
return schema.type === void 0 ? { ...schema, type: "object" } : schema;
|
|
5
5
|
}
|
|
6
6
|
function strictInputSchema(schema, nested = false) {
|
|
7
|
-
const
|
|
8
|
-
if (!nested && ($ref || allOf || anyOf || oneOf)) {
|
|
9
|
-
return objectRootSchema(schema);
|
|
10
|
-
}
|
|
11
|
-
const keepsAdditionalProperties = Object.keys(properties ?? {}).length === 0 && (typeof additionalProperties === "object" || additionalProperties === true || nested && additionalProperties === void 0 && !properties);
|
|
12
|
-
const strict = {
|
|
13
|
-
...schema,
|
|
14
|
-
...keepsAdditionalProperties ? {} : { additionalProperties: false },
|
|
15
|
-
...properties && {
|
|
16
|
-
properties: Object.fromEntries(
|
|
17
|
-
Object.entries(properties).map(([key, value]) => [
|
|
18
|
-
key,
|
|
19
|
-
typeof value === "object" && value.type === "object" ? strictInputSchema(value, true) : value
|
|
20
|
-
])
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
};
|
|
7
|
+
const strict = strictSchemaNode(schema, nested, false);
|
|
24
8
|
return nested ? strict : objectRootSchema(strict);
|
|
25
9
|
}
|
|
26
10
|
function zodInputSchema(schema, target) {
|
|
@@ -111,10 +95,50 @@ function zodInputSchema(schema, target) {
|
|
|
111
95
|
}
|
|
112
96
|
return closed;
|
|
113
97
|
}
|
|
98
|
+
function isSchemaRecord(value) {
|
|
99
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
100
|
+
}
|
|
101
|
+
function strictSchemaNode(schema, nested, operand) {
|
|
102
|
+
const { $ref, additionalProperties, allOf, anyOf, oneOf, properties } = schema;
|
|
103
|
+
const hasConditional = "if" in schema && schema.if !== void 0;
|
|
104
|
+
const hasComposition = Boolean(
|
|
105
|
+
$ref || allOf || anyOf || oneOf || hasConditional
|
|
106
|
+
);
|
|
107
|
+
const isObjectSchema = nested ? schema.type === "object" : schema.type === void 0 || schema.type === "object";
|
|
108
|
+
const keepsAdditionalProperties = Object.keys(properties ?? {}).length === 0 && (typeof additionalProperties === "object" || additionalProperties === true || nested && additionalProperties === void 0 && !properties);
|
|
109
|
+
const closesNode = !operand && !hasComposition && isObjectSchema && !keepsAdditionalProperties;
|
|
110
|
+
const next = {
|
|
111
|
+
...schema,
|
|
112
|
+
...closesNode ? { additionalProperties: false } : {}
|
|
113
|
+
};
|
|
114
|
+
if (properties) {
|
|
115
|
+
next.properties = Object.fromEntries(
|
|
116
|
+
Object.entries(properties).map(([key, value]) => [
|
|
117
|
+
key,
|
|
118
|
+
isSchemaRecord(value) ? strictSchemaNode(value, true, false) : value
|
|
119
|
+
])
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
for (const keyword of ["allOf", "anyOf", "oneOf"]) {
|
|
123
|
+
const branches = schema[keyword];
|
|
124
|
+
if (Array.isArray(branches)) {
|
|
125
|
+
next[keyword] = branches.map(
|
|
126
|
+
(branch) => isSchemaRecord(branch) ? strictSchemaNode(branch, true, true) : branch
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (const keyword of ["else", "then"]) {
|
|
131
|
+
const branch = schema[keyword];
|
|
132
|
+
if (isSchemaRecord(branch)) {
|
|
133
|
+
next[keyword] = strictSchemaNode(branch, true, true);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return next;
|
|
137
|
+
}
|
|
114
138
|
|
|
115
139
|
export {
|
|
116
140
|
objectRootSchema,
|
|
117
141
|
strictInputSchema,
|
|
118
142
|
zodInputSchema
|
|
119
143
|
};
|
|
120
|
-
//# sourceMappingURL=chunk-
|
|
144
|
+
//# sourceMappingURL=chunk-B2QUCZGV.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\nfunction isSchemaRecord(value: unknown): value is JsonSchema {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction strictSchemaNode(\n schema: JsonSchema,\n nested: boolean,\n operand: boolean,\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 const closesNode =\n !operand && !hasComposition && isObjectSchema && !keepsAdditionalProperties;\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 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,a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AC,EAAE,WAAW,MACxC,OAAO,yBAAyB,YAC/B,yBAAyB,QACxB,UAAU,yBAAyB,UAAa,CAAC;AAEtD,QAAM,aACJ,CAAC,WAAW,CAAC,kBAAkB,kBAAkB,CAAC;AAEpD,QAAM,OAAgC;AAAA,IACpC,GAAG;AAAA,IACH,GAAI,aAAa,EAAE,sBAAsB,MAAM,IAAI,CAAC;AAAA,EACtD;AAEA,MAAI,YAAY;AACd,SAAK,aAAa,OAAO;AAAA,MACvB,OAAO,QAAQ,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,QAC/C;AAAA,QACA,eAAe,KAAK,IAAI,iBAAiB,OAAO,MAAM,KAAK,IAAI;AAAA,MACjE,CAAC;AAAA,IACH;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,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await 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; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk7IQ5QHVZcjs = require('./chunk-7IQ5QHVZ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkOCCYKYIMcjs = require('./chunk-OCCYKYIM.cjs');
|
|
9
9
|
|
|
10
10
|
// src/FastMCP.ts
|
|
11
11
|
var _indexjs = require('@modelcontextprotocol/sdk/server/index.js');
|
|
@@ -141,7 +141,7 @@ var DiscoveryDocumentCache = class {
|
|
|
141
141
|
throw error;
|
|
142
142
|
}
|
|
143
143
|
if (!res.ok) {
|
|
144
|
-
await
|
|
144
|
+
await _chunk7IQ5QHVZcjs.cancelResponseBody.call(void 0, res);
|
|
145
145
|
throw new Error(
|
|
146
146
|
`Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
|
|
147
147
|
);
|
|
@@ -258,7 +258,7 @@ var imageContent = async (input) => {
|
|
|
258
258
|
signal: AbortSignal.timeout(timeoutMs)
|
|
259
259
|
});
|
|
260
260
|
if (!response.ok) {
|
|
261
|
-
await
|
|
261
|
+
await _chunk7IQ5QHVZcjs.cancelResponseBody.call(void 0, response);
|
|
262
262
|
throw new Error(
|
|
263
263
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
264
264
|
);
|
|
@@ -340,7 +340,7 @@ var audioContent = async (input) => {
|
|
|
340
340
|
signal: AbortSignal.timeout(timeoutMs)
|
|
341
341
|
});
|
|
342
342
|
if (!response.ok) {
|
|
343
|
-
await
|
|
343
|
+
await _chunk7IQ5QHVZcjs.cancelResponseBody.call(void 0, response);
|
|
344
344
|
throw new Error(
|
|
345
345
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
346
346
|
);
|
|
@@ -1191,7 +1191,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1191
1191
|
return () => {
|
|
1192
1192
|
};
|
|
1193
1193
|
}
|
|
1194
|
-
const intervalMs = config.intervalMs && config.intervalMs
|
|
1194
|
+
const intervalMs = config.intervalMs && config.intervalMs >= 1 ? config.intervalMs : STREAM_KEEPALIVE_DEFAULT_INTERVAL_MS;
|
|
1195
1195
|
const timer = setInterval(() => {
|
|
1196
1196
|
extra.sendNotification({
|
|
1197
1197
|
method: "notifications/message",
|
|
@@ -1651,12 +1651,12 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1651
1651
|
tools: cachedToolsList
|
|
1652
1652
|
};
|
|
1653
1653
|
}
|
|
1654
|
-
|
|
1654
|
+
const listedTools = await Promise.all(
|
|
1655
1655
|
tools.map(async (tool) => {
|
|
1656
1656
|
let inputSchema;
|
|
1657
1657
|
try {
|
|
1658
|
-
inputSchema = tool.parameters ?
|
|
1659
|
-
tool.parameters["~standard"].vendor === "zod" && "_zod" in tool.parameters ?
|
|
1658
|
+
inputSchema = tool.parameters ? _chunkOCCYKYIMcjs.strictInputSchema.call(void 0,
|
|
1659
|
+
tool.parameters["~standard"].vendor === "zod" && "_zod" in tool.parameters ? _chunkOCCYKYIMcjs.zodInputSchema.call(void 0, tool.parameters, "draft-7") : await _xsschema.toJsonSchema.call(void 0, tool.parameters)
|
|
1660
1660
|
) : {
|
|
1661
1661
|
additionalProperties: false,
|
|
1662
1662
|
properties: {},
|
|
@@ -1669,10 +1669,16 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1669
1669
|
);
|
|
1670
1670
|
inputSchema = { type: "object" };
|
|
1671
1671
|
}
|
|
1672
|
+
if (inputSchema.type !== "object") {
|
|
1673
|
+
this.#logger.warn(
|
|
1674
|
+
`[FastMCP warning] Tool '${tool.name}' parameters must describe an object. Omitting the tool from tools/list.`
|
|
1675
|
+
);
|
|
1676
|
+
return void 0;
|
|
1677
|
+
}
|
|
1672
1678
|
let outputSchema;
|
|
1673
1679
|
if (tool.outputSchema) {
|
|
1674
1680
|
try {
|
|
1675
|
-
outputSchema =
|
|
1681
|
+
outputSchema = _chunkOCCYKYIMcjs.objectRootSchema.call(void 0,
|
|
1676
1682
|
await _xsschema.toJsonSchema.call(void 0, tool.outputSchema)
|
|
1677
1683
|
);
|
|
1678
1684
|
} catch (error) {
|
|
@@ -1681,18 +1687,27 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1681
1687
|
error
|
|
1682
1688
|
);
|
|
1683
1689
|
}
|
|
1690
|
+
if (outputSchema && outputSchema.type !== "object") {
|
|
1691
|
+
this.#logger.warn(
|
|
1692
|
+
`[FastMCP warning] Tool '${tool.name}' outputSchema must describe an object. Omitting the tool from tools/list.`
|
|
1693
|
+
);
|
|
1694
|
+
return void 0;
|
|
1695
|
+
}
|
|
1684
1696
|
}
|
|
1685
1697
|
return {
|
|
1686
1698
|
annotations: tool.annotations,
|
|
1687
1699
|
description: tool.description,
|
|
1688
1700
|
inputSchema,
|
|
1689
1701
|
name: tool.name,
|
|
1690
|
-
...outputSchema && {
|
|
1702
|
+
...outputSchema && {
|
|
1703
|
+
outputSchema
|
|
1704
|
+
},
|
|
1691
1705
|
// Pass through _meta for MCP ext-apps UI support (issue #229)
|
|
1692
1706
|
...tool._meta && { _meta: tool._meta }
|
|
1693
1707
|
};
|
|
1694
1708
|
})
|
|
1695
1709
|
);
|
|
1710
|
+
cachedToolsList = listedTools.filter((tool) => tool !== void 0);
|
|
1696
1711
|
return {
|
|
1697
1712
|
tools: cachedToolsList
|
|
1698
1713
|
};
|
|
@@ -1763,9 +1778,10 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1763
1778
|
}
|
|
1764
1779
|
}
|
|
1765
1780
|
};
|
|
1781
|
+
let toolSettled = false;
|
|
1766
1782
|
try {
|
|
1767
1783
|
const reportProgress = async (progress) => {
|
|
1768
|
-
if (progressToken === void 0) {
|
|
1784
|
+
if (toolSettled || progressToken === void 0) {
|
|
1769
1785
|
return;
|
|
1770
1786
|
}
|
|
1771
1787
|
try {
|
|
@@ -1788,6 +1804,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1788
1804
|
};
|
|
1789
1805
|
const log = this.#createLog(sendNotification);
|
|
1790
1806
|
const streamContent = async (content) => {
|
|
1807
|
+
if (toolSettled) {
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1791
1810
|
const contentArray = Array.isArray(content) ? content : [content];
|
|
1792
1811
|
try {
|
|
1793
1812
|
await sendNotification({
|
|
@@ -1856,6 +1875,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1856
1875
|
executeToolPromise,
|
|
1857
1876
|
aborted
|
|
1858
1877
|
]).finally(() => {
|
|
1878
|
+
toolSettled = true;
|
|
1859
1879
|
clearTimeout(timeoutId);
|
|
1860
1880
|
stopWaitingForAbort();
|
|
1861
1881
|
stopStreamKeepalive();
|
|
@@ -1906,6 +1926,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1906
1926
|
);
|
|
1907
1927
|
}
|
|
1908
1928
|
} catch (error) {
|
|
1929
|
+
toolSettled = true;
|
|
1909
1930
|
if (error instanceof UserError) {
|
|
1910
1931
|
let structuredContent = error.extras;
|
|
1911
1932
|
if (structuredContent && tool.outputSchema) {
|
|
@@ -3706,4 +3727,4 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
3706
3727
|
|
|
3707
3728
|
|
|
3708
3729
|
exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.FastMCPError = FastMCPError; exports.SessionError = SessionError; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.ServerState = ServerState; exports.FastMCPSession = FastMCPSession; exports.FastMCP = FastMCP;
|
|
3709
|
-
//# sourceMappingURL=chunk-
|
|
3730
|
+
//# sourceMappingURL=chunk-DPJW5QEO.cjs.map
|