Skip to main content
Glama

set_world_spawn

Set the world spawn point by modifying level.dat with specified coordinates. The server must be stopped before using this tool.

Instructions

Set the world spawn point by modifying level.dat. The server must be stopped.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
world_nameYesWorld folder name
xYesX coordinate
yYesY coordinate
zYesZ coordinate

Implementation Reference

  • Registration and implementation of the set_world_spawn MCP tool. It verifies the server is not running before using worldManager.modifyLevelDat to update the spawn coordinates.
    server.tool(
      "set_world_spawn",
      "Set the world spawn point by modifying level.dat. The server must be stopped.",
      {
        world_name: z.string().describe("World folder name"),
        x: z.number().describe("X coordinate"),
        y: z.number().describe("Y coordinate"),
        z: z.number().describe("Z coordinate"),
      },
      async ({ world_name, x, y, z: zCoord }) => {
        if (manager.isRunning()) {
          return {
            content: [
              {
                type: "text",
                text: "Cannot modify level.dat while the server is running. Use the /setworldspawn command via execute_command instead, or stop the server first.",
              },
            ],
            isError: true,
          };
        }
    
        try {
          await worldManager.modifyLevelDat(world_name, {
            SpawnX: x,
            SpawnY: y,
            SpawnZ: zCoord,
          });
          return {
            content: [
              {
                type: "text",
                text: `World spawn for "${world_name}" set to X:${x} Y:${y} Z:${zCoord}.`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error: ${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