Skip to main content
Glama

notifications_toggle_do_not_disturb

Toggle Do Not Disturb mode on macOS to silence notifications using AppleScript automation.

Instructions

[Notification management] Toggle Do Not Disturb mode using keyboard shortcut

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • AppleScript implementation that executes the tool logic by sending a specific keyboard shortcut (Cmd+Opt+Ctrl+Z) to toggle Do Not Disturb mode in System Events.
    {
      name: "toggle_do_not_disturb",
      description: "Toggle Do Not Disturb mode using keyboard shortcut",
      script: `
        try
          tell application "System Events"
            keystroke "z" using {control down, option down, command down}
          end tell
          return "Toggled Do Not Disturb mode"
        on error errMsg
          return "Failed to toggle Do Not Disturb: " & errMsg
        end try
      `,
    },
  • Registers all tools in the listTools handler, constructing the tool name as '{category}_{script}', resulting in 'notifications_toggle_do_not_disturb'.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: this.categories.flatMap((category) =>
        category.scripts.map((script) => ({
          name: `${category.name}_${script.name}`, // Changed from dot to underscore
          description: `[${category.description}] ${script.description}`,
          inputSchema: script.schema || {
            type: "object",
            properties: {},
          },
        })),
      ),
    }));
  • Executes the specific script for the tool by calling executeScript on the script content from the matching category and script.
    const scriptContent =
      typeof script.script === "function"
        ? script.script(request.params.arguments)
        : script.script;
  • Helper function that executes the AppleScript code using osascript, handling execution and errors.
    private async executeScript(script: string): Promise<string> {
      // Log script execution (truncate long scripts for readability)
      const scriptPreview = script.length > 100 ? script.substring(0, 100) + "..." : script;
      this.log("debug", "Executing AppleScript", { scriptPreview });
      
      try {
        const startTime = Date.now();
        const { stdout } = await execAsync(
          `osascript -e '${script.replace(/'/g, "'\"'\"'")}'`,
        );
        const executionTime = Date.now() - startTime;
        
        this.log("debug", "AppleScript executed successfully", { 
          executionTimeMs: executionTime,
          outputLength: stdout.length
        });
        
        return stdout.trim();
      } catch (error) {
        // Properly type check the error object
        let errorMessage = "Unknown error occurred";
        if (error && typeof error === "object") {
          if ("message" in error && typeof error.message === "string") {
            errorMessage = error.message;
          } else if (error instanceof Error) {
            errorMessage = error.message;
          }
        } else if (typeof error === "string") {
          errorMessage = error;
        }
        
        this.log("error", "AppleScript execution failed", { 
          error: errorMessage,
          scriptPreview
        });
        
        throw new Error(`AppleScript execution failed: ${errorMessage}`);
      }
    }
  • src/index.ts:6-29 (registration)
    Imports and registers the notifications category containing the toggle_do_not_disturb script.
    import { notificationsCategory } from "./categories/notifications.js";
    import { itermCategory } from "./categories/iterm.js";
    import { mailCategory } from "./categories/mail.js";
    import { pagesCategory } from "./categories/pages.js";
    import { shortcutsCategory } from "./categories/shortcuts.js";
    import { messagesCategory } from "./categories/messages.js";
    import { notesCategory } from "./categories/notes.js";
    
    const server = new AppleScriptFramework({
      name: "applescript-server",
      version: "1.0.4",
      debug: false,
    });
    
    // Log startup information using stderr (server isn't connected yet)
    console.error(`[INFO] Starting AppleScript MCP server - PID: ${process.pid}`);
    
    // Add all categories
    console.error("[INFO] Registering categories...");
    server.addCategory(systemCategory);
    server.addCategory(calendarCategory);
    server.addCategory(finderCategory);
    server.addCategory(clipboardCategory);
    server.addCategory(notificationsCategory);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'Toggle Do Not Disturb mode', implying a state change, but doesn't clarify if this requires permissions, what the default state is, whether it's reversible, or any side effects like notifications being suppressed. This leaves significant gaps for a mutation tool.

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, efficient sentence that front-loads the key action ('Toggle Do Not Disturb mode') and adds a useful detail ('using keyboard shortcut') without any fluff. Every word earns its place, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's complexity (simple toggle with no parameters) and no output schema, the description is minimally adequate. It states what the tool does but lacks details on behavioral aspects like permissions or effects, which are important for a mutation tool with no annotations. This makes it complete enough for basic use but with clear gaps.

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

Parameters4/5

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

The tool has 0 parameters, and schema description coverage is 100%, so there's no need for parameter details in the description. The baseline for 0 parameters is 4, as the description appropriately doesn't waste space on non-existent parameters.

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

Purpose4/5

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

The description clearly states the verb ('Toggle') and resource ('Do Not Disturb mode'), making the purpose specific and understandable. However, it doesn't distinguish this tool from its sibling 'notifications_send_notification' or other notification-related tools, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description mentions 'using keyboard shortcut', which provides some implied context for when to use this tool (e.g., for quick toggling via shortcuts). However, it lacks explicit guidance on when to choose this over alternatives, such as manual toggling or other notification tools, and doesn't specify any prerequisites or exclusions.

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/joshrutkowski/applescript-mcp'

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