list-inventory
Display all items in the Minecraft bot's inventory to manage resources, track items, and optimize in-game actions efficiently.
Instructions
List all items in the bot's inventory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/bot.ts:262-284 (handler)The main handler function for the 'list-inventory' tool. It fetches all items from the bot's inventory using bot.inventory.items(), maps them to a structured format, and returns a formatted text list or 'Inventory is empty' if none.async (): Promise<McpResponse> => { try { const items = bot.inventory.items(); const itemList: InventoryItem[] = items.map((item: any) => ({ name: item.name, count: item.count, slot: item.slot })); if (items.length === 0) { return 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 createResponse(inventoryText); } catch (error) { return createErrorResponse(error as Error); } }
- src/bot.ts:258-285 (registration)Registration of the 'list-inventory' tool via server.tool() within the registerInventoryTools function, including empty input schema and inline handler.server.tool( "list-inventory", "List all items in the bot's inventory", {}, async (): Promise<McpResponse> => { try { const items = bot.inventory.items(); const itemList: InventoryItem[] = items.map((item: any) => ({ name: item.name, count: item.count, slot: item.slot })); if (items.length === 0) { return 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 createResponse(inventoryText); } catch (error) { return createErrorResponse(error as Error); } } );
- src/bot.ts:30-34 (helper)Type interface used in the list-inventory handler to structure inventory item data.interface InventoryItem { name: string; count: number; slot: number; }