Skip to main content
Glama

eatFood

Restore hunger in Minecraft by consuming food directly from your inventory using this simple tool on the MCP Server. Ideal for AI agents managing in-game survival tasks.

Instructions

Eat food from inventory to restore hunger

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function for the 'eatFood' tool. Determines if the bot is hungry (food < 20), searches inventory for edible items from a predefined list of Minecraft foods, equips the first available food to hand slot, and consumes it using bot.consume(). Emits observations via bot.emit for start/end states.
    export const eatFood = async ( bot: Bot, params: ISkillParams, serviceParams: ISkillServiceParams, ): Promise<boolean> => { const minecraftFoodNames = [ 'apple', 'baked_potato', 'beetroot', 'beetroot_soup', 'bread', 'cake', 'carrot', 'chorus_fruit', 'cooked_chicken', 'cooked_cod', 'cooked_mutton', 'cooked_porkchop', 'cooked_rabbit', 'cooked_salmon', 'cookie', 'dried_kelp', 'enchanted_golden_apple', 'glow_berries', 'golden_apple', 'golden_carrot', 'honey_bottle', 'melon_slice', 'mushroom_stew', 'poisonous_potato', 'potato', 'pufferfish', 'pumpkin_pie', 'rabbit_stew', 'beef', 'chicken', 'cod', 'mutton', 'porkchop', 'rabbit', 'salmon', 'rotten_flesh', 'spider_eye', 'cooked_beef', 'suspicious_stew', 'sweet_berries', 'tropical_fish', ]; const {getStatsData, setStatsData} = serviceParams; // check to see if the bot is hungry if (bot.food < 20) { console.log(`Bot is hungry and has ${bot.food} food points.`); } else { return bot.emit( 'alteraBotEndObservation', `You decided not to eat since you are not hungry.`, ); } for (const foodName of minecraftFoodNames) { const food = bot.inventory.findInventoryItem(foodName as any, null, false); if (food !== null) { console.log(`Found item: ${foodName}`); bot.equip(food, 'hand'); console.log(`Eating: ${foodName}`); try { await asyncwrap({ func: async () => { console.log(`${foodName} consumed!`); return bot.consume(); }, getStatsData, setStatsData, }); } catch (error) { console.log(`Error consuming ${foodName}: ${error}`); } return bot.emit( 'alteraBotEndObservation', `You finished eating one ${foodName}`, ); } } return bot.emit( 'alteraBotEndObservation', `You tried to eat but you have no food to eat!`, ); };
  • Schema definition for the 'eatFood' tool within SKILL_METADATA. Specifies the tool description and an empty input schema (no parameters required). This is used to generate the inputSchema for the SkillDefinition.
    eatFood: { description: "Eat food from inventory to restore hunger", params: {}, required: [] },
  • The loadSkills function registers all skills including 'eatFood' by iterating over SKILL_METADATA, creating SkillDefinition objects with name, description, inputSchema from metadata, and dynamic executor that imports the skill implementation. This array is likely used to register tools with the MCP server.
    export async function loadSkills(): Promise<SkillDefinition[]> { const skills: SkillDefinition[] = []; for (const [skillName, metadata] of Object.entries(SKILL_METADATA)) { skills.push({ name: skillName, description: metadata.description, inputSchema: { type: "object", properties: metadata.params, required: metadata.required }, execute: createSkillExecutor(skillName) }); } return skills; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leo4life2/minecraft-mcp-http'

If you have feedback or need assistance with the MCP directory API, please join our Discord server