moveTo
Teleport a Minecraft player to specified X, Y, Z coordinates. Use precise location control for navigation and building tasks.
Instructions
Move the player to a specific location
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate | |
| y | Yes | Y coordinate | |
| z | Yes | Z coordinate |
Implementation Reference
- src/tools/movement.ts:38-87 (handler)The handler function for the 'moveTo' tool. Registers tool with name 'moveTo', defines Zod schema for x/y/z coordinates, and implements logic using mineflayer-pathfinder (Movements, GoalBlock, pathfinder.goto) with a 60-second timeout.
server.tool( 'moveTo', 'Move the player to a specific location', { x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), }, async ({ x, y, z }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Set pathfinder Movements const movements = new Movements(botState.bot) botState.bot.pathfinder.setMovements(movements) // Set target position const goal = new goals.GoalBlock(x, y, z) return new Promise<ToolResponse>((resolve) => { // Start movement botState .bot!.pathfinder.goto(goal) .then(() => { resolve( createSuccessResponse( `Successfully moved to X=${x}, Y=${y}, Z=${z}` ) ) }) .catch((err) => { resolve(createErrorResponse(err)) }) // Timeout handling (if still moving after 1 minute) setTimeout(() => { resolve( createSuccessResponse( 'Movement is taking longer than expected. Still trying to reach the destination...' ) ) }, 60000) }) } catch (error) { return createErrorResponse(error) } } ) - src/tools/movement.ts:41-45 (schema)Input schema for the 'moveTo' tool using Zod: x (number), y (number), z (number) coordinate descriptions.
{ x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), }, - src/tools/index.ts:21-21 (registration)Registration call: registerMovementTools() is invoked from registerAllTools() to register the 'moveTo' tool on the MCP server.
registerMovementTools() - src/tools/movement.ts:13-88 (registration)The registerMovementTools() export function that calls server.tool('moveTo', ...) to register the tool.
export function registerMovementTools() { // Tool to get current position information server.tool( 'getPosition', 'Get the current position of the player in the Minecraft world', {}, async () => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { const position = botState.bot.entity.position return createSuccessResponse( `Current position: X=${position.x.toFixed(2)}, Y=${position.y.toFixed( 2 )}, Z=${position.z.toFixed(2)}` ) } catch (error) { return createErrorResponse(error) } } ) // Tool to move to a specified location server.tool( 'moveTo', 'Move the player to a specific location', { x: z.number().describe('X coordinate'), y: z.number().describe('Y coordinate'), z: z.number().describe('Z coordinate'), }, async ({ x, y, z }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Set pathfinder Movements const movements = new Movements(botState.bot) botState.bot.pathfinder.setMovements(movements) // Set target position const goal = new goals.GoalBlock(x, y, z) return new Promise<ToolResponse>((resolve) => { // Start movement botState .bot!.pathfinder.goto(goal) .then(() => { resolve( createSuccessResponse( `Successfully moved to X=${x}, Y=${y}, Z=${z}` ) ) }) .catch((err) => { resolve(createErrorResponse(err)) }) // Timeout handling (if still moving after 1 minute) setTimeout(() => { resolve( createSuccessResponse( 'Movement is taking longer than expected. Still trying to reach the destination...' ) ) }, 60000) }) } catch (error) { return createErrorResponse(error) } } ) }