up-mcp-bridge 1.0.13 → 1.0.14
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.
|
@@ -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.13";
|
|
18047
18047
|
|
|
18048
18048
|
// node_modules/pkce-challenge/dist/index.node.js
|
|
18049
18049
|
var crypto;
|
|
@@ -20161,6 +20161,7 @@ function mcpProxy({
|
|
|
20161
20161
|
let isReconnecting = false;
|
|
20162
20162
|
let reconnectAttempts = 0;
|
|
20163
20163
|
let connectionHealthy = true;
|
|
20164
|
+
let mcpSessionInitialized = false;
|
|
20164
20165
|
const pendingMessages = [];
|
|
20165
20166
|
const messageTimings = /* @__PURE__ */ new Map();
|
|
20166
20167
|
let lastActivityTime = Date.now();
|
|
@@ -20526,6 +20527,9 @@ function mcpProxy({
|
|
|
20526
20527
|
const message = messageTransformer.interceptResponse(_message);
|
|
20527
20528
|
log("[Remote\u2192Local]", message.method || message.id);
|
|
20528
20529
|
tryExtractSessionId();
|
|
20530
|
+
if (message.result && message.result.serverInfo) {
|
|
20531
|
+
log("[MCP Init] Received initialize response, session will be marked initialized after notifications/initialized is sent");
|
|
20532
|
+
}
|
|
20529
20533
|
if (message.id !== void 0) {
|
|
20530
20534
|
const timing = messageTimings.get(message.id);
|
|
20531
20535
|
if (timing) {
|
|
@@ -20561,6 +20565,8 @@ function mcpProxy({
|
|
|
20561
20565
|
stopBackgroundHeartbeat();
|
|
20562
20566
|
clearAllRequestTracking();
|
|
20563
20567
|
setConnectionHealthy(false, "remote transport closed");
|
|
20568
|
+
mcpSessionInitialized = false;
|
|
20569
|
+
log("[MCP Init] Session initialization reset for reconnection");
|
|
20564
20570
|
if (reconnectOptions.enabled && reconnectFn && reconnectAttempts < reconnectOptions.maxAttempts) {
|
|
20565
20571
|
log(`Remote transport closed. Starting reconnection loop...`);
|
|
20566
20572
|
debugLog("Remote transport closed, starting reconnection loop", { attempt: reconnectAttempts + 1 });
|
|
@@ -20590,6 +20596,8 @@ function mcpProxy({
|
|
|
20590
20596
|
});
|
|
20591
20597
|
continue;
|
|
20592
20598
|
}
|
|
20599
|
+
mcpSessionInitialized = true;
|
|
20600
|
+
log("[MCP Init] Session re-initialized successfully after reconnection");
|
|
20593
20601
|
reconnectAttempts = 0;
|
|
20594
20602
|
isReconnecting = false;
|
|
20595
20603
|
setConnectionHealthy(true, "reconnection successful");
|
|
@@ -20682,8 +20690,13 @@ function mcpProxy({
|
|
|
20682
20690
|
log(JSON.stringify(message, null, 2));
|
|
20683
20691
|
savedInitializeMessage = { ...message };
|
|
20684
20692
|
log("[Init] Saved initialize message for potential reconnection");
|
|
20693
|
+
mcpSessionInitialized = false;
|
|
20694
|
+
log("[MCP Init] Starting new MCP handshake, session marked as not initialized");
|
|
20685
20695
|
debugLog("Initialize message with modified client info", { clientInfo });
|
|
20686
20696
|
}
|
|
20697
|
+
if (message.method === "notifications/initialized") {
|
|
20698
|
+
log("[MCP Init] Client sending notifications/initialized, marking session as initialized");
|
|
20699
|
+
}
|
|
20687
20700
|
if (isReconnecting || !connectionHealthy) {
|
|
20688
20701
|
const timing = message.id !== void 0 ? messageTimings.get(message.id) : void 0;
|
|
20689
20702
|
const delayMs = timing ? Date.now() - timing.receivedAt : 0;
|
|
@@ -20695,6 +20708,15 @@ function mcpProxy({
|
|
|
20695
20708
|
}
|
|
20696
20709
|
return;
|
|
20697
20710
|
}
|
|
20711
|
+
if (!mcpSessionInitialized && message.method !== "initialize" && message.method !== "notifications/initialized") {
|
|
20712
|
+
log(`[BUG-005] Session not initialized, queuing message ${message.id || "(no id)"} (${message.method})`);
|
|
20713
|
+
log("[Local\u2192Remote] (queuing - session not initialized)", message.method || message.id);
|
|
20714
|
+
queueMessageForRetry(message);
|
|
20715
|
+
if (pendingMessages.length === 1) {
|
|
20716
|
+
log("[BUG-005] Hint: This usually happens after context compaction. Messages will be sent after session is re-initialized.");
|
|
20717
|
+
}
|
|
20718
|
+
return;
|
|
20719
|
+
}
|
|
20698
20720
|
trackRequest(message);
|
|
20699
20721
|
const sendStartTime = Date.now();
|
|
20700
20722
|
if (message.id !== void 0) {
|
|
@@ -20712,6 +20734,31 @@ function mcpProxy({
|
|
|
20712
20734
|
if (sendDuration > 1e3) {
|
|
20713
20735
|
log(`[BUG-003 SendSlow] Message ${message.id || "(no id)"} (${message.method}) send() took ${sendDuration}ms`);
|
|
20714
20736
|
}
|
|
20737
|
+
if (message.method === "notifications/initialized" && !mcpSessionInitialized) {
|
|
20738
|
+
mcpSessionInitialized = true;
|
|
20739
|
+
log("[MCP Init] Session initialized! Flushing any queued messages...");
|
|
20740
|
+
const queueSize = pendingMessages.length;
|
|
20741
|
+
if (queueSize > 0) {
|
|
20742
|
+
log(`[MCP Init] Flushing ${queueSize} queued messages that were waiting for session initialization`);
|
|
20743
|
+
let flushedCount = 0;
|
|
20744
|
+
while (pendingMessages.length > 0) {
|
|
20745
|
+
const pending = pendingMessages.shift();
|
|
20746
|
+
if (pending.message.id) {
|
|
20747
|
+
queuedMessageIds.delete(pending.message.id);
|
|
20748
|
+
}
|
|
20749
|
+
if (Date.now() - pending.timestamp < messageTimeoutMs) {
|
|
20750
|
+
log(`[MCP Init] Sending queued message ${pending.message.id || "(no id)"} (${pending.message.method})`);
|
|
20751
|
+
trackRequest(pending.message);
|
|
20752
|
+
currentTransportToServer.send(pending.message).catch(onServerError);
|
|
20753
|
+
flushedCount++;
|
|
20754
|
+
} else {
|
|
20755
|
+
log(`[MCP Init] Message ${pending.message.id} expired, sending error`);
|
|
20756
|
+
sendErrorForPendingMessage(pending, "Request timed out waiting for MCP session initialization");
|
|
20757
|
+
}
|
|
20758
|
+
}
|
|
20759
|
+
log(`[MCP Init] Flush complete: ${flushedCount} messages sent`);
|
|
20760
|
+
}
|
|
20761
|
+
}
|
|
20715
20762
|
}).catch((error2) => {
|
|
20716
20763
|
if (message.id !== void 0) {
|
|
20717
20764
|
clearRequestTracking(message.id);
|
package/dist/client.js
CHANGED
package/dist/proxy.js
CHANGED