find-item
Locate a specific item in the bot's inventory by providing its name or type, facilitating quick inventory management in Minecraft through the mcp-minecraft server.
Instructions
Find a specific item in the bot's inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| nameOrType | Yes | Name or type of item to find |
Implementation Reference
- src/tools/inventory-tools.ts:44-56 (handler)Handler function that finds an item in the bot's inventory by name or type, using mineflayer bot.inventory.items() and returns details or not found message.async ({ nameOrType }) => { const bot = getBot(); const items = bot.inventory.items(); const item = items.find((item) => item.name.includes(nameOrType.toLowerCase()) ); if (item) { return factory.createResponse(`Found ${item.count} ${item.name} in inventory (slot ${item.slot})`); } else { return factory.createResponse(`Couldn't find any item matching '${nameOrType}' in inventory`); } }
- src/tools/inventory-tools.ts:41-43 (schema)Zod schema defining the input parameter 'nameOrType' for the find-item tool.{ nameOrType: z.string().describe("Name or type of item to find") },
- src/tools/inventory-tools.ts:38-57 (registration)Registers the 'find-item' tool using ToolFactory.registerTool, including name, description, schema, and handler.factory.registerTool( "find-item", "Find a specific item in the bot's inventory", { nameOrType: z.string().describe("Name or type of item to find") }, async ({ nameOrType }) => { const bot = getBot(); const items = bot.inventory.items(); const item = items.find((item) => item.name.includes(nameOrType.toLowerCase()) ); if (item) { return factory.createResponse(`Found ${item.count} ${item.name} in inventory (slot ${item.slot})`); } else { return factory.createResponse(`Couldn't find any item matching '${nameOrType}' in inventory`); } } );
- src/main.ts:52-52 (registration)Calls registerInventoryTools which includes registration of the 'find-item' tool.registerInventoryTools(factory, getBot);