world
Control and manage Minecraft Bedrock world settings: adjust time, weather, day/night cycles, query world data, send messages, execute commands, and sequence actions for precise server operations.
Instructions
World management: time, weather, environment, day/night cycles, world queries, connections
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | World management action to perform | |
| command | No | Minecraft Bedrock Edition command to execute (without /). For correct syntax and available commands, use the minecraft_wiki tool to search for specific command information. Examples: "give @p diamond_sword", "tp @p 0 64 0", "setblock ~ ~ ~ stone" | |
| duration | No | Weather duration in ticks (optional) | |
| message | No | Message to send to all players | |
| steps | No | Array of world actions for sequence. Each step should have "type" field and relevant parameters. | |
| target | No | Target player for message (optional, defaults to all players) | |
| time | No | Time in ticks (0-24000, where 0=dawn, 6000=noon, 12000=dusk, 18000=midnight) | |
| weather | No | Weather type to set |
Implementation Reference
- src/tools/core/world.ts:74-197 (handler)Main handler function that processes input arguments and executes world management operations based on the 'action' parameter (e.g., set_time, get_time, set_weather, run_command). Uses this.world from socket-be to interact with Minecraft.async execute(args: { action: string; time?: number; weather?: string; duration?: number; message?: string; target?: string; command?: string; steps?: SequenceStep[]; }): Promise<ToolCallResult> { if (!this.world) { return { success: false, message: 'World not available. Ensure Minecraft is connected.' }; } try { const { action } = args; let result: any; let message: string; switch (action) { case 'set_time': if (args.time === undefined) return { success: false, message: 'Time required for set_time' }; await this.world.setTimeOfDay(args.time); const timeDesc = this.getTimeDescription(args.time); message = `Time set to ${args.time} ticks (${timeDesc})`; break; case 'get_time': const currentTime = await this.world.getTimeOfDay(); const currentDay = await this.world.getDay(); const currentTick = await this.world.getCurrentTick(); result = { timeOfDay: currentTime, day: currentDay, totalTicks: currentTick, description: this.getTimeDescription(currentTime) }; message = `Current time: ${currentTime} ticks (${this.getTimeDescription(currentTime)}) on day ${currentDay}`; break; case 'get_day': result = await this.world.getDay(); message = `Current day: ${result}`; break; case 'set_weather': if (!args.weather) return { success: false, message: 'Weather required for set_weather' }; const weatherType = this.normalizeWeatherType(args.weather); await this.world.setWeather(weatherType, args.duration); message = args.duration ? `Weather set to ${args.weather} for ${args.duration} ticks` : `Weather set to ${args.weather}`; break; case 'get_weather': result = await this.world.getWeather(); message = `Current weather: ${result}`; break; case 'get_players': const players = await this.world.getPlayers(); const playerInfo = players.map(p => ({ name: p.name, isLocal: p.isLocalPlayer })); result = playerInfo; message = `Found ${players.length} players online`; break; case 'get_world_info': result = { name: this.world.name, connectedAt: this.world.connectedAt, averagePing: this.world.averagePing, maxPlayers: this.world.maxPlayers, isValid: this.world.isValid }; message = `World info retrieved: ${this.world.name}`; break; case 'send_message': if (!args.message) return { success: false, message: 'Message required for send_message' }; await this.world.sendMessage(args.message, args.target); message = args.target ? `Message sent to ${args.target}: "${args.message}"` : `Message sent to all players: "${args.message}"`; break; case 'run_command': if (!args.command) return { success: false, message: 'Command required for run_command' }; result = await this.world.runCommand(args.command); message = `Command executed: ${args.command}`; break; case 'get_connection_info': result = { averagePing: this.world.averagePing, connectedAt: this.world.connectedAt, maxPlayers: this.world.maxPlayers, isValid: this.world.isValid }; message = 'Connection info retrieved'; break; case 'sequence': if (!args.steps) { return this.createErrorResponse('steps array is required for sequence action'); } return await this.executeSequence(args.steps as SequenceStep[]); default: return { success: false, message: `Unknown action: ${action}` }; } return { success: true, message: message, data: { action, result, timestamp: Date.now() } }; } catch (error) { return { success: false, message: `World management error: ${error instanceof Error ? error.message : String(error)}` }; } }
- src/tools/core/world.ts:13-59 (schema)Defines the input schema for the 'world' tool, specifying properties like action (required, enum of actions), time, weather, etc., for validation.readonly inputSchema: InputSchema = { type: 'object', properties: { action: { type: 'string', description: 'World management action to perform', enum: [ 'set_time', 'get_time', 'get_day', 'set_weather', 'get_weather', 'get_players', 'get_world_info', 'send_message', 'run_command', 'get_connection_info', 'sequence' ] }, time: { type: 'number', description: 'Time in ticks (0-24000, where 0=dawn, 6000=noon, 12000=dusk, 18000=midnight)', minimum: 0, maximum: 24000 }, weather: { type: 'string', description: 'Weather type to set', enum: ['clear', 'rain', 'thunder'] }, duration: { type: 'number', description: 'Weather duration in ticks (optional)', minimum: 0 }, message: { type: 'string', description: 'Message to send to all players' }, target: { type: 'string', description: 'Target player for message (optional, defaults to all players)' }, command: { type: 'string', description: 'Minecraft Bedrock Edition command to execute (without /). For correct syntax and available commands, use the minecraft_wiki tool to search for specific command information. Examples: "give @p diamond_sword", "tp @p 0 64 0", "setblock ~ ~ ~ stone"' }, steps: { type: 'array', description: 'Array of world actions for sequence. Each step should have "type" field and relevant parameters.' } }, required: ['action'] };
- src/server.ts:348-372 (registration)Registers the WorldTool instance in the tools array during server initialization. These tools are later registered to the MCP server using their .name property in registerModularTools().this.tools = [ // Socket-BE Core API ツール(推奨 - シンプルでAI使いやすい) new AgentTool(), new WorldTool(), new PlayerTool(), new BlocksTool(), new SystemTool(), new CameraTool(), new SequenceTool(), new MinecraftWikiTool(), // Advanced Building ツール(高レベル建築機能) new BuildCubeTool(), // ✅ 完全動作 new BuildLineTool(), // ✅ 完全動作 new BuildSphereTool(), // ✅ 完全動作 new BuildCylinderTool(), // ✅ 修正済み new BuildParaboloidTool(), // ✅ 基本動作 new BuildHyperboloidTool(), // ✅ 基本動作 new BuildRotateTool(), // ✅ 基本動作 new BuildTransformTool(), // ✅ 基本動作 new BuildTorusTool(), // ✅ 修正完了 new BuildHelixTool(), // ✅ 修正完了 new BuildEllipsoidTool(), // ✅ 修正完了 new BuildBezierTool(), // ✅ 新規追加(可変制御点ベジェ曲線) ];