Skip to main content
Glama
leo4life2

Minecraft MCP Server

by leo4life2

prepareLandForFarming

Automate tilling soil in Minecraft for farming using a scripted tool that integrates with the MCP Server, enabling efficient land preparation for crop planting.

Instructions

Prepare land for farming by tilling soil

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler function that executes the tool: prepares farmland by tilling soil near water sources (within 4-block distance), clears grass above, navigates to each spot, tills using tillLandToFarmland helper, then plants seeds using plantSeedsOnFarmland, and emits completion observation.
    export const prepareLandForFarming = async (
      bot: Bot,
      params: ISkillParams,
      serviceParams: ISkillServiceParams,
    ): Promise<boolean> => {
      const skillName = 'prepareLandForFarming';
      const requiredParams: string[] = [];
      const isParamsValid = validateSkillParams(
        params,
        requiredParams,
        skillName,
      );
      if (!isParamsValid) {
        serviceParams.cancelExecution?.();
        bot.emit(
          'alteraBotEndObservation',
          `Mistake: You didn't provide all of the required parameters ${requiredParams.join(', ')} for the ${skillName} skill.`,
        );
        return false;
      }
      const {signal, getStatsData, setStatsData} = serviceParams;
      const mcData = minecraftData(bot.version);
      // Avoid breaking blocks while building
      const movements = new Movements(bot);
      movements.canDig = false; // Prevent the bot from breaking blocks
      bot.pathfinder.setMovements(movements);
    
      // Remove expanding the farms for now
      // const placedCount = expandFarm(bot, 8);
      const waterBlocks = bot
        .findBlocks({
          matching: mcData.blocksByName.water.id,
          maxDistance: 6,
          count: 100,
        })
        .map((position) => bot.blockAt(position));
      // console.log("Found water blocks: ", waterBlocks.length);
    
      const airId = mcData.blocksByName.air.id;
      // grassId is 1.19, shortGrassId is 1.20
      const grassId = mcData.blocksByName.grass?.id;
      const shortGrassId = mcData.blocksByName.short_grass?.id;
      const tallGrassId = mcData.blocksByName.tall_grass?.id;
    
      const adjacentWaterBlocks = waterBlocks.filter((waterBlock) =>
        hasAdjacentLand(bot, {position: waterBlock.position}),
      );
      // console.log("Found adjacent water blocks: ", adjacentWaterBlocks.length);
      const queue = adjacentWaterBlocks.map((waterBlock) => ({
        block: waterBlock,
        distance: 0,
      }));
      // const queue = waterBlocks.map(waterBlock => ({ block: waterBlock, distance: 0 }));
      // console.log("Found water blocks: ", queue.length)
      const visited = new Set();
      const tillableBlocks = [];
    
      while (queue.length > 0) {
        const {block, distance} = queue.shift(); // Get the first element from the queue
        // console.log("Processing block: ", block.position.toString());
        const blockKey = block.position.toString();
    
        if (visited.has(blockKey)) continue; // Skip if already visited
        visited.add(blockKey);
    
        // If it's a dirt or grass block and within 4 blocks of water, mark it for tilling
        if (
          distance > 0 &&
          distance <= 4 &&
          (block.type === mcData.blocksByName.dirt.id ||
            block.type === mcData.blocksByName.grass_block.id)
        ) {
          const blockAbove = bot.blockAt(block.position.offset(0, 1, 0));
          if (
            blockAbove &&
            (blockAbove.type === airId ||
              blockAbove.type === grassId ||
              blockAbove.type === shortGrassId ||
              blockAbove.type === tallGrassId)
          ) {
            tillableBlocks.push(block);
          }
        }
    
        if (distance < 4) {
          const neighbors = getNeighborBlocks(bot, {
            position: block.position,
            yLevel: block.position.y,
          });
          for (const neighbor of neighbors) {
            const neighborKey = neighbor.position.toString();
            if (!visited.has(neighborKey)) {
              queue.push({block: neighbor, distance: distance + 1});
            }
          }
        }
      }
    
      // Till the identified blocks
      for (const block of tillableBlocks) {
        // Navigate to the block
        await navigateToLocation(bot, {
          x: block.position.x,
          y: block.position.y,
          z: block.position.z,
          range: 1,
        });
        // check for signal to cancel
        if (isSignalAborted(signal)) {
          return bot.emit(
            'alteraBotEndObservation',
            `You decided to do something else and stop preparing land for farming.`,
          );
        }
    
        await tillLandToFarmland(bot, {
          targetBlock: block,
          setStatsData,
          getStatsData,
        });
      }
    
      await plantSeedsOnFarmland(bot, {getStatsData, setStatsData, radius: 8});
    
      const defaultMovements = new Movements(bot);
      bot.pathfinder.setMovements(defaultMovements);
    
      bot.emit(
        'alteraBotEndObservation',
        `You ` /* + `placed ${placedCount} new dirt blocks in the farm, `*/ +
          `tilled ${tillableBlocks.length} pieces of land, and have finished preparing land for farming.`,
      );
      return true;
    };
  • Registers the 'prepareLandForFarming' skill in SKILL_METADATA, defining its description and empty input schema (no parameters required). Used by loadSkills() to create SkillDefinition.
    prepareLandForFarming: {
        description: "Prepare land for farming by tilling soil",
        params: {},
        required: []
    },
  • Dynamically generates the input schema for the skill from SKILL_METADATA during registration in loadSkills().
        type: "object",
        properties: metadata.params,
        required: metadata.required
    },
    execute: createSkillExecutor(skillName)
  • Helper to filter water blocks that have adjacent land (dirt or grass_block), used to start BFS for finding tillable areas.
    const hasAdjacentLand = (
      bot: Bot,
      options: IHasAdjacentLandOptions,
    ): boolean => {
      const {position} = options;
      const mcData = minecraftData(bot.version);
      const offsets = [
        {x: 1, y: 0, z: 0},
        {x: -1, y: 0, z: 0},
        {x: 0, y: 0, z: 1},
        {x: 0, y: 0, z: -1},
      ];
    
      return offsets.some((offset) => {
        const newPos = position.plus(new Vec3(offset.x, offset.y, offset.z));
        const block = bot.blockAt(newPos);
        return (
          block &&
          (block.type === mcData.blocksByName.dirt.id ||
            block.type === mcData.blocksByName.grass_block.id)
        );
      });
    };
  • Helper to get horizontal neighbor blocks for BFS expansion from water to find tillable land within distance 4.
    const getNeighborBlocks = (
      bot: Bot,
      options: IGetNeighborBlocksOptions,
    ): Block[] => {
      const {position, yLevel} = options;
      const offsets = [
        {x: 1, y: 0, z: 0},
        {x: -1, y: 0, z: 0},
        {x: 0, y: 0, z: 1},
        {x: 0, y: 0, z: -1},
        // { x: 0, y: 1, z: 0 }, { x: 0, y: -1, z: 0 }, // Check above and below too
      ];
    
      return offsets
        .map((offset) => {
          const newPos = position.plus(new Vec3(offset.x, offset.y, offset.z));
          return bot.blockAt(newPos);
        })
        .filter((block) => block && block.position.y === yLevel); // Remove undefined blocks (e.g., out of the world bounds)
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('tilling soil') but doesn't reveal traits like whether it's destructive, requires specific permissions, has side effects (e.g., affecting nearby crops), or what the outcome entails (e.g., soil readiness for planting). This leaves significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's action without any fluff or redundancy. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation action with no annotations and no output schema), the description is incomplete. It doesn't explain behavioral aspects like effects, prerequisites, or return values, which are crucial for an agent to use it correctly in context with siblings like 'harvestMatureCrops'.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description doesn't add param info, but that's acceptable here. Baseline is 4 for zero parameters, as it avoids unnecessary detail.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('prepare') and resource ('land for farming'), and distinguishes it from siblings like 'harvestMatureCrops' or 'mineResource' by focusing on soil preparation. However, it doesn't explicitly differentiate from potential similar actions like 'tillSoil' if such existed, keeping it at 4 rather than 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as whether it's for initial land setup versus ongoing maintenance, or how it relates to siblings like 'harvestMatureCrops' or 'placeItemNearYou'. It lacks explicit when/when-not instructions or prerequisite context, leaving usage unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/leo4life2/minecraft-mcp-http'

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