From 406f83160ebb0f248e3fa353ad6baba460882290 Mon Sep 17 00:00:00 2001 From: Michael <108142320+xthanhn91@users.noreply.github.com> Date: Fri, 27 Feb 2026 16:02:53 +0700 Subject: [PATCH] fix(mcp): treat "method not found" ping responses as healthy (#1) MCP servers that don't implement the `ping` method return a "method not found" error. The health loop previously treated this as a failure, triggering exponential backoff reconnects and making tools temporarily unavailable. Now uses case-insensitive matching to detect "method not found" responses and treats the server as healthy (it did respond, just doesn't support ping). Resets reconnect attempts and clears error state. --- internal/mcp/manager.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/mcp/manager.go b/internal/mcp/manager.go index 9390e5d6..44ce8152 100644 --- a/internal/mcp/manager.go +++ b/internal/mcp/manager.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log/slog" + "strings" "sync" "sync/atomic" "time" @@ -338,6 +339,15 @@ func (m *Manager) healthLoop(ctx context.Context, ss *serverState) { return case <-ticker.C: if err := ss.client.Ping(ctx); err != nil { + // Servers that don't implement "ping" are still alive — treat as healthy. + if strings.Contains(strings.ToLower(err.Error()), "method not found") { + ss.connected.Store(true) + ss.mu.Lock() + ss.reconnAttempts = 0 + ss.lastErr = "" + ss.mu.Unlock() + continue + } ss.connected.Store(false) ss.mu.Lock() ss.lastErr = err.Error()