Skip to main content
Glama

set_block

Place a block at specified coordinates in a Minecraft world using the /setblock command. Define block type and placement mode to modify terrain or structures.

Instructions

Place a block at a specific position. Uses the /setblock command.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYesX coordinate
yYesY coordinate
zYesZ coordinate
blockYesBlock ID (e.g., 'diamond_block', 'stone', 'oak_planks')
modeNoPlacement modereplace

Implementation Reference

  • The 'set_block' tool is defined and registered within the registerCommandTools function using server.tool. It accepts coordinates, a block ID, and a placement mode, then executes the '/setblock' command via RCON.
    server.tool(
      "set_block",
      "Place a block at a specific position. Uses the /setblock command.",
      {
        x: z.number().describe("X coordinate"),
        y: z.number().describe("Y coordinate"),
        z: z.number().describe("Z coordinate"),
        block: z
          .string()
          .describe("Block ID (e.g., 'diamond_block', 'stone', 'oak_planks')"),
        mode: z
          .enum(["destroy", "keep", "replace"])
          .optional()
          .default("replace")
          .describe("Placement mode"),
      },
      async ({ x, y, z: zCoord, block, mode }) => {
        try {
          const response = await manager.rcon.send(
            `setblock ${x} ${y} ${zCoord} ${block} ${mode}`
          );
          return { content: [{ type: "text", text: response }] };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Failed: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );

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/tamo2918/Minecraft-Server-MCP'

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