Skip to main content
Glama

Toggle Dark Mode

toggle_dark_mode
Idempotent

Switch macOS system appearance between dark mode and light mode with a single action.

Instructions

Toggle macOS appearance between dark mode and light mode.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
darkModeYes

Implementation Reference

  • The core JXA script that toggles dark mode by reading the current dark mode state from System Events appearance preferences and toggling it.
    export function toggleDarkModeScript(): string {
      return `
        const se = Application('System Events');
        const current = se.appearancePreferences.darkMode();
        se.appearancePreferences.darkMode = !current;
        JSON.stringify({darkMode: !current});
      `;
    }
  • The tool registration with input/output schema (no input, returns {darkMode: boolean}) and the handler that calls toggleDarkModeScript().
    server.registerTool(
      "toggle_dark_mode",
      {
        title: "Toggle Dark Mode",
        description: "Toggle macOS appearance between dark mode and light mode.",
        inputSchema: {},
        outputSchema: {
          darkMode: z.boolean(),
        },
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async () => {
        try {
          return okStructured(await runJxa<{ darkMode: boolean }>(toggleDarkModeScript()));
        } catch (e) {
          return errJxaFor("toggle dark mode", e);
        }
      },
    );
  • Registration of the 'toggle_dark_mode' tool via server.registerTool() inside registerSystemTools().
    server.registerTool(
      "toggle_dark_mode",
      {
        title: "Toggle Dark Mode",
        description: "Toggle macOS appearance between dark mode and light mode.",
        inputSchema: {},
        outputSchema: {
          darkMode: z.boolean(),
        },
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async () => {
        try {
          return okStructured(await runJxa<{ darkMode: boolean }>(toggleDarkModeScript()));
        } catch (e) {
          return errJxaFor("toggle dark mode", e);
        }
      },
    );
  • Import of toggleDarkModeScript helper from scripts.ts, which provides the JXA script string used by the handler.
    import {
      getClipboardScript,
      setClipboardScript,
      getVolumeScript,
      setVolumeScript,
      toggleDarkModeScript,
  • Documentation entry for the toggle_dark_mode tool in the docs site.
    { name: 'toggle_dark_mode', desc: 'Dark/light mode', type: 'write' },
Behavior3/5

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

The description does not contradict annotations (idempotentHint=true, etc.) but adds no behavioral context beyond what annotations already provide. It simply restates the toggle action.

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 with no redundant information. It earns its place with high efficiency.

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?

For a simple toggle tool with no parameters and an output schema, the description is completely adequate. It covers the essential functionality without missing details.

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 input schema has zero parameters, so schema coverage is 100%. The description does not need to add parameter details; baseline 4 is appropriate.

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 the verb 'Toggle' and the resource 'macOS appearance between dark mode and light mode', making it specific and distinguishable from sibling tools like toggle_focus_mode or toggle_wifi.

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 is clear about what the tool does, and given it's a simple toggle, no alternative usage guidance is necessary. However, it could mention that it affects system-wide appearance only, but lack of exclusions is acceptable.

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