Toggle Focus Mode
toggle_focus_modeControl your focus by enabling or disabling Do Not Disturb mode to reduce interruptions and manage notifications.
Instructions
Toggle Do Not Disturb (Focus mode) on or off.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| enable | Yes | True to enable Do Not Disturb, false to disable |
Implementation Reference
- src/system/tools.ts:467-489 (registration)Registration of the 'toggle_focus_mode' tool with schema definition and handler callback.
server.registerTool( "toggle_focus_mode", { title: "Toggle Focus Mode", description: "Toggle Do Not Disturb (Focus mode) on or off.", inputSchema: { enable: z.boolean().describe("True to enable Do Not Disturb, false to disable"), }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async ({ enable }) => { try { return ok(await runJxa(toggleFocusModeScript(enable))); } catch (e) { return errJxaFor("toggle focus mode", e); } }, ); - src/system/tools.ts:482-488 (handler)Handler function for toggle_focus_mode that executes the JXA script via toggleFocusModeScript.
async ({ enable }) => { try { return ok(await runJxa(toggleFocusModeScript(enable))); } catch (e) { return errJxaFor("toggle focus mode", e); } }, - src/system/tools.ts:472-474 (schema)Input schema for toggle_focus_mode: expects a boolean 'enable' parameter.
inputSchema: { enable: z.boolean().describe("True to enable Do Not Disturb, false to disable"), }, - src/system/scripts.ts:264-272 (helper)Helper function that generates the JXA script to toggle Do Not Disturb using 'defaults' command and killall NotificationCenter.
export function toggleFocusModeScript(enable: boolean): string { return ` const app = Application.currentApplication(); app.includeStandardAdditions = true; app.doShellScript('defaults -currentHost write com.apple.notificationcenterui doNotDisturb -boolean ${enable ? "true" : "false"}'); app.doShellScript('killall NotificationCenter 2>/dev/null || true'); JSON.stringify({doNotDisturb: ${enable}, success: true}); `; } - src/system/tools.ts:25-25 (registration)Import of the toggleFocusModeScript helper from scripts.ts into tools.ts.
toggleFocusModeScript,