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
| Name | Required | Description | Default |
|---|---|---|---|
| world_name | Yes | World folder name | |
| x | Yes | X coordinate | |
| y | Yes | Y coordinate | |
| z | Yes | Z coordinate |
Implementation Reference
- src/tools/world-tools.ts:168-216 (handler)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, }; } } );