fastmcp 4.22.9 → 4.22.10
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 +2 -2
- package/dist/FastMCP.d.cts +2 -1
- package/dist/FastMCP.d.ts +2 -1
- package/dist/FastMCP.js +1 -1
- package/dist/{chunk-YDWOFVQN.cjs → chunk-RE2YJZA6.cjs} +58 -66
- package/dist/chunk-RE2YJZA6.cjs.map +1 -0
- package/dist/{chunk-PVW7IVUE.js → chunk-RVBVCLCO.js} +33 -41
- package/dist/chunk-RVBVCLCO.js.map +1 -0
- package/dist/examples/custom-routes.cjs +2 -2
- package/dist/examples/custom-routes.js +1 -1
- package/dist/openapi/index.cjs +6 -6
- package/dist/openapi/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-PVW7IVUE.js.map +0 -1
- package/dist/chunk-YDWOFVQN.cjs.map +0 -1
|
@@ -2005,7 +2005,8 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2005
2005
|
*
|
|
2006
2006
|
* The transport's lifecycle belongs to the caller: `stop()` does not close
|
|
2007
2007
|
* transports passed here. Close the returned session (or the transport) when
|
|
2008
|
-
* you are done with it.
|
|
2008
|
+
* you are done with it. If the client hangs up before the session is set up,
|
|
2009
|
+
* the returned session is already closed and is not listed in `sessions`.
|
|
2009
2010
|
*
|
|
2010
2011
|
* @param transport - An already-constructed MCP server transport.
|
|
2011
2012
|
* @param auth - Session auth, equivalent to what `authenticate` would return.
|
|
@@ -2013,21 +2014,7 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2013
2014
|
*/
|
|
2014
2015
|
async connect(transport, auth) {
|
|
2015
2016
|
const session = this.#createSession(auth);
|
|
2016
|
-
await session
|
|
2017
|
-
this.#sessions.push(session);
|
|
2018
|
-
session.once("error", () => {
|
|
2019
|
-
this.#removeSession(session);
|
|
2020
|
-
});
|
|
2021
|
-
const originalOnClose = transport.onclose;
|
|
2022
|
-
transport.onclose = () => {
|
|
2023
|
-
this.#removeSession(session);
|
|
2024
|
-
if (originalOnClose) {
|
|
2025
|
-
originalOnClose();
|
|
2026
|
-
}
|
|
2027
|
-
};
|
|
2028
|
-
this.emit("connect", {
|
|
2029
|
-
session
|
|
2030
|
-
});
|
|
2017
|
+
await this.#connectSession(session, transport);
|
|
2031
2018
|
this.#serverState = "running" /* Running */;
|
|
2032
2019
|
return session;
|
|
2033
2020
|
}
|
|
@@ -2265,7 +2252,6 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2265
2252
|
version: this.#options.version,
|
|
2266
2253
|
websiteUrl: this.#options.websiteUrl
|
|
2267
2254
|
});
|
|
2268
|
-
await session.connect(transport);
|
|
2269
2255
|
let stdinClosed = false;
|
|
2270
2256
|
const onStdinClose = () => {
|
|
2271
2257
|
if (stdinClosed) return;
|
|
@@ -2277,29 +2263,9 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2277
2263
|
};
|
|
2278
2264
|
process.stdin.on("close", onStdinClose);
|
|
2279
2265
|
process.stdin.on("end", onStdinClose);
|
|
2280
|
-
this.#
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
});
|
|
2284
|
-
if (transport.onclose) {
|
|
2285
|
-
const originalOnClose = transport.onclose;
|
|
2286
|
-
transport.onclose = () => {
|
|
2287
|
-
process.stdin.off("close", onStdinClose);
|
|
2288
|
-
process.stdin.off("end", onStdinClose);
|
|
2289
|
-
this.#removeSession(session);
|
|
2290
|
-
if (originalOnClose) {
|
|
2291
|
-
originalOnClose();
|
|
2292
|
-
}
|
|
2293
|
-
};
|
|
2294
|
-
} else {
|
|
2295
|
-
transport.onclose = () => {
|
|
2296
|
-
process.stdin.off("close", onStdinClose);
|
|
2297
|
-
process.stdin.off("end", onStdinClose);
|
|
2298
|
-
this.#removeSession(session);
|
|
2299
|
-
};
|
|
2300
|
-
}
|
|
2301
|
-
this.emit("connect", {
|
|
2302
|
-
session
|
|
2266
|
+
await this.#connectSession(session, transport, () => {
|
|
2267
|
+
process.stdin.off("close", onStdinClose);
|
|
2268
|
+
process.stdin.off("end", onStdinClose);
|
|
2303
2269
|
});
|
|
2304
2270
|
this.#serverState = "running" /* Running */;
|
|
2305
2271
|
} else if (config.transportType === "httpStream") {
|
|
@@ -2421,6 +2387,32 @@ var FastMCP = class extends FastMCPEventEmitter {
|
|
|
2421
2387
|
}
|
|
2422
2388
|
this.#serverState = "stopped" /* Stopped */;
|
|
2423
2389
|
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Connects `session` to `transport` and lists it in `sessions` until the
|
|
2392
|
+
* transport closes. The close is watched from before the session connects,
|
|
2393
|
+
* so a client that hangs up during setup leaves no session behind.
|
|
2394
|
+
*/
|
|
2395
|
+
async #connectSession(session, transport, onClose) {
|
|
2396
|
+
let closed = false;
|
|
2397
|
+
const originalOnClose = transport.onclose;
|
|
2398
|
+
transport.onclose = () => {
|
|
2399
|
+
closed = true;
|
|
2400
|
+
onClose?.();
|
|
2401
|
+
this.#removeSession(session);
|
|
2402
|
+
originalOnClose?.();
|
|
2403
|
+
};
|
|
2404
|
+
await session.connect(transport);
|
|
2405
|
+
if (closed) {
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
this.#sessions.push(session);
|
|
2409
|
+
session.once("error", () => {
|
|
2410
|
+
this.#removeSession(session);
|
|
2411
|
+
});
|
|
2412
|
+
this.emit("connect", {
|
|
2413
|
+
session
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2424
2416
|
/**
|
|
2425
2417
|
* Creates a new FastMCPSession instance with the current configuration.
|
|
2426
2418
|
* Used both for regular sessions and stateless requests.
|
|
@@ -3177,4 +3169,4 @@ export {
|
|
|
3177
3169
|
FastMCPSession,
|
|
3178
3170
|
FastMCP
|
|
3179
3171
|
};
|
|
3180
|
-
//# sourceMappingURL=chunk-
|
|
3172
|
+
//# sourceMappingURL=chunk-RVBVCLCO.js.map
|