up-mcp-bridge 1.0.4 → 1.0.8
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/{chunk-D7PYIPZK.js → chunk-UOG5UZOF.js} +50 -2
- package/dist/client.js +1 -1
- package/dist/proxy.js +18 -2
- package/package.json +1 -1
|
@@ -18043,7 +18043,7 @@ var Client = class extends Protocol {
|
|
|
18043
18043
|
};
|
|
18044
18044
|
|
|
18045
18045
|
// package.json
|
|
18046
|
-
var version2 = "1.0.
|
|
18046
|
+
var version2 = "1.0.8";
|
|
18047
18047
|
|
|
18048
18048
|
// node_modules/pkce-challenge/dist/index.node.js
|
|
18049
18049
|
var crypto;
|
|
@@ -20151,7 +20151,8 @@ function mcpProxy({
|
|
|
20151
20151
|
ignoredTools = [],
|
|
20152
20152
|
reconnectFn,
|
|
20153
20153
|
reconnectOptions = { enabled: false, maxAttempts: 5, baseDelayMs: 1e3 },
|
|
20154
|
-
serverUrl
|
|
20154
|
+
serverUrl,
|
|
20155
|
+
onLocalClose
|
|
20155
20156
|
}) {
|
|
20156
20157
|
let transportToClientClosed = false;
|
|
20157
20158
|
let transportToServerClosed = false;
|
|
@@ -20560,8 +20561,12 @@ function mcpProxy({
|
|
|
20560
20561
|
return;
|
|
20561
20562
|
}
|
|
20562
20563
|
transportToClientClosed = true;
|
|
20564
|
+
log("[Lifecycle] Local transport closed (stdin closed by client)");
|
|
20563
20565
|
debugLog("Local transport closed, closing remote transport");
|
|
20564
20566
|
currentTransportToServer.close().catch(onServerError);
|
|
20567
|
+
if (onLocalClose) {
|
|
20568
|
+
onLocalClose();
|
|
20569
|
+
}
|
|
20565
20570
|
};
|
|
20566
20571
|
transportToClient.onerror = onClientError;
|
|
20567
20572
|
function onClientError(error2) {
|
|
@@ -21034,6 +21039,8 @@ async function parseCommandLineArgs(args, usage) {
|
|
|
21034
21039
|
}
|
|
21035
21040
|
function setupSignalHandlers(cleanup) {
|
|
21036
21041
|
let isShuttingDown = false;
|
|
21042
|
+
const initialPpid = process.ppid;
|
|
21043
|
+
log(`[Lifecycle] Parent PID: ${initialPpid}, My PID: ${process.pid}`);
|
|
21037
21044
|
const gracefulShutdown = async (signal) => {
|
|
21038
21045
|
if (isShuttingDown) {
|
|
21039
21046
|
log(`[Shutdown] Already shutting down, ignoring ${signal}`);
|
|
@@ -21052,9 +21059,50 @@ function setupSignalHandlers(cleanup) {
|
|
|
21052
21059
|
};
|
|
21053
21060
|
process.on("SIGINT", () => gracefulShutdown("SIGINT"));
|
|
21054
21061
|
process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
|
|
21062
|
+
process.on("SIGHUP", () => gracefulShutdown("SIGHUP"));
|
|
21063
|
+
const parentWatchdog = setInterval(() => {
|
|
21064
|
+
const currentPpid = process.ppid;
|
|
21065
|
+
if (currentPpid !== initialPpid) {
|
|
21066
|
+
log(`[Watchdog] Parent PID changed from ${initialPpid} to ${currentPpid} - parent died!`);
|
|
21067
|
+
clearInterval(parentWatchdog);
|
|
21068
|
+
gracefulShutdown("parent-died");
|
|
21069
|
+
}
|
|
21070
|
+
}, 500);
|
|
21055
21071
|
process.stdin.resume();
|
|
21056
21072
|
process.stdin.on("end", () => gracefulShutdown("stdin-end"));
|
|
21057
21073
|
process.stdin.on("close", () => gracefulShutdown("stdin-close"));
|
|
21074
|
+
process.stdin.on("error", (err) => {
|
|
21075
|
+
log(`[Lifecycle] stdin error: ${err.message}`);
|
|
21076
|
+
gracefulShutdown("stdin-error");
|
|
21077
|
+
});
|
|
21078
|
+
const stdinReadableCheck = setInterval(() => {
|
|
21079
|
+
if (!process.stdin.readable) {
|
|
21080
|
+
log("[Lifecycle] stdin is no longer readable");
|
|
21081
|
+
clearInterval(stdinReadableCheck);
|
|
21082
|
+
gracefulShutdown("stdin-not-readable");
|
|
21083
|
+
}
|
|
21084
|
+
}, 100);
|
|
21085
|
+
process.on("disconnect", () => gracefulShutdown("disconnect"));
|
|
21086
|
+
process.stdout.on("error", (err) => {
|
|
21087
|
+
log(`[Lifecycle] stdout error: ${err.message}`);
|
|
21088
|
+
if (err.message.includes("EPIPE") || err.message.includes("write after end")) {
|
|
21089
|
+
gracefulShutdown("stdout-epipe");
|
|
21090
|
+
}
|
|
21091
|
+
});
|
|
21092
|
+
process.on("uncaughtException", (err) => {
|
|
21093
|
+
log(`[Lifecycle] Uncaught exception: ${err.message}`);
|
|
21094
|
+
gracefulShutdown("uncaught-exception");
|
|
21095
|
+
});
|
|
21096
|
+
process.on("unhandledRejection", (reason) => {
|
|
21097
|
+
log(`[Lifecycle] Unhandled rejection: ${reason}`);
|
|
21098
|
+
gracefulShutdown("unhandled-rejection");
|
|
21099
|
+
});
|
|
21100
|
+
process.on("beforeExit", (code) => {
|
|
21101
|
+
log(`[Lifecycle] beforeExit with code ${code}`);
|
|
21102
|
+
if (!isShuttingDown) {
|
|
21103
|
+
gracefulShutdown("beforeExit");
|
|
21104
|
+
}
|
|
21105
|
+
});
|
|
21058
21106
|
}
|
|
21059
21107
|
function getServerUrlHash(serverUrl, authorizeResource, headers) {
|
|
21060
21108
|
const parts = [serverUrl];
|
package/dist/client.js
CHANGED
package/dist/proxy.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
parseCommandLineArgs,
|
|
12
12
|
setupSignalHandlers,
|
|
13
13
|
version
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-UOG5UZOF.js";
|
|
15
15
|
|
|
16
16
|
// src/proxy.ts
|
|
17
17
|
import { EventEmitter } from "events";
|
|
@@ -164,7 +164,22 @@ async function runProxy(serverUrl, callbackPort, headers, transportStrategy = "h
|
|
|
164
164
|
ignoredTools,
|
|
165
165
|
reconnectFn,
|
|
166
166
|
reconnectOptions,
|
|
167
|
-
serverUrl
|
|
167
|
+
serverUrl,
|
|
168
|
+
onLocalClose: async () => {
|
|
169
|
+
log("[Shutdown] Local transport closed, initiating cleanup...");
|
|
170
|
+
try {
|
|
171
|
+
await remoteTransport.close();
|
|
172
|
+
if (server) {
|
|
173
|
+
server.close();
|
|
174
|
+
}
|
|
175
|
+
process.stdout.end();
|
|
176
|
+
log("[Shutdown] Cleanup complete, exiting with code 0");
|
|
177
|
+
process.exit(0);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
log("[Shutdown] Error during cleanup:", error);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
168
183
|
});
|
|
169
184
|
await localTransport.start();
|
|
170
185
|
log("Local STDIO server running");
|
|
@@ -179,6 +194,7 @@ async function runProxy(serverUrl, callbackPort, headers, transportStrategy = "h
|
|
|
179
194
|
if (server) {
|
|
180
195
|
server.close();
|
|
181
196
|
}
|
|
197
|
+
process.stdout.end();
|
|
182
198
|
};
|
|
183
199
|
setupSignalHandlers(cleanup);
|
|
184
200
|
} catch (error) {
|