rest
Regain health in Minecraft by resting for a specified time (default: 10 seconds). Use this tool as part of the MCP Server to enable AI agents to manage character recovery during gameplay.
Instructions
Rest to regain health
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| restTime | No | Time to rest in seconds (default: 10) |
Implementation Reference
- The main handler function that executes the 'rest' tool logic: validates parameters, waits for a configurable duration in ticks (simulating rest), handles interruptions, and emits observations.export const rest = async ( bot: Bot, params: ISkillParams, serviceParams: ISkillServiceParams, ): Promise<boolean> => { const skillName = 'rest'; const requiredParams: string[] = []; const isParamsValid = validateSkillParams( params, requiredParams, skillName, ); if (!isParamsValid) { serviceParams.cancelExecution?.(); bot.emit( 'alteraBotEndObservation', `Mistake: You didn't provide all of the required parameters ${requiredParams.join(', ')} for the ${skillName} skill.`, ); return false; } const unpackedParams = { restTime: params.restTime ?? 4, signal: serviceParams.signal, }; let {restTime, signal} = unpackedParams; const SECONDS_TO_TICKS = 20; // twenty ticks per second restTime = Math.min(restTime, 12); // Set max rest time to 12 seconds. const ticks_to_rest = restTime * SECONDS_TO_TICKS; // convert seconds to ticks const tick_interval = SECONDS_TO_TICKS * 2; // allow interrupting every 2 seconds let cur_sleep_ticks = 0; while (cur_sleep_ticks < ticks_to_rest) { if (isSignalAborted(signal)) { // You interrupted your own rest return bot.emit( 'alteraBotEndObservation', `You decided to do something else instead of resting.`, ); } await bot.waitForTicks(tick_interval); cur_sleep_ticks += tick_interval; } return bot.emit('alteraBotEndObservation', `You finished resting.`); };
- Schema definition for the 'rest' tool, specifying the input parameters (restTime), description, and required fields (none).rest: { description: "Rest to regain health", params: { restTime: { type: "number", description: "Time to rest in seconds (default: 10)" } }, required: [] },
- mcp-server/src/skillRegistry.ts:350-367 (registration)Function that registers all skills including 'rest' by iterating over SKILL_METADATA, creating SkillDefinition objects with schema and dynamic executor loader.export async function loadSkills(): Promise<SkillDefinition[]> { const skills: SkillDefinition[] = []; for (const [skillName, metadata] of Object.entries(SKILL_METADATA)) { skills.push({ name: skillName, description: metadata.description, inputSchema: { type: "object", properties: metadata.params, required: metadata.required }, execute: createSkillExecutor(skillName) }); } return skills; }