Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🔌 fix: Prevent Repeated Idle Check Triggers for Users With Failed MCP Connections (#12853)

David Newman1f37ec842a6b
diff --git a/packages/api/src/mcp/UserConnectionManager.ts b/packages/api/src/mcp/UserConnectionManager.ts
index 760f84c75e..96d75c625b 100644
--- a/packages/api/src/mcp/UserConnectionManager.ts
+++ b/packages/api/src/mcp/UserConnectionManager.ts
@@ -268,10 +268,16 @@ export abstract class UserConnectionManager {
this.pendingConnections.delete(key);
}
}
- // Ensure user activity timestamp is removed
- this.userLastActivity.delete(userId);
logger.info(`[MCP][User: ${userId}] All connections processed for disconnection.`);
}
+ /**
+ * Always clear the activity timestamp, even when userMap was missing.
+ * `updateUserLastActivity` can be called before a connection is established
+ * (e.g. in MCPManager.callTool prior to getConnection); if that connection
+ * attempt fails, the activity entry would otherwise leak and trigger the
+ * idle check repeatedly for the same userId.
+ */
+ this.userLastActivity.delete(userId);
}
/** Check for and disconnect idle connections */