Caveat, I'm new to Godot, this probably isn't the best way, plus not looking into 2D, BUT:
I would populate an array with bomb positions to begin with where a 1 represents a bomb and a zero represents no bomb. Using this to generate each bomb, I'd give each an attribute 'bomb_position' which contains its position in the array.
Then when the Raycast hits each bomb, I'd retrieve 'bomb_position' from the collider and check the array summing it's surrounding values.
Very crudely ("it's late"), I am imagining the array once generated could look something like:
0,0,0,1,0
0,1,0,1,0
0,1,1,1,0
1,0,0,0,1
1,0,1,1,0
If raycast hits bomb with bomb_position [1][2], then we only need to sum the total of the following:
0,0,0,1,0
0,1,0,1,0
0,1,1,1,0
1,0,0,0,1
1,0,1,1,0
Looping a 2D array seems simpler than any kind of engine sorcery (I mean, you probably COULD do something funky with Areas, but why would you).