Skip to main content
Glama
zeeweebee

Minecraft MCP Server

by zeeweebee

find-block

Locate the nearest block of a specified type within a defined search radius in Minecraft. Use this tool to find resources, structures, or specific blocks for building and exploration.

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

  • The handler function for the 'find-block' tool. It searches for the nearest block of the specified type within maxDistance using bot.findBlock, using minecraftData to resolve block ID by name.
    async ({ blockType, maxDistance = 16 }): Promise<McpResponse> => {
      try {
        const mcData = minecraftData(bot.version);
        const blocksByName = mcData.blocksByName;
    
        if (!blocksByName[blockType]) {
          return createResponse(`Unknown block type: ${blockType}`);
        }
    
        const blockId = blocksByName[blockType].id;
    
        const block = bot.findBlock({
          matching: blockId,
          maxDistance: maxDistance
        });
    
        if (!block) {
          return createResponse(`No ${blockType} found within ${maxDistance} blocks`);
        }
    
        return createResponse(`Found ${blockType} at position (${block.position.x}, ${block.position.y}, ${block.position.z})`);
      } catch (error) {
        return createErrorResponse(error as Error);
      }
    }
  • Input schema for the 'find-block' tool using Zod: blockType (string, required), maxDistance (number, optional).
    {
      blockType: z.string().describe("Type of block to find"),
      maxDistance: z.number().optional().describe("Maximum search distance (default: 16)")
    },
  • src/bot.ts:462-494 (registration)
    Registration of the 'find-block' tool using server.tool() in registerBlockTools function, including inline schema and handler.
    server.tool(
      "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 }): Promise<McpResponse> => {
        try {
          const mcData = minecraftData(bot.version);
          const blocksByName = mcData.blocksByName;
    
          if (!blocksByName[blockType]) {
            return createResponse(`Unknown block type: ${blockType}`);
          }
    
          const blockId = blocksByName[blockType].id;
    
          const block = bot.findBlock({
            matching: blockId,
            maxDistance: maxDistance
          });
    
          if (!block) {
            return createResponse(`No ${blockType} found within ${maxDistance} blocks`);
          }
    
          return createResponse(`Found ${blockType} at position (${block.position.x}, ${block.position.y}, ${block.position.z})`);
        } catch (error) {
          return createErrorResponse(error as Error);
        }
      }
    );

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