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: MCP SSE & Ping Error Handling (#10635)

Peter3628619297e6
diff --git a/packages/api/src/mcp/connection.ts b/packages/api/src/mcp/connection.ts
index c130b3a467..ae4fc72324 100644
--- a/packages/api/src/mcp/connection.ts
+++ b/packages/api/src/mcp/connection.ts
@@ -595,17 +595,27 @@ export class MCPConnection extends EventEmitter {
private setupTransportErrorHandlers(transport: Transport): void {
transport.onerror = (error) => {
- logger.error(`${this.getLogPrefix()} Transport error:`, error);
-
- // Check if it's an OAuth authentication error
if (error && typeof error === 'object' && 'code' in error) {
const errorCode = (error as unknown as { code?: number }).code;
+
+ // Ignore SSE 404 errors for servers that don't support SSE
+ if (
+ errorCode === 404 &&
+ String(error?.message).toLowerCase().includes('failed to open sse stream')
+ ) {
+ logger.warn(`${this.getLogPrefix()} SSE stream not available (404). Ignoring.`);
+ return;
+ }
+
+ // Check if it's an OAuth authentication error
if (errorCode === 401 || errorCode === 403) {
logger.warn(`${this.getLogPrefix()} OAuth authentication error detected`);
this.emit('oauthError', error);
}
}
+ logger.error(`${this.getLogPrefix()} Transport error:`, error);
+
this.emit('connectionChange', 'error');
};
}
@@ -678,7 +688,9 @@ export class MCPConnection extends EventEmitter {
const pingUnsupported =
error instanceof Error &&
((error as Error)?.message.includes('-32601') ||
+ (error as Error)?.message.includes('-32602') ||
(error as Error)?.message.includes('invalid method ping') ||
+ (error as Error)?.message.includes('Unsupported method: ping') ||
(error as Error)?.message.includes('method not found'));
if (!pingUnsupported) {