Skip to main content
Glama
zeeweebee

Minecraft MCP Server

by zeeweebee

fly-to

Teleport a Minecraft character to specific coordinates by providing X, Y, and Z values for precise movement within the game world.

Instructions

Make the bot fly to a specific position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate
zYesZ coordinate

Implementation Reference

  • The complete inline handler for the 'fly-to' tool. Checks for creative mode, sets up a timed abortable flight using bot.creative.flyTo via a helper, handles errors and timeouts.
    server.tool(
      "fly-to",
      "Make the bot fly to a specific 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> => {
        if (!bot.creative) {
          return createResponse("Creative mode is not available. Cannot fly.");
        }
        
        const currentPos = bot.entity.position;
        console.error(`Flying from (${Math.floor(currentPos.x)}, ${Math.floor(currentPos.y)}, ${Math.floor(currentPos.z)}) to (${Math.floor(x)}, ${Math.floor(y)}, ${Math.floor(z)})`);
    
        const controller = new AbortController();
        const FLIGHT_TIMEOUT_MS = 20000;
        
        const timeoutId = setTimeout(() => {
          if (!controller.signal.aborted) {
            controller.abort();
          }
        }, FLIGHT_TIMEOUT_MS);
        
        try {
          const destination = new Vec3(x, y, z);
          
          await createCancellableFlightOperation(bot, destination, controller);
    
          return createResponse(`Successfully flew to position (${x}, ${y}, ${z}).`);
        } catch (error) {
          if (controller.signal.aborted) {
            const currentPosAfterTimeout = bot.entity.position;
            return createErrorResponse(
              `Flight timed out after ${FLIGHT_TIMEOUT_MS/1000} seconds. The destination may be unreachable. ` +
              `Current position: (${Math.floor(currentPosAfterTimeout.x)}, ${Math.floor(currentPosAfterTimeout.y)}, ${Math.floor(currentPosAfterTimeout.z)})`
            );
          }
          
          console.error('Flight error:', error);
          return createErrorResponse(error as Error);
        } finally {
          clearTimeout(timeoutId);
          bot.creative.stopFlying();
        }
      }
    );
  • Zod input schema defining the required x, y, z coordinates as numbers for the fly-to tool.
    {
      x: z.number().describe("X coordinate"),
      y: z.number().describe("Y coordinate"),
      z: z.number().describe("Z coordinate")
    },
  • Helper function that wraps bot.creative.flyTo in a Promise with AbortController support for cancellable flight operations.
    function createCancellableFlightOperation(
      bot: any, 
      destination: Vec3, 
      controller: AbortController
    ): Promise<boolean> {
      return new Promise((resolve, reject) => {
        let aborted = false;
        
        controller.signal.addEventListener('abort', () => {
          aborted = true;
          bot.creative.stopFlying();
          reject(new Error("Flight operation cancelled"));
        });
        
        bot.creative.flyTo(destination)
          .then(() => {
            if (!aborted) {
              resolve(true);
            }
          })
          .catch((err: any) => {
            if (!aborted) {
              reject(err);
            }
          });
      });
    }
  • src/bot.ts:145-145 (registration)
    Registration call that invokes registerFlightTools, which defines and registers the fly-to tool.
    registerFlightTools(server, bot);

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