Skip to main content
Glama

Toggle Focus Mode

toggle_focus_mode
Idempotent

Control 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

TableJSON Schema
NameRequiredDescriptionDefault
enableYesTrue to enable Do Not Disturb, false to disable

Implementation Reference

  • 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);
        }
      },
    );
  • 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);
      }
    },
  • 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"),
    },
  • 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});
      `;
    }
  • Import of the toggleFocusModeScript helper from scripts.ts into tools.ts.
    toggleFocusModeScript,
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations (idempotentHint=true, readOnlyHint=false) already indicate the tool is idempotent and non-destructive. The description adds no contradictory information and confirms the toggle behavior, which is adequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence of 8 words with no unnecessary detail, perfectly front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one boolean parameter, no output schema), the description along with the schema and annotations covers all necessary context for an agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already provides a complete description for the single 'enable' parameter (100% coverage). The description does not add meaning beyond what the schema offers, so baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it toggles Do Not Disturb/Focus mode on or off, specifying the specific verb and resource. It distinguishes itself from sibling tools like toggle_dark_mode.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implicitly says to use this tool to enable or disable focus mode, but does not explicitly mention alternatives or when not to use. However, the purpose is clear enough for an agent to decide without confusion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/heznpc/AirMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server