equipItem
Equip an item to a specified slot (hand, head, torso, legs, feet) in Minecraft using the MCP Minecraft Remote server, enabling precise inventory management through natural language commands.
Instructions
Equip an item from inventory to hand or armor slot
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| destination | No | Slot to equip the item to | hand |
| itemName | Yes | Name of the item to equip |
Implementation Reference
- src/tools/inventoryManagement.ts:12-48 (registration)Registration of the 'equipItem' tool using server.tool, including description, input schema, and inline handler function that equips items from inventory to specified slots.server.tool( 'equipItem', 'Equip an item from inventory to hand or armor slot', { itemName: z.string().describe('Name of the item to equip'), destination: z .enum(['hand', 'head', 'torso', 'legs', 'feet']) .default('hand') .describe('Slot to equip the item to'), }, async ({ itemName, destination }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the item in inventory const item = botState.bot.inventory .items() .find((item) => item.name.toLowerCase() === itemName.toLowerCase()) if (!item) { return createSuccessResponse( `Item "${itemName}" not found in inventory.` ) } // Equip the item to the specified destination await botState.bot.equip(item, destination) return createSuccessResponse( `Successfully equipped ${itemName} to ${destination}` ) } catch (error) { return createErrorResponse(error) } } )
- src/tools/inventoryManagement.ts:22-47 (handler)The execution logic for equipItem: validates connection, locates item in bot's inventory by case-insensitive name match, equips to 'hand', 'head', 'torso', 'legs', or 'feet' slot, handles missing item or errors with responses.async ({ itemName, destination }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the item in inventory const item = botState.bot.inventory .items() .find((item) => item.name.toLowerCase() === itemName.toLowerCase()) if (!item) { return createSuccessResponse( `Item "${itemName}" not found in inventory.` ) } // Equip the item to the specified destination await botState.bot.equip(item, destination) return createSuccessResponse( `Successfully equipped ${itemName} to ${destination}` ) } catch (error) { return createErrorResponse(error) } }
- Input schema using Zod: itemName (required string), destination (optional enum with default 'hand').{ itemName: z.string().describe('Name of the item to equip'), destination: z .enum(['hand', 'head', 'torso', 'legs', 'feet']) .default('hand') .describe('Slot to equip the item to'), },
- src/tools/index.ts:32-32 (registration)High-level registration call within registerAllTools() that invokes the inventory management tools registration, including equipItem.registerInventoryManagementTools()