Skip to main content
Glama

system_get_battery_status

Retrieve current battery level and charging status from macOS devices to monitor power information and manage system resources.

Instructions

[System control and information] Get battery level and charging status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • AppleScript implementation that retrieves battery status using the 'pmset -g batt' shell command.
      name: "get_battery_status",
      description: "Get battery level and charging status",
      script: `
            try
              set powerSource to do shell script "pmset -g batt"
              return powerSource
            on error errMsg
              return "Failed to get battery status: " & errMsg
            end try
          `,
    },
  • Dynamically generates the tool list for MCP, constructing tool names as '{category.name}_{script.name}' (e.g., 'system_get_battery_status') from registered categories and scripts.
    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: {},
          },
        })),
      ),
    }));
  • src/index.ts:25-25 (registration)
    Registers the 'system' category (containing 'get_battery_status') with the MCP server.
    server.addCategory(systemCategory);
  • Generic tool execution handler that resolves the tool name to category/script, generates/runs the AppleScript, and returns the result.
    const result = await this.executeScript(scriptContent);
    
    this.log("info", "Tool execution completed successfully", { 
      tool: toolName,
      resultLength: result.length
    });
    
    return {
      content: [
        {
          type: "text",
          text: result,
        },
      ],
    };

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