list_worlds
Lists all Minecraft worlds in the server directory with their file sizes for inventory management and storage optimization.
Instructions
List all Minecraft worlds in the server directory with their sizes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/world-tools.ts:15-43 (handler)The `list_worlds` tool registration and handler implementation. It uses `worldManager.listWorlds()` to fetch the worlds and formats the output.
server.tool( "list_worlds", "List all Minecraft worlds in the server directory with their sizes.", {}, async () => { const worlds = worldManager.listWorlds(); if (worlds.length === 0) { return { content: [ { type: "text", text: "No worlds found. Start the server to generate one, or use setup_world to configure generation settings.", }, ], }; } const lines: string[] = []; for (const name of worlds) { const size = worldManager.getWorldSize(name); const info = await worldManager.getWorldInfo(name).catch(() => null); const details = info ? ` | Seed: ${info.seed} | GameType: ${["Survival", "Creative", "Adventure", "Spectator"][info.gameType] ?? info.gameType} | Spawn: ${info.spawnX},${info.spawnY},${info.spawnZ}` : ""; lines.push(`📁 ${name} (${size.toFixed(1)} MB)${details}`); } return { content: [{ type: "text", text: lines.join("\n") }] }; } );