Skip to main content
Glama

placeBlock

Place a specific block at designated coordinates in Minecraft using precise x, y, z values and item name. Enables controlled building and editing in remote servers.

Instructions

Place a block at the specified location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
itemNameYesName of the item to place
xYesX coordinate
yYesY coordinate
zYesZ coordinate

Implementation Reference

  • The handler function that executes the placeBlock tool: validates connection, locates and equips the specified item, iterates over possible adjacent faces to find a valid reference block, and places the block using bot.placeBlock.
    async ({ x, y, z, itemName }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find item from inventory const item = botState.bot.inventory .items() .find((item) => item.name.toLowerCase() === itemName.toLowerCase()) if (!item) { return createSuccessResponse( `Item "${itemName}" not found in inventory.` ) } // Hold item in hand await botState.bot.equip(item, 'hand') // Get reference block and placement face for target position const targetPos = { x, y, z } const faceVectors = [ { x: 0, y: 1, z: 0 }, // Up { x: 0, y: -1, z: 0 }, // Down { x: 1, y: 0, z: 0 }, // East { x: -1, y: 0, z: 0 }, // West { x: 0, y: 0, z: 1 }, // South { x: 0, y: 0, z: -1 }, // North ] // Check each face to see if placement is possible for (const faceVector of faceVectors) { const referencePos = { x: targetPos.x - faceVector.x, y: targetPos.y - faceVector.y, z: targetPos.z - faceVector.z, } const referenceBlock = botState.bot.blockAt( new Vec3(referencePos.x, referencePos.y, referencePos.z) ) if (referenceBlock && referenceBlock.name !== 'air') { try { // Place the block await botState.bot.placeBlock( referenceBlock, new Vec3(faceVector.x, faceVector.y, faceVector.z) ) return createSuccessResponse( `Successfully placed ${itemName} at X=${x}, Y=${y}, Z=${z}` ) } catch (err) { // If placement fails on this face, try the next face continue } } } // If placement fails on all faces return createSuccessResponse( `Failed to place ${itemName}. No suitable surface found or not enough space.` ) } catch (error) { return createErrorResponse(error) } }
  • Zod schema defining the input parameters for the placeBlock tool: coordinates (x, y, z) as numbers and itemName as string.
    { x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), itemName: z.string().describe('Name of the item to place'), },
  • Registers the 'placeBlock' tool with the server using server.tool, specifying name and description.
    'placeBlock', 'Place a block at the specified location',
  • Invokes registerBlockTools() as part of registering all tools, which includes the placeBlock tool.
    registerBlockTools()

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