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
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
♻️ fix: Resolve MCP Connection if Ping is Unsupported (#8483)
Danny Avila418b5e907077
diff --git a/packages/api/src/mcp/connection.ts b/packages/api/src/mcp/connection.tsindex e46d59a3e2..99e59b5467 100644--- a/packages/api/src/mcp/connection.ts+++ b/packages/api/src/mcp/connection.ts@@ -590,12 +590,59 @@ export class MCPConnection extends EventEmitter {}public async isConnected(): Promise<boolean> {+ // First check if we're in a connected state+ if (this.connectionState !== 'connected') {+ return false;+ }+try {+ // Try ping first as it's the lightest checkawait this.client.ping();return this.connectionState === 'connected';} catch (error) {- logger.error(`${this.getLogPrefix()} Ping failed:`, error);- return false;+ // Check if the error is because ping is not supported (method not found)+ const pingUnsupported =+ error instanceof Error &&+ ((error as Error)?.message.includes('-32601') ||+ (error as Error)?.message.includes('invalid method ping') ||+ (error as Error)?.message.includes('method not found'));++ if (!pingUnsupported) {+ logger.error(`${this.getLogPrefix()} Ping failed:`, error);+ return false;+ }++ // Ping is not supported by this server, try an alternative verification+ logger.debug(+ `${this.getLogPrefix()} Server does not support ping method, verifying connection with capabilities`,+ );++ try {+ // Get server capabilities to verify connection is truly active+ const capabilities = this.client.getServerCapabilities();++ // If we have capabilities, try calling a supported method to verify connection+ if (capabilities?.tools) {+ await this.client.listTools();+ return this.connectionState === 'connected';+ } else if (capabilities?.resources) {+ await this.client.listResources();+ return this.connectionState === 'connected';+ } else if (capabilities?.prompts) {+ await this.client.listPrompts();+ return this.connectionState === 'connected';+ } else {+ // No capabilities to test, but we're in connected state and initialization succeeded+ logger.debug(+ `${this.getLogPrefix()} No capabilities to test, assuming connected based on state`,+ );+ return this.connectionState === 'connected';+ }+ } catch (capabilityError) {+ // If capability check fails, the connection is likely broken+ logger.error(`${this.getLogPrefix()} Connection verification failed:`, capabilityError);+ return false;+ }}}