nice find. good luck with the engine. if it doesn't work, replacement 6 cylinder engines are pretty plentiful. you shouldn't have any problems finding a replacement. looks like you have a 1970's model? if so , the AMC 232 and 258 will bolt right up. the 304 v8 should hook up to your bell housing, iirc, but you'd need different motor mounts for the v8.
good luck to you and welcome to the site!
1966 CJ5A, mods are coming
1966 Wagoneer, bone stock