VillagerViewer allows players to view and edit a villager's inventory by sneaking and right-clicking on them with a stick (configurable).
Here you can view/edit a villager's inventory