System Power
system_powerShutdown or restart your Mac with action commands. Select shutdown to power off or restart to reboot.
Instructions
Shutdown or restart the Mac.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Power action: shutdown or restart |
Implementation Reference
- src/system/tools.ts:573-579 (handler)The tool handler function that executes the system_power logic. It runs the JXA script for the given action (shutdown/restart) via systemPowerScript().
async ({ action }) => { try { return ok(await runJxa<{ action: string; success: boolean }>(systemPowerScript(action))); } catch (e) { return errJxaFor("system power", e); } }, - src/system/tools.ts:558-565 (schema)Registration + schema for system_power tool. Defines inputSchema with a 'action' enum of 'shutdown' or 'restart', and marks the tool as destructive and not read-only.
server.registerTool( "system_power", { title: "System Power", description: "Shutdown or restart the Mac. Use with caution.", inputSchema: { action: z.enum(["shutdown", "restart"]).describe("Power action: shutdown or restart"), }, - src/system/tools.ts:558-580 (registration)Tool registration via server.registerTool('system_power', ...) — same block as schema.
server.registerTool( "system_power", { title: "System Power", description: "Shutdown or restart the Mac. Use with caution.", inputSchema: { action: z.enum(["shutdown", "restart"]).describe("Power action: shutdown or restart"), }, annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false, }, }, async ({ action }) => { try { return ok(await runJxa<{ action: string; success: boolean }>(systemPowerScript(action))); } catch (e) { return errJxaFor("system power", e); } }, ); - src/system/scripts.ts:294-303 (helper)Helper function systemPowerScript() that generates a JXA script string. It validates the action via ALLOWED_POWER_ACTIONS set and returns a JXA script that calls System Events' shutdown() or restart().
export function systemPowerScript(action: string): string { if (!ALLOWED_POWER_ACTIONS.has(action)) { throw new Error(`Invalid power action: ${action}`); } return ` const se = Application('System Events'); se.${action}(); JSON.stringify({action: '${action}', success: true}); `; }