fastmcp 4.12.2 → 4.12.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/README.md +2 -0
- package/dist/FastMCP.cjs +5 -3
- package/dist/FastMCP.cjs.map +1 -1
- package/dist/FastMCP.d.cts +17 -12
- package/dist/FastMCP.d.ts +17 -12
- package/dist/FastMCP.js +4 -2
- package/dist/{OAuthProvider-BNqoBTYA.d.cts → OAuthProvider-B_E71LUD.d.cts} +9 -0
- package/dist/{OAuthProvider-BNqoBTYA.d.ts → OAuthProvider-B_E71LUD.d.ts} +9 -0
- 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/{chunk-PNBJIDG6.js → chunk-2ZFQSPXZ.js} +34 -19
- package/dist/chunk-2ZFQSPXZ.js.map +1 -0
- package/dist/{chunk-POXZCEYE.cjs → chunk-DD63MJG7.cjs} +94 -42
- package/dist/chunk-DD63MJG7.cjs.map +1 -0
- package/dist/{chunk-RAIXP3PS.cjs → chunk-ENMHHQJF.cjs} +34 -19
- package/dist/chunk-ENMHHQJF.cjs.map +1 -0
- package/dist/{chunk-5BQXF2VT.js → chunk-FKX5QBJV.js} +56 -4
- package/dist/chunk-FKX5QBJV.js.map +1 -0
- package/dist/examples/custom-routes.cjs +3 -3
- package/dist/examples/custom-routes.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-5BQXF2VT.js.map +0 -1
- package/dist/chunk-PNBJIDG6.js.map +0 -1
- package/dist/chunk-POXZCEYE.cjs.map +0 -1
- package/dist/chunk-RAIXP3PS.cjs.map +0 -1
|
@@ -35,12 +35,15 @@ var DiscoveryDocumentCache = class {
|
|
|
35
35
|
}
|
|
36
36
|
#cache = /* @__PURE__ */ new Map();
|
|
37
37
|
#inFlight = /* @__PURE__ */ new Map();
|
|
38
|
+
#timeoutMs;
|
|
38
39
|
#ttl;
|
|
39
40
|
/**
|
|
40
41
|
* @param options - configuration options
|
|
42
|
+
* @param options.timeoutMs - timeout in miliseconds for the upstream fetch
|
|
41
43
|
* @param options.ttl - time-to-live in miliseconds
|
|
42
44
|
*/
|
|
43
45
|
constructor(options = {}) {
|
|
46
|
+
this.#timeoutMs = _nullishCoalesce(options.timeoutMs, () => ( 1e4));
|
|
44
47
|
this.#ttl = _nullishCoalesce(options.ttl, () => ( 36e5));
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
@@ -98,7 +101,19 @@ var DiscoveryDocumentCache = class {
|
|
|
98
101
|
return true;
|
|
99
102
|
}
|
|
100
103
|
async #fetchAndCache(url) {
|
|
101
|
-
|
|
104
|
+
let res;
|
|
105
|
+
try {
|
|
106
|
+
res = await fetch(url, {
|
|
107
|
+
signal: AbortSignal.timeout(this.#timeoutMs)
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Failed to fetch discovery document from ${url}: timed out after ${this.#timeoutMs}ms`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
102
117
|
if (!res.ok) {
|
|
103
118
|
throw new Error(
|
|
104
119
|
`Failed to fetch discovery document from ${url}: ${res.status} ${res.statusText}`
|
|
@@ -182,12 +197,16 @@ function unwrapDefault(value) {
|
|
|
182
197
|
}
|
|
183
198
|
|
|
184
199
|
// src/FastMCP.ts
|
|
200
|
+
var MEDIA_FETCH_TIMEOUT_MS = 3e4;
|
|
185
201
|
var imageContent = async (input) => {
|
|
186
202
|
let rawData;
|
|
187
203
|
try {
|
|
188
204
|
if ("url" in input) {
|
|
205
|
+
const timeoutMs = _nullishCoalesce(input.timeoutMs, () => ( MEDIA_FETCH_TIMEOUT_MS));
|
|
189
206
|
try {
|
|
190
|
-
const response = await _undici.fetch.call(void 0, input.url
|
|
207
|
+
const response = await _undici.fetch.call(void 0, input.url, {
|
|
208
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
209
|
+
});
|
|
191
210
|
if (!response.ok) {
|
|
192
211
|
throw new Error(
|
|
193
212
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
@@ -195,6 +214,11 @@ var imageContent = async (input) => {
|
|
|
195
214
|
}
|
|
196
215
|
rawData = Buffer.from(await response.arrayBuffer());
|
|
197
216
|
} catch (error) {
|
|
217
|
+
if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`Failed to fetch image from URL (${input.url}): timed out after ${timeoutMs}ms`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
198
222
|
throw new Error(
|
|
199
223
|
`Failed to fetch image from URL (${input.url}): ${error instanceof Error ? error.message : String(error)}`
|
|
200
224
|
);
|
|
@@ -239,8 +263,11 @@ var audioContent = async (input) => {
|
|
|
239
263
|
let rawData;
|
|
240
264
|
try {
|
|
241
265
|
if ("url" in input) {
|
|
266
|
+
const timeoutMs = _nullishCoalesce(input.timeoutMs, () => ( MEDIA_FETCH_TIMEOUT_MS));
|
|
242
267
|
try {
|
|
243
|
-
const response = await _undici.fetch.call(void 0, input.url
|
|
268
|
+
const response = await _undici.fetch.call(void 0, input.url, {
|
|
269
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
270
|
+
});
|
|
244
271
|
if (!response.ok) {
|
|
245
272
|
throw new Error(
|
|
246
273
|
`Server responded with status: ${response.status} - ${response.statusText}`
|
|
@@ -248,6 +275,11 @@ var audioContent = async (input) => {
|
|
|
248
275
|
}
|
|
249
276
|
rawData = Buffer.from(await response.arrayBuffer());
|
|
250
277
|
} catch (error) {
|
|
278
|
+
if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
279
|
+
throw new Error(
|
|
280
|
+
`Failed to fetch audio from URL (${input.url}): timed out after ${timeoutMs}ms`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
251
283
|
throw new Error(
|
|
252
284
|
`Failed to fetch audio from URL (${input.url}): ${error instanceof Error ? error.message : String(error)}`
|
|
253
285
|
);
|
|
@@ -306,6 +338,23 @@ var UnexpectedStateError = class extends FastMCPError {
|
|
|
306
338
|
};
|
|
307
339
|
var UserError = class extends UnexpectedStateError {
|
|
308
340
|
};
|
|
341
|
+
function assertStandardSchema(toolName, schemaName, schema) {
|
|
342
|
+
const standard = schema["~standard"];
|
|
343
|
+
if (typeof _optionalChain([standard, 'optionalAccess', _8 => _8.validate]) === "function") {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
throw new UserError(
|
|
347
|
+
`Tool '${toolName}' ${schemaName} must implement Standard Schema. If you are using Zod, upgrade to version 3.24 or later.`
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
function assertToolSchemas(tool) {
|
|
351
|
+
if (tool.parameters) {
|
|
352
|
+
assertStandardSchema(tool.name, "parameters", tool.parameters);
|
|
353
|
+
}
|
|
354
|
+
if (tool.outputSchema) {
|
|
355
|
+
assertStandardSchema(tool.name, "outputSchema", tool.outputSchema);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
309
358
|
var TextContentZodSchema = _zod.z.object({
|
|
310
359
|
/**
|
|
311
360
|
* The text content of the message.
|
|
@@ -553,10 +602,10 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
553
602
|
);
|
|
554
603
|
}
|
|
555
604
|
}
|
|
556
|
-
if (_optionalChain([this, 'access',
|
|
605
|
+
if (_optionalChain([this, 'access', _9 => _9.#rootsConfig, 'optionalAccess', _10 => _10.enabled]) !== false && _optionalChain([this, 'access', _11 => _11.#clientCapabilities, 'optionalAccess', _12 => _12.roots, 'optionalAccess', _13 => _13.listChanged]) && typeof this.#server.listRoots === "function") {
|
|
557
606
|
try {
|
|
558
607
|
const roots = await this.#server.listRoots();
|
|
559
|
-
this.#roots = _optionalChain([roots, 'optionalAccess',
|
|
608
|
+
this.#roots = _optionalChain([roots, 'optionalAccess', _14 => _14.roots]) || [];
|
|
560
609
|
} catch (e) {
|
|
561
610
|
if (e instanceof _typesjs.McpError && e.code === _typesjs.ErrorCode.MethodNotFound) {
|
|
562
611
|
this.#logger.debug(
|
|
@@ -729,7 +778,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
729
778
|
},
|
|
730
779
|
elicit: (params, options) => this.#server.elicitInput(params, options),
|
|
731
780
|
log: this.#createLog(),
|
|
732
|
-
requestId: typeof _optionalChain([meta, 'optionalAccess',
|
|
781
|
+
requestId: typeof _optionalChain([meta, 'optionalAccess', _15 => _15.requestId]) === "string" ? meta.requestId : void 0,
|
|
733
782
|
session: this.#auth,
|
|
734
783
|
sessionId: this.#sessionId
|
|
735
784
|
};
|
|
@@ -775,8 +824,8 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
775
824
|
};
|
|
776
825
|
}
|
|
777
826
|
#formatSchemaIssues(issues) {
|
|
778
|
-
return _optionalChain([this, 'access',
|
|
779
|
-
const path = _optionalChain([issue, 'access',
|
|
827
|
+
return _optionalChain([this, 'access', _16 => _16.#utils, 'optionalAccess', _17 => _17.formatInvalidParamsErrorMessage]) ? this.#utils.formatInvalidParamsErrorMessage(issues) : issues.map((issue) => {
|
|
828
|
+
const path = _optionalChain([issue, 'access', _18 => _18.path, 'optionalAccess', _19 => _19.join, 'call', _20 => _20(".")]) || "root";
|
|
780
829
|
return `${path}: ${issue.message}`;
|
|
781
830
|
}).join(", ");
|
|
782
831
|
}
|
|
@@ -988,7 +1037,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
988
1037
|
result = await prompt.load(
|
|
989
1038
|
args,
|
|
990
1039
|
this.#auth,
|
|
991
|
-
this.#createLoadContext(_optionalChain([request, 'access',
|
|
1040
|
+
this.#createLoadContext(_optionalChain([request, 'access', _21 => _21.params, 'optionalAccess', _22 => _22._meta]))
|
|
992
1041
|
);
|
|
993
1042
|
} catch (error) {
|
|
994
1043
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1053,7 +1102,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1053
1102
|
const result = await resourceTemplate.load(
|
|
1054
1103
|
match,
|
|
1055
1104
|
this.#auth,
|
|
1056
|
-
this.#createLoadContext(_optionalChain([request, 'access',
|
|
1105
|
+
this.#createLoadContext(_optionalChain([request, 'access', _23 => _23.params, 'optionalAccess', _24 => _24._meta]))
|
|
1057
1106
|
);
|
|
1058
1107
|
const resources = Array.isArray(result) ? result : [result];
|
|
1059
1108
|
return {
|
|
@@ -1078,7 +1127,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1078
1127
|
try {
|
|
1079
1128
|
maybeArrayResult = await resource.load(
|
|
1080
1129
|
this.#auth,
|
|
1081
|
-
this.#createLoadContext(_optionalChain([request, 'access',
|
|
1130
|
+
this.#createLoadContext(_optionalChain([request, 'access', _25 => _25.params, 'optionalAccess', _26 => _26._meta]))
|
|
1082
1131
|
);
|
|
1083
1132
|
} catch (error) {
|
|
1084
1133
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1141,7 +1190,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1141
1190
|
);
|
|
1142
1191
|
}
|
|
1143
1192
|
setupRootsHandlers() {
|
|
1144
|
-
if (_optionalChain([this, 'access',
|
|
1193
|
+
if (_optionalChain([this, 'access', _27 => _27.#rootsConfig, 'optionalAccess', _28 => _28.enabled]) === false) {
|
|
1145
1194
|
this.#logger.debug(
|
|
1146
1195
|
"[FastMCP debug] roots capability explicitly disabled via config"
|
|
1147
1196
|
);
|
|
@@ -1233,7 +1282,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1233
1282
|
}
|
|
1234
1283
|
args = parsed.value;
|
|
1235
1284
|
}
|
|
1236
|
-
const progressToken = _optionalChain([request, 'access',
|
|
1285
|
+
const progressToken = _optionalChain([request, 'access', _29 => _29.params, 'optionalAccess', _30 => _30._meta, 'optionalAccess', _31 => _31.progressToken]);
|
|
1237
1286
|
let result;
|
|
1238
1287
|
try {
|
|
1239
1288
|
const reportProgress = async (progress) => {
|
|
@@ -1292,7 +1341,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1292
1341
|
elicit: (params, options) => this.#server.elicitInput(params, options),
|
|
1293
1342
|
log,
|
|
1294
1343
|
reportProgress,
|
|
1295
|
-
requestId: typeof _optionalChain([request, 'access',
|
|
1344
|
+
requestId: typeof _optionalChain([request, 'access', _32 => _32.params, 'optionalAccess', _33 => _33._meta, 'optionalAccess', _34 => _34.requestId]) === "string" ? request.params._meta.requestId : void 0,
|
|
1296
1345
|
session: this.#auth,
|
|
1297
1346
|
sessionId: this.#sessionId,
|
|
1298
1347
|
streamContent
|
|
@@ -1402,7 +1451,7 @@ function normalizePath(path) {
|
|
|
1402
1451
|
return path.startsWith("/") ? path : `/${path}`;
|
|
1403
1452
|
}
|
|
1404
1453
|
function parseBasicAuthHeader(authHeader) {
|
|
1405
|
-
const basicMatch = _optionalChain([authHeader, 'optionalAccess',
|
|
1454
|
+
const basicMatch = _optionalChain([authHeader, 'optionalAccess', _35 => _35.match, 'call', _36 => _36(/^Basic\s+(.+)$/)]);
|
|
1406
1455
|
if (!basicMatch) return null;
|
|
1407
1456
|
try {
|
|
1408
1457
|
const credentials = Buffer.from(basicMatch[1], "base64").toString("utf-8");
|
|
@@ -1544,6 +1593,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1544
1593
|
* Adds a tool to the server.
|
|
1545
1594
|
*/
|
|
1546
1595
|
addTool(tool) {
|
|
1596
|
+
assertToolSchemas(tool);
|
|
1547
1597
|
this.#tools = this.#tools.filter((t) => t.name !== tool.name);
|
|
1548
1598
|
this.#tools.push(tool);
|
|
1549
1599
|
if (this.#serverState === "running" /* Running */) {
|
|
@@ -1554,6 +1604,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1554
1604
|
* Adds tools to the server.
|
|
1555
1605
|
*/
|
|
1556
1606
|
addTools(tools) {
|
|
1607
|
+
tools.forEach(assertToolSchemas);
|
|
1557
1608
|
const newToolNames = new Set(tools.map((tool) => tool.name));
|
|
1558
1609
|
this.#tools = this.#tools.filter((t) => !newToolNames.has(t.name));
|
|
1559
1610
|
this.#tools.push(...tools);
|
|
@@ -1883,7 +1934,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1883
1934
|
enableJsonResponse: httpConfig.enableJsonResponse,
|
|
1884
1935
|
eventStore: httpConfig.eventStore,
|
|
1885
1936
|
host: httpConfig.host,
|
|
1886
|
-
..._optionalChain([this, 'access',
|
|
1937
|
+
..._optionalChain([this, 'access', _37 => _37.#options, 'access', _38 => _38.oauth, 'optionalAccess', _39 => _39.enabled]) && _optionalChain([this, 'access', _40 => _40.#options, 'access', _41 => _41.oauth, 'access', _42 => _42.protectedResource, 'optionalAccess', _43 => _43.resource]) ? {
|
|
1887
1938
|
oauth: {
|
|
1888
1939
|
protectedResource: {
|
|
1889
1940
|
resource: this.#options.oauth.protectedResource.resource
|
|
@@ -1930,7 +1981,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
1930
1981
|
enableJsonResponse: httpConfig.enableJsonResponse,
|
|
1931
1982
|
eventStore: httpConfig.eventStore,
|
|
1932
1983
|
host: httpConfig.host,
|
|
1933
|
-
..._optionalChain([this, 'access',
|
|
1984
|
+
..._optionalChain([this, 'access', _44 => _44.#options, 'access', _45 => _45.oauth, 'optionalAccess', _46 => _46.enabled]) && _optionalChain([this, 'access', _47 => _47.#options, 'access', _48 => _48.oauth, 'access', _49 => _49.protectedResource, 'optionalAccess', _50 => _50.resource]) ? {
|
|
1934
1985
|
oauth: {
|
|
1935
1986
|
protectedResource: {
|
|
1936
1987
|
resource: this.#options.oauth.protectedResource.resource
|
|
@@ -2032,7 +2083,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2032
2083
|
*/
|
|
2033
2084
|
#createUnauthorizedResponse(message) {
|
|
2034
2085
|
const oauth = this.#options.oauth;
|
|
2035
|
-
const resource = _optionalChain([oauth, 'optionalAccess',
|
|
2086
|
+
const resource = _optionalChain([oauth, 'optionalAccess', _51 => _51.enabled]) ? _optionalChain([oauth, 'access', _52 => _52.protectedResource, 'optionalAccess', _53 => _53.resource]) : void 0;
|
|
2036
2087
|
const wwwAuthenticateParts = [
|
|
2037
2088
|
'error="invalid_token"',
|
|
2038
2089
|
`error_description="${message.replace(/"/g, '\\"')}"`
|
|
@@ -2144,7 +2195,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2144
2195
|
}
|
|
2145
2196
|
}
|
|
2146
2197
|
const oauthConfig = this.#options.oauth;
|
|
2147
|
-
if (_optionalChain([oauthConfig, 'optionalAccess',
|
|
2198
|
+
if (_optionalChain([oauthConfig, 'optionalAccess', _54 => _54.enabled]) && req.method === "GET") {
|
|
2148
2199
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
2149
2200
|
const authorizationServerMetadataPath = joinPaths(
|
|
2150
2201
|
"",
|
|
@@ -2178,8 +2229,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2178
2229
|
}
|
|
2179
2230
|
}
|
|
2180
2231
|
}
|
|
2181
|
-
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess',
|
|
2182
|
-
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess',
|
|
2232
|
+
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess', _55 => _55.proxy]);
|
|
2233
|
+
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess', _56 => _56.enabled])) {
|
|
2183
2234
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
2184
2235
|
const oauthPath = basePathRelativePath;
|
|
2185
2236
|
try {
|
|
@@ -2196,7 +2247,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2196
2247
|
const statusCode = error.statusCode || 400;
|
|
2197
2248
|
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
2198
2249
|
JSON.stringify(
|
|
2199
|
-
_optionalChain([error, 'access',
|
|
2250
|
+
_optionalChain([error, 'access', _57 => _57.toJSON, 'optionalCall', _58 => _58()]) || {
|
|
2200
2251
|
error: "invalid_request"
|
|
2201
2252
|
}
|
|
2202
2253
|
)
|
|
@@ -2223,7 +2274,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2223
2274
|
} catch (error) {
|
|
2224
2275
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2225
2276
|
JSON.stringify(
|
|
2226
|
-
_optionalChain([error, 'access',
|
|
2277
|
+
_optionalChain([error, 'access', _59 => _59.toJSON, 'optionalCall', _60 => _60()]) || {
|
|
2227
2278
|
error: "invalid_request"
|
|
2228
2279
|
}
|
|
2229
2280
|
)
|
|
@@ -2245,7 +2296,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2245
2296
|
} catch (error) {
|
|
2246
2297
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2247
2298
|
JSON.stringify(
|
|
2248
|
-
_optionalChain([error, 'access',
|
|
2299
|
+
_optionalChain([error, 'access', _61 => _61.toJSON, 'optionalCall', _62 => _62()]) || {
|
|
2249
2300
|
error: "server_error"
|
|
2250
2301
|
}
|
|
2251
2302
|
)
|
|
@@ -2280,7 +2331,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2280
2331
|
} catch (error) {
|
|
2281
2332
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2282
2333
|
JSON.stringify(
|
|
2283
|
-
_optionalChain([error, 'access',
|
|
2334
|
+
_optionalChain([error, 'access', _63 => _63.toJSON, 'optionalCall', _64 => _64()]) || {
|
|
2284
2335
|
error: "server_error"
|
|
2285
2336
|
}
|
|
2286
2337
|
)
|
|
@@ -2302,8 +2353,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2302
2353
|
const basicAuth = parseBasicAuthHeader(
|
|
2303
2354
|
req.headers.authorization
|
|
2304
2355
|
);
|
|
2305
|
-
const clientId = _optionalChain([basicAuth, 'optionalAccess',
|
|
2306
|
-
const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess',
|
|
2356
|
+
const clientId = _optionalChain([basicAuth, 'optionalAccess', _65 => _65.clientId]) || params.get("client_id") || "";
|
|
2357
|
+
const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess', _66 => _66.clientSecret]), () => ( params.get("client_secret"))), () => ( void 0));
|
|
2307
2358
|
let response;
|
|
2308
2359
|
if (grantType === "authorization_code") {
|
|
2309
2360
|
response = await oauthProxy.exchangeAuthorizationCode({
|
|
@@ -2333,7 +2384,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2333
2384
|
const statusCode = error.statusCode || 400;
|
|
2334
2385
|
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
2335
2386
|
JSON.stringify(
|
|
2336
|
-
_optionalChain([error, 'access',
|
|
2387
|
+
_optionalChain([error, 'access', _67 => _67.toJSON, 'optionalCall', _68 => _68()]) || {
|
|
2337
2388
|
error: "invalid_request"
|
|
2338
2389
|
}
|
|
2339
2390
|
)
|
|
@@ -2404,23 +2455,23 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2404
2455
|
const envBasePath = process.env.FASTMCP_BASE_PATH;
|
|
2405
2456
|
const envStateless = process.env.FASTMCP_STATELESS;
|
|
2406
2457
|
const envHost = process.env.FASTMCP_HOST;
|
|
2407
|
-
const transportType = _optionalChain([overrides, 'optionalAccess',
|
|
2458
|
+
const transportType = _optionalChain([overrides, 'optionalAccess', _69 => _69.transportType]) || (transportArg === "http-stream" ? "httpStream" : transportArg) || envTransport || "stdio";
|
|
2408
2459
|
if (transportType === "httpStream") {
|
|
2409
2460
|
const port = parseInt(
|
|
2410
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
2461
|
+
_optionalChain([overrides, 'optionalAccess', _70 => _70.httpStream, 'optionalAccess', _71 => _71.port, 'optionalAccess', _72 => _72.toString, 'call', _73 => _73()]) || portArg || envPort || "8080"
|
|
2411
2462
|
);
|
|
2412
|
-
const host = _optionalChain([overrides, 'optionalAccess',
|
|
2413
|
-
const endpoint = _optionalChain([overrides, 'optionalAccess',
|
|
2463
|
+
const host = _optionalChain([overrides, 'optionalAccess', _74 => _74.httpStream, 'optionalAccess', _75 => _75.host]) || hostArg || envHost || "localhost";
|
|
2464
|
+
const endpoint = _optionalChain([overrides, 'optionalAccess', _76 => _76.httpStream, 'optionalAccess', _77 => _77.endpoint]) || endpointArg || envEndpoint || "/mcp";
|
|
2414
2465
|
const basePath = normalizeBasePath(
|
|
2415
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
2466
|
+
_optionalChain([overrides, 'optionalAccess', _78 => _78.httpStream, 'optionalAccess', _79 => _79.basePath]) || basePathArg || envBasePath
|
|
2416
2467
|
);
|
|
2417
|
-
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess',
|
|
2418
|
-
const stateless = _optionalChain([overrides, 'optionalAccess',
|
|
2419
|
-
const cors = _optionalChain([overrides, 'optionalAccess',
|
|
2420
|
-
const eventStore = _optionalChain([overrides, 'optionalAccess',
|
|
2421
|
-
const sslCa = _optionalChain([overrides, 'optionalAccess',
|
|
2422
|
-
const sslCert = _optionalChain([overrides, 'optionalAccess',
|
|
2423
|
-
const sslKey = _optionalChain([overrides, 'optionalAccess',
|
|
2468
|
+
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess', _80 => _80.httpStream, 'optionalAccess', _81 => _81.enableJsonResponse]) || false;
|
|
2469
|
+
const stateless = _optionalChain([overrides, 'optionalAccess', _82 => _82.httpStream, 'optionalAccess', _83 => _83.stateless]) || statelessArg === "true" || envStateless === "true" || false;
|
|
2470
|
+
const cors = _optionalChain([overrides, 'optionalAccess', _84 => _84.httpStream, 'optionalAccess', _85 => _85.cors]);
|
|
2471
|
+
const eventStore = _optionalChain([overrides, 'optionalAccess', _86 => _86.httpStream, 'optionalAccess', _87 => _87.eventStore]);
|
|
2472
|
+
const sslCa = _optionalChain([overrides, 'optionalAccess', _88 => _88.httpStream, 'optionalAccess', _89 => _89.sslCa]);
|
|
2473
|
+
const sslCert = _optionalChain([overrides, 'optionalAccess', _90 => _90.httpStream, 'optionalAccess', _91 => _91.sslCert]);
|
|
2474
|
+
const sslKey = _optionalChain([overrides, 'optionalAccess', _92 => _92.httpStream, 'optionalAccess', _93 => _93.sslKey]);
|
|
2424
2475
|
return {
|
|
2425
2476
|
httpStream: {
|
|
2426
2477
|
basePath,
|
|
@@ -2495,5 +2546,6 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2495
2546
|
|
|
2496
2547
|
|
|
2497
2548
|
|
|
2498
|
-
|
|
2499
|
-
|
|
2549
|
+
|
|
2550
|
+
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;
|
|
2551
|
+
//# sourceMappingURL=chunk-DD63MJG7.cjs.map
|