Skip to main content
Glama

find-block

Locate the nearest block of a specified type within a defined distance in Minecraft. Ideal for real-time exploration and structure building using the mcp-minecraft server.

Instructions

Find the nearest block of a specific type

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
blockTypeYesType of block to find
maxDistanceNoMaximum search distance (default: 16)

Implementation Reference

  • Registers the "find-block" MCP tool with its description, input schema using Zod, and inline asynchronous handler function that uses the bot to find the nearest block of the specified type within maxDistance.
    factory.registerTool( "find-block", "Find the nearest block of a specific type", { blockType: z.string().describe("Type of block to find"), maxDistance: z.number().optional().describe("Maximum search distance (default: 16)") }, async ({ blockType, maxDistance = 16 }) => { const bot = getBot(); const mcData = minecraftData(bot.version); const blocksByName = mcData.blocksByName; if (!blocksByName[blockType]) { return factory.createResponse(`Unknown block type: ${blockType}`); } const blockId = blocksByName[blockType].id; const block = bot.findBlock({ matching: blockId, maxDistance: maxDistance }); if (!block) { return factory.createResponse(`No ${blockType} found within ${maxDistance} blocks`); } return factory.createResponse(`Found ${blockType} at position (${block.position.x}, ${block.position.y}, ${block.position.z})`); } );
  • The handler function for the "find-block" tool. It retrieves the bot, looks up the block ID using minecraft-data, finds the nearest block using bot.findBlock, and returns the position or an error message.
    async ({ blockType, maxDistance = 16 }) => { const bot = getBot(); const mcData = minecraftData(bot.version); const blocksByName = mcData.blocksByName; if (!blocksByName[blockType]) { return factory.createResponse(`Unknown block type: ${blockType}`); } const blockId = blocksByName[blockType].id; const block = bot.findBlock({ matching: blockId, maxDistance: maxDistance }); if (!block) { return factory.createResponse(`No ${blockType} found within ${maxDistance} blocks`); } return factory.createResponse(`Found ${blockType} at position (${block.position.x}, ${block.position.y}, ${block.position.z})`); }
  • Zod schema defining the input parameters for the "find-block" tool: blockType (required string) and maxDistance (optional number, default 16).
    { blockType: z.string().describe("Type of block to find"), maxDistance: z.number().optional().describe("Maximum search distance (default: 16)") },

Other Tools

Related Tools

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/yuniko-software/minecraft-mcp-server'

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