equip-item
Equip a specific item to a designated slot in Minecraft, such as the hand, to prepare for use during gameplay.
Instructions
Equip a specific item
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| itemName | Yes | Name of the item to equip | |
| destination | No | Where to equip the item (default: 'hand') |
Implementation Reference
- src/bot.ts:318-334 (handler)The core handler function for the 'equip-item' tool. It searches the bot's inventory for an item matching the given name (case-insensitive partial match), equips it to the specified destination (default 'hand') using bot.equip, and returns success/error messages.async ({ itemName, destination = 'hand' }): Promise<McpResponse> => { try { const items = bot.inventory.items(); const item = items.find((item: any) => item.name.includes(itemName.toLowerCase()) ); if (!item) { return createResponse(`Couldn't find any item matching '${itemName}' in inventory`); } await bot.equip(item, destination as mineflayer.EquipmentDestination); return createResponse(`Equipped ${item.name} to ${destination}`); } catch (error) { return createErrorResponse(error as Error); } }
- src/bot.ts:314-317 (schema)Zod input schema for the 'equip-item' tool, defining parameters: itemName (required string) and destination (optional string, defaults to 'hand').{ itemName: z.string().describe("Name of the item to equip"), destination: z.string().optional().describe("Where to equip the item (default: 'hand')") },
- src/bot.ts:311-335 (registration)Registration of the 'equip-item' tool via server.tool() call within registerInventoryTools function, including description, schema, and inline handler implementation.server.tool( "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' }): Promise<McpResponse> => { try { const items = bot.inventory.items(); const item = items.find((item: any) => item.name.includes(itemName.toLowerCase()) ); if (!item) { return createResponse(`Couldn't find any item matching '${itemName}' in inventory`); } await bot.equip(item, destination as mineflayer.EquipmentDestination); return createResponse(`Equipped ${item.name} to ${destination}`); } catch (error) { return createErrorResponse(error as Error); } } );