fastmcp 4.15.2 → 4.16.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.
- package/README.md +44 -0
- package/dist/FastMCP.cjs +2 -2
- package/dist/FastMCP.d.cts +27 -6
- package/dist/FastMCP.d.ts +27 -6
- package/dist/FastMCP.js +1 -1
- package/dist/{chunk-4VIPI4GU.js → chunk-EL6BTW4Y.js} +53 -13
- package/dist/chunk-EL6BTW4Y.js.map +1 -0
- package/dist/{chunk-N6ZZF5YB.cjs → chunk-RCOJI5RM.cjs} +93 -53
- package/dist/chunk-RCOJI5RM.cjs.map +1 -0
- package/dist/examples/custom-routes.cjs +2 -2
- package/dist/examples/custom-routes.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4VIPI4GU.js.map +0 -1
- package/dist/chunk-N6ZZF5YB.cjs.map +0 -1
|
@@ -467,21 +467,38 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
467
467
|
/**
|
|
468
468
|
* The HTTP session ID, or `undefined` for transports that do not have one.
|
|
469
469
|
*
|
|
470
|
-
* Resolved from the transport
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
*
|
|
470
|
+
* Resolved from the transport rather than captured when the session
|
|
471
|
+
* connects: `StreamableHTTPServerTransport` assigns its `sessionId` while it
|
|
472
|
+
* handles `initialize`, which happens after `connect()` resolves. A value
|
|
473
|
+
* read at connect time is therefore still `undefined`.
|
|
474
|
+
*
|
|
475
|
+
* The first ID seen is latched, so the session keeps reporting it once the
|
|
476
|
+
* transport detaches — `Protocol` drops its transport reference on close,
|
|
477
|
+
* which would otherwise make the ID vanish mid-teardown. Latching is safe
|
|
478
|
+
* because {@link connect} refuses a second transport, so a session never
|
|
479
|
+
* sees two IDs.
|
|
474
480
|
*/
|
|
475
481
|
get sessionId() {
|
|
476
|
-
if (this.#sessionId
|
|
477
|
-
|
|
482
|
+
if (this.#sessionId === void 0) {
|
|
483
|
+
const transportSessionId = _optionalChain([this, 'access', _9 => _9.#server, 'access', _10 => _10.transport, 'optionalAccess', _11 => _11.sessionId]);
|
|
484
|
+
if (typeof transportSessionId === "string") {
|
|
485
|
+
this.#sessionId = transportSessionId;
|
|
486
|
+
}
|
|
478
487
|
}
|
|
479
|
-
|
|
480
|
-
return typeof _optionalChain([transport, 'optionalAccess', _9 => _9.sessionId]) === "string" ? transport.sessionId : void 0;
|
|
488
|
+
return this.#sessionId;
|
|
481
489
|
}
|
|
482
490
|
set sessionId(value) {
|
|
483
491
|
this.#sessionId = value;
|
|
484
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* Aborted once the session ends, and folded into the `signal` every tool
|
|
495
|
+
* call receives. The MCP SDK only aborts a request's own signal for an
|
|
496
|
+
* explicit `notifications/cancelled`, and neither `Protocol` nor
|
|
497
|
+
* `StreamableHTTPServerTransport` touches it when the transport simply goes
|
|
498
|
+
* away — so without this a tool keeps running after the client that asked
|
|
499
|
+
* for it has hung up.
|
|
500
|
+
*/
|
|
501
|
+
#abortController = new AbortController();
|
|
485
502
|
#auth;
|
|
486
503
|
#capabilities = {};
|
|
487
504
|
#clientCapabilities;
|
|
@@ -603,6 +620,7 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
603
620
|
if (this.#pingInterval) {
|
|
604
621
|
clearInterval(this.#pingInterval);
|
|
605
622
|
}
|
|
623
|
+
this.#abortSession();
|
|
606
624
|
try {
|
|
607
625
|
await this.#server.close();
|
|
608
626
|
} catch (error) {
|
|
@@ -634,10 +652,10 @@ var FastMCPSession = class extends FastMCPSessionEventEmitter {
|
|
|
634
652
|
);
|
|
635
653
|
}
|
|
636
654
|
}
|
|
637
|
-
if (_optionalChain([this, 'access',
|
|
655
|
+
if (_optionalChain([this, 'access', _12 => _12.#rootsConfig, 'optionalAccess', _13 => _13.enabled]) !== false && _optionalChain([this, 'access', _14 => _14.#clientCapabilities, 'optionalAccess', _15 => _15.roots, 'optionalAccess', _16 => _16.listChanged]) && typeof this.#server.listRoots === "function") {
|
|
638
656
|
try {
|
|
639
657
|
const roots = await this.#server.listRoots();
|
|
640
|
-
this.#roots = _optionalChain([roots, 'optionalAccess',
|
|
658
|
+
this.#roots = _optionalChain([roots, 'optionalAccess', _17 => _17.roots]) || [];
|
|
641
659
|
} catch (e) {
|
|
642
660
|
if (e instanceof _typesjs.McpError && e.code === _typesjs.ErrorCode.MethodNotFound) {
|
|
643
661
|
this.#logger.debug(
|
|
@@ -793,6 +811,16 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
793
811
|
});
|
|
794
812
|
});
|
|
795
813
|
}
|
|
814
|
+
/**
|
|
815
|
+
* Cancels the `signal` held by every tool still executing on this session.
|
|
816
|
+
* Idempotent, so the close path and the transport's own close handler can
|
|
817
|
+
* both call it.
|
|
818
|
+
*/
|
|
819
|
+
#abortSession() {
|
|
820
|
+
if (!this.#abortController.signal.aborted) {
|
|
821
|
+
this.#abortController.abort(new SessionError("Session closed"));
|
|
822
|
+
}
|
|
823
|
+
}
|
|
796
824
|
/**
|
|
797
825
|
* Builds the context object passed as the third argument to
|
|
798
826
|
* `resource.load` / `resourceTemplate.load` / `prompt.load`.
|
|
@@ -810,7 +838,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
810
838
|
},
|
|
811
839
|
elicit: (params, options) => this.#server.elicitInput(params, options),
|
|
812
840
|
log: this.#createLog(),
|
|
813
|
-
requestId: typeof _optionalChain([meta, 'optionalAccess',
|
|
841
|
+
requestId: typeof _optionalChain([meta, 'optionalAccess', _18 => _18.requestId]) === "string" ? meta.requestId : void 0,
|
|
814
842
|
session: this.#auth,
|
|
815
843
|
sessionId: this.sessionId
|
|
816
844
|
};
|
|
@@ -856,8 +884,8 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
856
884
|
};
|
|
857
885
|
}
|
|
858
886
|
#formatSchemaIssues(issues) {
|
|
859
|
-
return _optionalChain([this, 'access',
|
|
860
|
-
const path = _optionalChain([issue, 'access',
|
|
887
|
+
return _optionalChain([this, 'access', _19 => _19.#utils, 'optionalAccess', _20 => _20.formatInvalidParamsErrorMessage]) ? this.#utils.formatInvalidParamsErrorMessage(issues) : issues.map((issue) => {
|
|
888
|
+
const path = _optionalChain([issue, 'access', _21 => _21.path, 'optionalAccess', _22 => _22.join, 'call', _23 => _23(".")]) || "root";
|
|
861
889
|
return `${path}: ${issue.message}`;
|
|
862
890
|
}).join(", ");
|
|
863
891
|
}
|
|
@@ -888,7 +916,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
888
916
|
*/
|
|
889
917
|
#startStreamKeepalive(extra, toolName) {
|
|
890
918
|
const config = this.#streamKeepaliveConfig;
|
|
891
|
-
if (!_optionalChain([config, 'optionalAccess',
|
|
919
|
+
if (!_optionalChain([config, 'optionalAccess', _24 => _24.enabled])) {
|
|
892
920
|
return () => {
|
|
893
921
|
};
|
|
894
922
|
}
|
|
@@ -908,9 +936,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
908
936
|
);
|
|
909
937
|
});
|
|
910
938
|
}, intervalMs);
|
|
911
|
-
_optionalChain([timer, 'access',
|
|
939
|
+
_optionalChain([timer, 'access', _25 => _25.unref, 'optionalCall', _26 => _26()]);
|
|
912
940
|
const stop = () => clearInterval(timer);
|
|
913
|
-
_optionalChain([extra, 'access',
|
|
941
|
+
_optionalChain([extra, 'access', _27 => _27.signal, 'optionalAccess', _28 => _28.addEventListener, 'call', _29 => _29("abort", stop, { once: true })]);
|
|
914
942
|
return stop;
|
|
915
943
|
}
|
|
916
944
|
async #validateStructuredContent(tool, value, toolName) {
|
|
@@ -1062,6 +1090,9 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1062
1090
|
this.#server.onerror = (error) => {
|
|
1063
1091
|
this.#logger.error("[FastMCP error]", error);
|
|
1064
1092
|
};
|
|
1093
|
+
this.#server.onclose = () => {
|
|
1094
|
+
this.#abortSession();
|
|
1095
|
+
};
|
|
1065
1096
|
}
|
|
1066
1097
|
setupLoggingHandlers() {
|
|
1067
1098
|
this.#server.setRequestHandler(_typesjs.SetLevelRequestSchema, (request) => {
|
|
@@ -1111,7 +1142,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1111
1142
|
result = await prompt.load(
|
|
1112
1143
|
args,
|
|
1113
1144
|
this.#auth,
|
|
1114
|
-
this.#createLoadContext(_optionalChain([request, 'access',
|
|
1145
|
+
this.#createLoadContext(_optionalChain([request, 'access', _30 => _30.params, 'optionalAccess', _31 => _31._meta]))
|
|
1115
1146
|
);
|
|
1116
1147
|
} catch (error) {
|
|
1117
1148
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1176,7 +1207,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1176
1207
|
const result = await resourceTemplate.load(
|
|
1177
1208
|
match,
|
|
1178
1209
|
this.#auth,
|
|
1179
|
-
this.#createLoadContext(_optionalChain([request, 'access',
|
|
1210
|
+
this.#createLoadContext(_optionalChain([request, 'access', _32 => _32.params, 'optionalAccess', _33 => _33._meta]))
|
|
1180
1211
|
);
|
|
1181
1212
|
const resources = Array.isArray(result) ? result : [result];
|
|
1182
1213
|
return {
|
|
@@ -1201,7 +1232,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1201
1232
|
try {
|
|
1202
1233
|
maybeArrayResult = await resource.load(
|
|
1203
1234
|
this.#auth,
|
|
1204
|
-
this.#createLoadContext(_optionalChain([request, 'access',
|
|
1235
|
+
this.#createLoadContext(_optionalChain([request, 'access', _34 => _34.params, 'optionalAccess', _35 => _35._meta]))
|
|
1205
1236
|
);
|
|
1206
1237
|
} catch (error) {
|
|
1207
1238
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -1264,7 +1295,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1264
1295
|
);
|
|
1265
1296
|
}
|
|
1266
1297
|
setupRootsHandlers() {
|
|
1267
|
-
if (_optionalChain([this, 'access',
|
|
1298
|
+
if (_optionalChain([this, 'access', _36 => _36.#rootsConfig, 'optionalAccess', _37 => _37.enabled]) === false) {
|
|
1268
1299
|
this.#logger.debug(
|
|
1269
1300
|
"[FastMCP debug] roots capability explicitly disabled via config"
|
|
1270
1301
|
);
|
|
@@ -1358,7 +1389,7 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1358
1389
|
}
|
|
1359
1390
|
args = parsed.value;
|
|
1360
1391
|
}
|
|
1361
|
-
const progressToken = _optionalChain([request, 'access',
|
|
1392
|
+
const progressToken = _optionalChain([request, 'access', _38 => _38.params, 'optionalAccess', _39 => _39._meta, 'optionalAccess', _40 => _40.progressToken]);
|
|
1362
1393
|
let result;
|
|
1363
1394
|
try {
|
|
1364
1395
|
const reportProgress = async (progress) => {
|
|
@@ -1410,6 +1441,14 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1410
1441
|
toolName: request.params.name
|
|
1411
1442
|
});
|
|
1412
1443
|
}
|
|
1444
|
+
const timeoutAbort = new AbortController();
|
|
1445
|
+
const signal = AbortSignal.any([
|
|
1446
|
+
timeoutAbort.signal,
|
|
1447
|
+
this.#abortController.signal,
|
|
1448
|
+
// Only ever aborted for an explicit `notifications/cancelled`; the
|
|
1449
|
+
// session signal above is what covers a client that simply left.
|
|
1450
|
+
...extra.signal ? [extra.signal] : []
|
|
1451
|
+
]);
|
|
1413
1452
|
const executeToolPromise = Promise.resolve(
|
|
1414
1453
|
tool.execute(args, {
|
|
1415
1454
|
client: {
|
|
@@ -1418,9 +1457,10 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1418
1457
|
elicit: (params, options) => this.#server.elicitInput(params, options),
|
|
1419
1458
|
log,
|
|
1420
1459
|
reportProgress,
|
|
1421
|
-
requestId: typeof _optionalChain([request, 'access',
|
|
1460
|
+
requestId: typeof _optionalChain([request, 'access', _41 => _41.params, 'optionalAccess', _42 => _42._meta, 'optionalAccess', _43 => _43.requestId]) === "string" ? request.params._meta.requestId : void 0,
|
|
1422
1461
|
session: this.#auth,
|
|
1423
1462
|
sessionId: this.sessionId,
|
|
1463
|
+
signal,
|
|
1424
1464
|
streamContent
|
|
1425
1465
|
})
|
|
1426
1466
|
);
|
|
@@ -1432,11 +1472,11 @@ ${error instanceof Error ? error.stack : JSON.stringify(error)}`
|
|
|
1432
1472
|
executeToolPromise,
|
|
1433
1473
|
new Promise((_, reject) => {
|
|
1434
1474
|
const timeoutId = setTimeout(() => {
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
`Tool '${request.params.name}' timed out after ${tool.timeoutMs}ms. Consider increasing timeoutMs or optimizing the tool implementation.`
|
|
1438
|
-
)
|
|
1475
|
+
const timedOut = new UserError(
|
|
1476
|
+
`Tool '${request.params.name}' timed out after ${tool.timeoutMs}ms. Consider increasing timeoutMs or optimizing the tool implementation.`
|
|
1439
1477
|
);
|
|
1478
|
+
timeoutAbort.abort(timedOut);
|
|
1479
|
+
reject(timedOut);
|
|
1440
1480
|
}, tool.timeoutMs);
|
|
1441
1481
|
executeToolPromise.then(
|
|
1442
1482
|
() => clearTimeout(timeoutId),
|
|
@@ -1534,7 +1574,7 @@ function normalizePath(path) {
|
|
|
1534
1574
|
return path.startsWith("/") ? path : `/${path}`;
|
|
1535
1575
|
}
|
|
1536
1576
|
function parseBasicAuthHeader(authHeader) {
|
|
1537
|
-
const basicMatch = _optionalChain([authHeader, 'optionalAccess',
|
|
1577
|
+
const basicMatch = _optionalChain([authHeader, 'optionalAccess', _44 => _44.match, 'call', _45 => _45(/^Basic\s+(.+)$/)]);
|
|
1538
1578
|
if (!basicMatch) return null;
|
|
1539
1579
|
try {
|
|
1540
1580
|
const credentials = Buffer.from(basicMatch[1], "base64").toString("utf-8");
|
|
@@ -2019,7 +2059,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2019
2059
|
enableJsonResponse: httpConfig.enableJsonResponse,
|
|
2020
2060
|
eventStore: httpConfig.eventStore,
|
|
2021
2061
|
host: httpConfig.host,
|
|
2022
|
-
..._optionalChain([this, 'access',
|
|
2062
|
+
..._optionalChain([this, 'access', _46 => _46.#options, 'access', _47 => _47.oauth, 'optionalAccess', _48 => _48.enabled]) && _optionalChain([this, 'access', _49 => _49.#options, 'access', _50 => _50.oauth, 'access', _51 => _51.protectedResource, 'optionalAccess', _52 => _52.resource]) ? {
|
|
2023
2063
|
oauth: {
|
|
2024
2064
|
protectedResource: {
|
|
2025
2065
|
resource: this.#options.oauth.protectedResource.resource
|
|
@@ -2068,7 +2108,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2068
2108
|
enableJsonResponse: httpConfig.enableJsonResponse,
|
|
2069
2109
|
eventStore: httpConfig.eventStore,
|
|
2070
2110
|
host: httpConfig.host,
|
|
2071
|
-
..._optionalChain([this, 'access',
|
|
2111
|
+
..._optionalChain([this, 'access', _53 => _53.#options, 'access', _54 => _54.oauth, 'optionalAccess', _55 => _55.enabled]) && _optionalChain([this, 'access', _56 => _56.#options, 'access', _57 => _57.oauth, 'access', _58 => _58.protectedResource, 'optionalAccess', _59 => _59.resource]) ? {
|
|
2072
2112
|
oauth: {
|
|
2073
2113
|
protectedResource: {
|
|
2074
2114
|
resource: this.#options.oauth.protectedResource.resource
|
|
@@ -2174,7 +2214,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2174
2214
|
*/
|
|
2175
2215
|
#createUnauthorizedResponse(message) {
|
|
2176
2216
|
const oauth = this.#options.oauth;
|
|
2177
|
-
const resource = _optionalChain([oauth, 'optionalAccess',
|
|
2217
|
+
const resource = _optionalChain([oauth, 'optionalAccess', _60 => _60.enabled]) ? _optionalChain([oauth, 'access', _61 => _61.protectedResource, 'optionalAccess', _62 => _62.resource]) : void 0;
|
|
2178
2218
|
const wwwAuthenticateParts = [
|
|
2179
2219
|
'error="invalid_token"',
|
|
2180
2220
|
`error_description="${message.replace(/"/g, '\\"')}"`
|
|
@@ -2286,7 +2326,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2286
2326
|
}
|
|
2287
2327
|
}
|
|
2288
2328
|
const oauthConfig = this.#options.oauth;
|
|
2289
|
-
if (_optionalChain([oauthConfig, 'optionalAccess',
|
|
2329
|
+
if (_optionalChain([oauthConfig, 'optionalAccess', _63 => _63.enabled]) && req.method === "GET") {
|
|
2290
2330
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
2291
2331
|
const authorizationServerMetadataPath = joinPaths(
|
|
2292
2332
|
"",
|
|
@@ -2320,8 +2360,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2320
2360
|
}
|
|
2321
2361
|
}
|
|
2322
2362
|
}
|
|
2323
|
-
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess',
|
|
2324
|
-
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess',
|
|
2363
|
+
const oauthProxy = _optionalChain([oauthConfig, 'optionalAccess', _64 => _64.proxy]);
|
|
2364
|
+
if (oauthProxy && _optionalChain([oauthConfig, 'optionalAccess', _65 => _65.enabled])) {
|
|
2325
2365
|
const url2 = new URL(req.url || "", `http://${host}`);
|
|
2326
2366
|
const oauthPath = basePathRelativePath;
|
|
2327
2367
|
try {
|
|
@@ -2374,7 +2414,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2374
2414
|
const statusCode = error.statusCode || 400;
|
|
2375
2415
|
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
2376
2416
|
JSON.stringify(
|
|
2377
|
-
_optionalChain([error, 'access',
|
|
2417
|
+
_optionalChain([error, 'access', _66 => _66.toJSON, 'optionalCall', _67 => _67()]) || {
|
|
2378
2418
|
error: "invalid_request"
|
|
2379
2419
|
}
|
|
2380
2420
|
)
|
|
@@ -2401,7 +2441,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2401
2441
|
} catch (error) {
|
|
2402
2442
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2403
2443
|
JSON.stringify(
|
|
2404
|
-
_optionalChain([error, 'access',
|
|
2444
|
+
_optionalChain([error, 'access', _68 => _68.toJSON, 'optionalCall', _69 => _69()]) || {
|
|
2405
2445
|
error: "invalid_request"
|
|
2406
2446
|
}
|
|
2407
2447
|
)
|
|
@@ -2423,7 +2463,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2423
2463
|
} catch (error) {
|
|
2424
2464
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2425
2465
|
JSON.stringify(
|
|
2426
|
-
_optionalChain([error, 'access',
|
|
2466
|
+
_optionalChain([error, 'access', _70 => _70.toJSON, 'optionalCall', _71 => _71()]) || {
|
|
2427
2467
|
error: "server_error"
|
|
2428
2468
|
}
|
|
2429
2469
|
)
|
|
@@ -2492,7 +2532,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2492
2532
|
} catch (error) {
|
|
2493
2533
|
res.writeHead(400, { "Content-Type": "application/json" }).end(
|
|
2494
2534
|
JSON.stringify(
|
|
2495
|
-
_optionalChain([error, 'access',
|
|
2535
|
+
_optionalChain([error, 'access', _72 => _72.toJSON, 'optionalCall', _73 => _73()]) || {
|
|
2496
2536
|
error: "server_error"
|
|
2497
2537
|
}
|
|
2498
2538
|
)
|
|
@@ -2550,8 +2590,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2550
2590
|
const basicAuth = parseBasicAuthHeader(
|
|
2551
2591
|
req.headers.authorization
|
|
2552
2592
|
);
|
|
2553
|
-
const clientId = _optionalChain([basicAuth, 'optionalAccess',
|
|
2554
|
-
const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess',
|
|
2593
|
+
const clientId = _optionalChain([basicAuth, 'optionalAccess', _74 => _74.clientId]) || params.get("client_id") || "";
|
|
2594
|
+
const clientSecret = _nullishCoalesce(_nullishCoalesce(_optionalChain([basicAuth, 'optionalAccess', _75 => _75.clientSecret]), () => ( params.get("client_secret"))), () => ( void 0));
|
|
2555
2595
|
let response;
|
|
2556
2596
|
if (grantType === "authorization_code") {
|
|
2557
2597
|
response = await oauthProxy.exchangeAuthorizationCode({
|
|
@@ -2581,7 +2621,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2581
2621
|
const statusCode = error.statusCode || 400;
|
|
2582
2622
|
res.writeHead(statusCode, { "Content-Type": "application/json" }).end(
|
|
2583
2623
|
JSON.stringify(
|
|
2584
|
-
_optionalChain([error, 'access',
|
|
2624
|
+
_optionalChain([error, 'access', _76 => _76.toJSON, 'optionalCall', _77 => _77()]) || {
|
|
2585
2625
|
error: "invalid_request"
|
|
2586
2626
|
}
|
|
2587
2627
|
)
|
|
@@ -2652,23 +2692,23 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2652
2692
|
const envBasePath = process.env.FASTMCP_BASE_PATH;
|
|
2653
2693
|
const envStateless = process.env.FASTMCP_STATELESS;
|
|
2654
2694
|
const envHost = process.env.FASTMCP_HOST;
|
|
2655
|
-
const transportType = _optionalChain([overrides, 'optionalAccess',
|
|
2695
|
+
const transportType = _optionalChain([overrides, 'optionalAccess', _78 => _78.transportType]) || (transportArg === "http-stream" ? "httpStream" : transportArg) || envTransport || "stdio";
|
|
2656
2696
|
if (transportType === "httpStream") {
|
|
2657
2697
|
const port = parseInt(
|
|
2658
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
2698
|
+
_optionalChain([overrides, 'optionalAccess', _79 => _79.httpStream, 'optionalAccess', _80 => _80.port, 'optionalAccess', _81 => _81.toString, 'call', _82 => _82()]) || portArg || envPort || "8080"
|
|
2659
2699
|
);
|
|
2660
|
-
const host = _optionalChain([overrides, 'optionalAccess',
|
|
2661
|
-
const endpoint = _optionalChain([overrides, 'optionalAccess',
|
|
2700
|
+
const host = _optionalChain([overrides, 'optionalAccess', _83 => _83.httpStream, 'optionalAccess', _84 => _84.host]) || hostArg || envHost || "localhost";
|
|
2701
|
+
const endpoint = _optionalChain([overrides, 'optionalAccess', _85 => _85.httpStream, 'optionalAccess', _86 => _86.endpoint]) || endpointArg || envEndpoint || "/mcp";
|
|
2662
2702
|
const basePath = normalizeBasePath(
|
|
2663
|
-
_optionalChain([overrides, 'optionalAccess',
|
|
2703
|
+
_optionalChain([overrides, 'optionalAccess', _87 => _87.httpStream, 'optionalAccess', _88 => _88.basePath]) || basePathArg || envBasePath
|
|
2664
2704
|
);
|
|
2665
|
-
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess',
|
|
2666
|
-
const stateless = _optionalChain([overrides, 'optionalAccess',
|
|
2667
|
-
const cors = _optionalChain([overrides, 'optionalAccess',
|
|
2668
|
-
const eventStore = _optionalChain([overrides, 'optionalAccess',
|
|
2669
|
-
const sslCa = _optionalChain([overrides, 'optionalAccess',
|
|
2670
|
-
const sslCert = _optionalChain([overrides, 'optionalAccess',
|
|
2671
|
-
const sslKey = _optionalChain([overrides, 'optionalAccess',
|
|
2705
|
+
const enableJsonResponse = _optionalChain([overrides, 'optionalAccess', _89 => _89.httpStream, 'optionalAccess', _90 => _90.enableJsonResponse]) || false;
|
|
2706
|
+
const stateless = _optionalChain([overrides, 'optionalAccess', _91 => _91.httpStream, 'optionalAccess', _92 => _92.stateless]) || statelessArg === "true" || envStateless === "true" || false;
|
|
2707
|
+
const cors = _optionalChain([overrides, 'optionalAccess', _93 => _93.httpStream, 'optionalAccess', _94 => _94.cors]);
|
|
2708
|
+
const eventStore = _optionalChain([overrides, 'optionalAccess', _95 => _95.httpStream, 'optionalAccess', _96 => _96.eventStore]);
|
|
2709
|
+
const sslCa = _optionalChain([overrides, 'optionalAccess', _97 => _97.httpStream, 'optionalAccess', _98 => _98.sslCa]);
|
|
2710
|
+
const sslCert = _optionalChain([overrides, 'optionalAccess', _99 => _99.httpStream, 'optionalAccess', _100 => _100.sslCert]);
|
|
2711
|
+
const sslKey = _optionalChain([overrides, 'optionalAccess', _101 => _101.httpStream, 'optionalAccess', _102 => _102.sslKey]);
|
|
2672
2712
|
return {
|
|
2673
2713
|
httpStream: {
|
|
2674
2714
|
basePath,
|
|
@@ -2767,4 +2807,4 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2767
2807
|
|
|
2768
2808
|
|
|
2769
2809
|
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;
|
|
2770
|
-
//# sourceMappingURL=chunk-
|
|
2810
|
+
//# sourceMappingURL=chunk-RCOJI5RM.cjs.map
|