Minecraft Education edition already does this.
Press C, code window appears, you can use Python, Javascript or a visual Scratch-like language, controlling an agent in the minecraft world to go and do things
https://education.minecraft.net/en-us/resources/computer-sci...