Skip to main content
Glama

followEntity

Track and follow a specific entity in Minecraft by its ID, maintaining a desired distance. Ideal for AI-controlled players on remote servers.

Instructions

Follow a specific entity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
distanceNoDistance to maintain while following
entityIdYesID of the entity to follow

Implementation Reference

  • The asynchronous handler function that implements the logic for the followEntity tool. It checks connection, finds the entity, sets a pathfinder GoalFollow goal, and returns a success response.
    async ({ entityId, distance }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the entity by ID const entity = botState.bot.entities[entityId] if (!entity) { return createSuccessResponse(`Entity with ID ${entityId} not found.`) } // Start following the entity return new Promise<ToolResponse>((resolve) => { // Import pathfinder goals const { goals } = require('mineflayer-pathfinder') // Start following the entity botState.bot!.pathfinder.setGoal( new goals.GoalFollow(entity, distance) ) resolve( createSuccessResponse( `Following entity: ${ entity.name || entity.username || 'Unknown entity' } (ID: ${entityId}) with distance of ${distance} blocks` ) ) }) } catch (error) { return createErrorResponse(error) } }
  • The server.tool registration call that defines the followEntity tool, including name, description, input schema, and handler.
    server.tool( 'followEntity', 'Follow a specific entity', { entityId: z.number().describe('ID of the entity to follow'), distance: z .number() .optional() .default(2) .describe('Distance to maintain while following'), }, async ({ entityId, distance }) => { if (!botState.isConnected || !botState.bot) { return createNotConnectedResponse() } try { // Find the entity by ID const entity = botState.bot.entities[entityId] if (!entity) { return createSuccessResponse(`Entity with ID ${entityId} not found.`) } // Start following the entity return new Promise<ToolResponse>((resolve) => { // Import pathfinder goals const { goals } = require('mineflayer-pathfinder') // Start following the entity botState.bot!.pathfinder.setGoal( new goals.GoalFollow(entity, distance) ) resolve( createSuccessResponse( `Following entity: ${ entity.name || entity.username || 'Unknown entity' } (ID: ${entityId}) with distance of ${distance} blocks` ) ) }) } catch (error) { return createErrorResponse(error) } } )
  • Zod schema defining the input parameters for the followEntity tool: entityId (required number) and distance (optional number, default 2).
    entityId: z.number().describe('ID of the entity to follow'), distance: z .number() .optional() .default(2) .describe('Distance to maintain while following'),

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/nacal/mcp-minecraft-remote'

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