fix(mcp): always call `ListTools` to discover available tools (#1447)

Lennart Lopin created

Change summary

internal/agent/tools/mcp/tools.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

Detailed changes

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

@@ -74,9 +74,9 @@ func RefreshTools(ctx context.Context, name string) {
 }
 
 func getTools(ctx context.Context, session *mcp.ClientSession) ([]*Tool, error) {
-	if session.InitializeResult().Capabilities.Tools == nil {
-		return nil, nil
-	}
+	// Always call ListTools to get the actual available tools.
+	// The InitializeResult Capabilities.Tools field may be an empty object {},
+	// which is valid per MCP spec, but we still need to call ListTools to discover tools.
 	result, err := session.ListTools(ctx, &mcp.ListToolsParams{})
 	if err != nil {
 		return nil, err