fix: keep alive

Carlos Alexandro Becker created

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Change summary

internal/llm/agent/mcp-tools.go | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)

Detailed changes

internal/llm/agent/mcp-tools.go 🔗

@@ -342,18 +342,22 @@ func createMCPSession(ctx context.Context, name string, m config.MCPConfig, reso
 		return nil, err
 	}
 
-	client := mcp.NewClient(&mcp.Implementation{
-		Name:    "crush",
-		Version: version.Version,
-		Title:   "Crush",
-	}, &mcp.ClientOptions{
-		ToolListChangedHandler: func(context.Context, *mcp.ToolListChangedRequest) {
-			mcpBroker.Publish(pubsub.UpdatedEvent, MCPEvent{
-				Type: MCPEventToolsListChanged,
-				Name: name,
-			})
+	client := mcp.NewClient(
+		&mcp.Implementation{
+			Name:    "crush",
+			Version: version.Version,
+			Title:   "Crush",
 		},
-	})
+		&mcp.ClientOptions{
+			ToolListChangedHandler: func(context.Context, *mcp.ToolListChangedRequest) {
+				mcpBroker.Publish(pubsub.UpdatedEvent, MCPEvent{
+					Type: MCPEventToolsListChanged,
+					Name: name,
+				})
+			},
+			KeepAlive: time.Minute * 10,
+		},
+	)
 
 	timeout := mcpTimeout(m)
 	mcpCtx, cancel := context.WithCancel(ctx)