Skip to main content
Glama

Get Battery Status

get_battery_status
Read-onlyIdempotent

Retrieve the current battery percentage, charging state, power source, and estimated time remaining on macOS.

Instructions

Get battery percentage, charging state, power source, and estimated time rema...

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The actual JXA script that executes the battery status logic. It uses pmset -g batt via shell command, parses the output to extract battery percentage, charging state, power source, and time remaining.
    export function getBatteryStatusScript(): string {
      return `
        const app = Application.currentApplication();
        app.includeStandardAdditions = true;
        const output = app.doShellScript('pmset -g batt');
        const lines = output.split('\\n');
        let percentage = null;
        let charging = false;
        let timeRemaining = null;
        let source = null;
        for (const line of lines) {
          if (line.indexOf('AC Power') !== -1) source = 'AC Power';
          if (line.indexOf('Battery Power') !== -1) source = 'Battery Power';
          const pctMatch = line.match(/(\\d+)%/);
          if (pctMatch) percentage = parseInt(pctMatch[1]);
          if (line.indexOf('charging') !== -1 && line.indexOf('discharging') === -1 && line.indexOf('not charging') === -1) charging = true;
          const timeMatch = line.match(/(\\d+:\\d+) remaining/);
          if (timeMatch) timeRemaining = timeMatch[1];
        }
        JSON.stringify({
          percentage: percentage,
          charging: charging,
          source: source,
          timeRemaining: timeRemaining,
          raw: output
        });
      `;
  • Registers the 'get_battery_status' tool on the MCP server with title 'Get Battery Status', description, input/output schemas, and a handler that runs the getBatteryStatusScript via JXA.
    server.registerTool(
      "get_battery_status",
      {
        title: "Get Battery Status",
        description: "Get battery percentage, charging state, power source, and estimated time remaining.",
        inputSchema: {},
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async () => {
        try {
          return ok(await runJxa(getBatteryStatusScript()));
        } catch (e) {
          return errJxaFor("get battery status", e);
        }
      },
    );
  • Tool link entry: get_system_info suggests get_battery_status as a follow-up action.
    get_system_info: [
      { tool: "list_running_apps", description: "See running apps" },
      { tool: "get_battery_status", description: "Check battery" },
    ],
  • Documentation listing 'get_battery_status' as a read-type tool with description 'Battery info'.
    { name: 'get_battery_status', desc: 'Battery info', type: 'read' },
  • Korean prompt referencing get_battery_status for checking battery level.
    - get_battery_status로 배터리 잔량 확인
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true. The description does not add behavioral context beyond what the annotations provide, such as frequency of data refresh or permission requirements. Therefore, it is neutral and does not exceed the baseline.

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 sentence that conveys all essential information without any fluff. It is front-loaded and highly efficient.

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

Completeness4/5

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

Given the tool's simplicity and lack of an output schema, the description adequately lists the returned data fields (percentage, charging state, power source, estimated time remaining). However, it could be slightly more complete by specifying units (e.g., minutes for time remaining).

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 zero parameters, and schema coverage is 100%. The description does not need to explain parameters. The baseline score for zero parameters is 4, as there are no parameter meanings to clarify.

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 tool retrieves battery percentage, charging state, power source, and estimated time remaining. This is specific and unambiguous, and no sibling tool duplicates this functionality, so differentiation is not needed.

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

Usage Guidelines3/5

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

No guidance on when to use or when not to use. However, the tool is simple and read-only with zero parameters, making its usage obvious. A score of 3 reflects minimal but adequate guidance.

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