list-inventory
Retrieve a detailed list of all items in the bot's inventory for real-time management and organization within Minecraft using the MCP server.
Instructions
List all items in the bot's inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/inventory-tools.ts:16-35 (handler)The core handler logic for the list-inventory tool. It fetches inventory items from the Mineflayer bot, maps to InventoryItem structs, formats a text list or empty message, and returns via factory.createResponse.async () => { const bot = getBot(); const items = bot.inventory.items(); const itemList: InventoryItem[] = items.map((item) => ({ name: item.name, count: item.count, slot: item.slot })); if (items.length === 0) { return factory.createResponse("Inventory is empty"); } let inventoryText = `Found ${items.length} items in inventory:\n\n`; itemList.forEach(item => { inventoryText += `- ${item.name} (x${item.count}) in slot ${item.slot}\n`; }); return factory.createResponse(inventoryText); }
- src/tools/inventory-tools.ts:12-36 (registration)Direct registration of the list-inventory tool using ToolFactory.registerTool, with name, description, empty schema, and inline handler.factory.registerTool( "list-inventory", "List all items in the bot's inventory", {}, async () => { const bot = getBot(); const items = bot.inventory.items(); const itemList: InventoryItem[] = items.map((item) => ({ name: item.name, count: item.count, slot: item.slot })); if (items.length === 0) { return factory.createResponse("Inventory is empty"); } let inventoryText = `Found ${items.length} items in inventory:\n\n`; itemList.forEach(item => { inventoryText += `- ${item.name} (x${item.count}) in slot ${item.slot}\n`; }); return factory.createResponse(inventoryText); } );
- src/tools/inventory-tools.ts:5-9 (helper)TypeScript interface defining structure of inventory items, used in the list-inventory handler for mapping bot items.interface InventoryItem { name: string; count: number; slot: number; }
- src/main.ts:52-52 (registration)Top-level invocation of registerInventoryTools function, which performs the registration of list-inventory and other inventory tools.registerInventoryTools(factory, getBot);