From 0c8f17eee1a43f426d97a232bc518d03318a1931 Mon Sep 17 00:00:00 2001 From: Vincent Date: Sun, 15 Feb 2026 22:36:15 -0500 Subject: [PATCH 1/2] fix: issue #418 - check for disrupted mcp client connections and re-initialize --- core/agent/agent.go | 15 +++++++++++++++ core/agent/mcp.go | 2 ++ 2 files changed, 17 insertions(+) diff --git a/core/agent/agent.go b/core/agent/agent.go index 7d4807ed..cc190126 100644 --- a/core/agent/agent.go +++ b/core/agent/agent.go @@ -857,6 +857,21 @@ func (a *Agent) consumeJob(job *types.Job, role string) { availableActions := a.getAvailableActionsForJob(job) cogitoTools := availableActions.ToCogitoTools(job.GetContext(), a.sharedState) + + mcpNeedsInit := false + for _, server := range a.mcpSessions { + err := server.Ping(a.context, &mcp.PingParams{}) + if err != nil { + mcpNeedsInit = true + xlog.Error("Error pinging MCP server, will re-initialize MCP actions", "agent", err) + break + } + } + + if mcpNeedsInit { + a.initMCPActions() + } + allActions := append(availableActions, a.mcpActionDefinitions...) obs := job.Obs diff --git a/core/agent/mcp.go b/core/agent/mcp.go index 9d521bf0..a2edf6f5 100644 --- a/core/agent/mcp.go +++ b/core/agent/mcp.go @@ -220,4 +220,6 @@ func (a *Agent) closeMCPServers() { for _, s := range a.mcpSessions { s.Close() } + + a.mcpSessions = []*mcp.ClientSession{} } From 604b3287febfdcf2663a34b083753d622b0231dd Mon Sep 17 00:00:00 2001 From: Vincent Date: Sun, 15 Feb 2026 22:40:37 -0500 Subject: [PATCH 2/2] issue #418 - fix log message --- core/agent/agent.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/agent/agent.go b/core/agent/agent.go index cc190126..fe6014b0 100644 --- a/core/agent/agent.go +++ b/core/agent/agent.go @@ -863,7 +863,7 @@ func (a *Agent) consumeJob(job *types.Job, role string) { err := server.Ping(a.context, &mcp.PingParams{}) if err != nil { mcpNeedsInit = true - xlog.Error("Error pinging MCP server, will re-initialize MCP actions", "agent", err) + xlog.Error("Error pinging MCP server, will re-initialize MCP actions", "error", err) break } }