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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"rule": "<rule>",
"value": "<value>"
},
"name": "set_game_rule"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rule | Yes | Game rule name (e.g., 'keepInventory', 'doDaylightCycle') | |
| value | Yes | Game rule value (e.g., 'true', 'false', '3') |
Implementation Reference
- src/tools/config-tools.ts:106-129 (handler)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, }; } } );