equip-item
Equip a specific item in Minecraft by specifying its name and destination (e.g., hand) using MCP-minecraft server, enabling real-time character control through the Mineflayer API.
Instructions
Equip a specific item
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| destination | No | Where to equip the item (default: 'hand') | |
| itemName | Yes | Name of the item to equip |
Implementation Reference
- src/tools/inventory-tools.ts:66-79 (handler)Handler function that finds the item in the bot's inventory by name and equips it to the specified destination (default 'hand') using bot.equip(). Returns success or not found message.async ({ itemName, destination = 'hand' }) => { const bot = getBot(); const items = bot.inventory.items(); const item = items.find((item) => item.name.includes(itemName.toLowerCase()) ); if (!item) { return factory.createResponse(`Couldn't find any item matching '${itemName}' in inventory`); } await bot.equip(item, destination as mineflayer.EquipmentDestination); return factory.createResponse(`Equipped ${item.name} to ${destination}`); }
- src/tools/inventory-tools.ts:62-65 (schema)Input schema defining 'itemName' as required string and optional 'destination' string using Zod.{ itemName: z.string().describe("Name of the item to equip"), destination: z.string().optional().describe("Where to equip the item (default: 'hand')") },
- src/tools/inventory-tools.ts:59-80 (registration)Registers the 'equip-item' tool with ToolFactory, including name, description, input schema, and handler function.factory.registerTool( "equip-item", "Equip a specific item", { itemName: z.string().describe("Name of the item to equip"), destination: z.string().optional().describe("Where to equip the item (default: 'hand')") }, async ({ itemName, destination = 'hand' }) => { const bot = getBot(); const items = bot.inventory.items(); const item = items.find((item) => item.name.includes(itemName.toLowerCase()) ); if (!item) { return factory.createResponse(`Couldn't find any item matching '${itemName}' in inventory`); } await bot.equip(item, destination as mineflayer.EquipmentDestination); return factory.createResponse(`Equipped ${item.name} to ${destination}`); } );