equip-item
Equip a specific item in Minecraft by specifying its name and destination, enabling precise control of in-game actions through the MCP server for AI-driven gameplay.
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/bot.ts:318-334 (handler)The handler function that implements the core logic of the 'equip-item' tool. It searches the bot's inventory for an item matching the provided name (case-insensitive partial match), equips it to the specified destination slot (defaults to 'hand'), and handles errors appropriately.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:315-317 (schema)Zod schema defining the input parameters for the 'equip-item' tool: itemName (required string) and destination (optional string). Note: startLine adjusted to the schema object for precision.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)The registration of the 'equip-item' tool via server.tool(), including name, description, input schema, and handler function. Located within the registerInventoryTools function.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); } } );