Skip to main content
Glama

set_game_rule

Configure Minecraft server game rules like keepInventory or doDaylightCycle using RCON commands to customize gameplay mechanics and server behavior.

Instructions

Set a game rule value via RCON. Common rules: doDaylightCycle, doWeatherCycle, doMobSpawning, keepInventory, mobGriefing, doFireTick, randomTickSpeed, playersSleepingPercentage.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ruleYesGame rule name (e.g., 'keepInventory', 'doDaylightCycle')
valueYesGame rule value (e.g., 'true', 'false', '3')

Implementation Reference

  • The set_game_rule tool is defined and handled directly in src/tools/config-tools.ts. It takes a rule name and value as input and sends a 'gamerule' command via RCON.
    server.tool(
      "set_game_rule",
      "Set a game rule value via RCON. Common rules: doDaylightCycle, doWeatherCycle, doMobSpawning, keepInventory, mobGriefing, doFireTick, randomTickSpeed, playersSleepingPercentage.",
      {
        rule: z.string().describe("Game rule name (e.g., 'keepInventory', 'doDaylightCycle')"),
        value: z.string().describe("Game rule value (e.g., 'true', 'false', '3')"),
      },
      async ({ rule, value }) => {
        try {
          const response = await manager.rcon.send(`gamerule ${rule} ${value}`);
          return { content: [{ type: "text", text: response }] };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Failed to set game rule: ${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