list-inventory
Retrieve all items currently stored in the Minecraft bot's inventory to manage resources and plan in-game actions.
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 handler function that lists all items in the bot's inventory. It retrieves items using bot.inventory.items(), maps them to structured data, formats a text response, and handles errors.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)Registers the 'list-inventory' tool with the MCP server, including name, description, 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 (schema)TypeScript interface defining the structure of an inventory item (name, count, slot), used in the tool handler for mapping inventory items.interface InventoryItem { name: string; count: number; slot: number; }
- src/bot.ts:141-141 (registration)Invocation of the registerInventoryTools function within createMcpServer, which includes the registration of 'list-inventory'.registerInventoryTools(server, bot);