Skip to main content
Glama
zeeweebee

Minecraft MCP Server

by zeeweebee

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

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

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