Skip to main content
Glama

equip-item

Equip an item to a specified slot in Minecraft, enabling character customization and gameplay adjustments through item management.

Instructions

Equip a specific item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemNameYesName of the item to equip
destinationNoWhere to equip the item (default: 'hand')

Implementation Reference

  • Handler function that locates an item in the bot's inventory by name and equips it to the specified destination (default 'hand') using mineflayer's bot.equip method.
    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}`);
    }
  • Zod schema defining the input parameters for the equip-item tool: itemName (required string) and optional destination (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')")
    },
  • Registration of the 'equip-item' tool using factory.registerTool, including name, description, input schema, and inline 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}`);
      }
    );

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/yuniko-software/minecraft-mcp-server'

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