Skip to main content
Glama

openContainer

Access containers like chests or furnaces in Minecraft by specifying their coordinates. Enables precise inventory management and interaction on remote servers through MCP Minecraft Remote.

Instructions

Open a container (chest, furnace, etc.) at specific coordinates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate of the container
yYesY coordinate of the container
zYesZ coordinate of the container

Implementation Reference

  • The handler function that performs the core logic of the openContainer tool: checks bot connection, gets block at coordinates, validates container type, opens container using mineflayer's openContainer, stores it in state, formats and returns container contents.
    async ({ x, y, z }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Get the block at the coordinates const block = botState.bot.blockAt(new Vec3(x, y, z)) if (!block) { return createSuccessResponse( `No block found at coordinates X=${x}, Y=${y}, Z=${z}` ) } // Check if the block is a container if ( !block.name.includes('chest') && !block.name.includes('furnace') && !block.name.includes('barrel') && !block.name.includes('shulker') && !block.name.includes('dispenser') && !block.name.includes('dropper') && !block.name.includes('hopper') ) { return createSuccessResponse( `Block at X=${x}, Y=${y}, Z=${z} is not a container (found: ${block.name})` ) } // Open the container const container = await botState.bot.openContainer(block) // Store container reference as our Container type with withdraw/deposit methods botState.currentContainer = container as unknown as Container // Get container contents const items = container.slots .filter((item): item is NonNullable<typeof item> => item !== null) .map((item) => { if (!item) return null return { name: item.name, displayName: item.displayName || item.name, count: item.count || 1, slot: container.slots.indexOf(item), } }) .filter((item) => item !== null) // Format the response let response = `Opened ${block.name} at X=${x}, Y=${y}, Z=${z}\n\n` if (items.length === 0) { response += 'Container is empty.' } else { response += `Container contains ${items.length} items:\n` items.forEach((item) => { response += `- ${item.displayName} (x${item.count}) in slot ${item.slot}\n` }) } return createSuccessResponse(response) } catch (error) { return createErrorResponse(error) } }
  • Zod schema defining the input parameters for the openContainer tool: x, y, z coordinates as numbers.
    { x: z.number().describe('X coordinate of the container'), y: z.number().describe('Y coordinate of the container'), z: z.number().describe('Z coordinate of the container'), },
  • Direct registration of the openContainer tool using server.tool, specifying name, description, input schema, and handler function.
    server.tool( 'openContainer', 'Open a container (chest, furnace, etc.) at specific coordinates', { x: z.number().describe('X coordinate of the container'), y: z.number().describe('Y coordinate of the container'), z: z.number().describe('Z coordinate of the container'), }, async ({ x, y, z }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Get the block at the coordinates const block = botState.bot.blockAt(new Vec3(x, y, z)) if (!block) { return createSuccessResponse( `No block found at coordinates X=${x}, Y=${y}, Z=${z}` ) } // Check if the block is a container if ( !block.name.includes('chest') && !block.name.includes('furnace') && !block.name.includes('barrel') && !block.name.includes('shulker') && !block.name.includes('dispenser') && !block.name.includes('dropper') && !block.name.includes('hopper') ) { return createSuccessResponse( `Block at X=${x}, Y=${y}, Z=${z} is not a container (found: ${block.name})` ) } // Open the container const container = await botState.bot.openContainer(block) // Store container reference as our Container type with withdraw/deposit methods botState.currentContainer = container as unknown as Container // Get container contents const items = container.slots .filter((item): item is NonNullable<typeof item> => item !== null) .map((item) => { if (!item) return null return { name: item.name, displayName: item.displayName || item.name, count: item.count || 1, slot: container.slots.indexOf(item), } }) .filter((item) => item !== null) // Format the response let response = `Opened ${block.name} at X=${x}, Y=${y}, Z=${z}\n\n` if (items.length === 0) { response += 'Container is empty.' } else { response += `Container contains ${items.length} items:\n` items.forEach((item) => { response += `- ${item.displayName} (x${item.count}) in slot ${item.slot}\n` }) } return createSuccessResponse(response) } catch (error) { return createErrorResponse(error) } } )
  • Invocation of registerContainerInteractionTools() which registers the openContainer tool among others.
    registerContainerInteractionTools()
  • src/index.ts:7-7 (registration)
    Top-level call to registerAllTools() at server startup, which chains to registering openContainer.
    registerAllTools()

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/nacal/mcp-minecraft-remote'

If you have feedback or need assistance with the MCP directory API, please join our Discord server