Skip to main content
Glama
zeeweebee

Minecraft MCP Server

by zeeweebee

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
NameRequiredDescriptionDefault
itemNameYesName of the item to equip
destinationNoWhere to equip the item (default: 'hand')

Implementation Reference

  • 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);
      }
    }
  • 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);
        }
      }
    );

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/zeeweebee/mcp-server'

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