dig-block
Remove a Minecraft block by specifying its X, Y, and Z coordinates using this tool on the MCP Server, enabling precise in-game actions for AI-controlled characters.
Instructions
Dig a block at the specified position
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate | |
| y | Yes | Y coordinate | |
| z | Yes | Z coordinate |
Implementation Reference
- src/bot.ts:414-435 (handler)The handler function for the 'dig-block' tool. It checks for a block at the position, moves closer if unable to dig/see it, and digs the block using bot.dig().async ({ x, y, z }): Promise<McpResponse> => { try { const blockPos = new Vec3(x, y, z); const block = bot.blockAt(blockPos); if (!block || block.name === 'air') { return createResponse(`No block found at position (${x}, ${y}, ${z})`); } if (!bot.canDigBlock(block) || !bot.canSeeBlock(block)) { // Try to move closer to dig the block const goal = new goals.GoalNear(x, y, z, 2); await bot.pathfinder.goto(goal); } await bot.dig(block); return createResponse(`Dug ${block.name} at (${x}, ${y}, ${z})`); } catch (error) { return createErrorResponse(error as Error); } }
- src/bot.ts:409-413 (schema)Zod schema defining the input parameters for the dig-block tool: x, y, z coordinates.{ x: z.number().describe("X coordinate"), y: z.number().describe("Y coordinate"), z: z.number().describe("Z coordinate"), },
- src/bot.ts:406-436 (registration)The MCP server.tool() call that registers the 'dig-block' tool, including name, description, schema, and handler.server.tool( "dig-block", "Dig a block at the specified position", { x: z.number().describe("X coordinate"), y: z.number().describe("Y coordinate"), z: z.number().describe("Z coordinate"), }, async ({ x, y, z }): Promise<McpResponse> => { try { const blockPos = new Vec3(x, y, z); const block = bot.blockAt(blockPos); if (!block || block.name === 'air') { return createResponse(`No block found at position (${x}, ${y}, ${z})`); } if (!bot.canDigBlock(block) || !bot.canSeeBlock(block)) { // Try to move closer to dig the block const goal = new goals.GoalNear(x, y, z, 2); await bot.pathfinder.goto(goal); } await bot.dig(block); return createResponse(`Dug ${block.name} at (${x}, ${y}, ${z})`); } catch (error) { return createErrorResponse(error as Error); } } );