Skip to main content
Glama

adb_get_battery_info

Retrieve battery status and health data from Android devices through ADB for monitoring power levels and charging state.

Instructions

Get battery information from the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdNoDevice ID (optional)

Implementation Reference

  • Main handler function for 'adb_get_battery_info' tool. Executes 'adb shell dumpsys battery', parses key battery properties using extractValue helper, and returns structured data.
    async getBatteryInfo(deviceId?: string) {
      try {
        const connected = await this.adbClient.isDeviceConnected(deviceId);
        if (!connected) {
          return {
            success: false,
            error: 'Device not connected',
            message: 'Cannot get battery info - device is not connected'
          };
        }
    
        const command = 'shell dumpsys battery';
        const result = await this.adbClient.executeCommand(command, deviceId);
        
        if (!result.success) {
          return {
            success: false,
            error: result.error,
            message: 'Failed to get battery info'
          };
        }
    
        // Parse battery information
        const output = result.output;
        const batteryInfo = {
          level: this.extractValue(output, 'level'),
          scale: this.extractValue(output, 'scale'),
          status: this.extractValue(output, 'status'),
          health: this.extractValue(output, 'health'),
          present: this.extractValue(output, 'present'),
          plugged: this.extractValue(output, 'plugged'),
          voltage: this.extractValue(output, 'voltage'),
          temperature: this.extractValue(output, 'temperature'),
          technology: this.extractValue(output, 'technology')
        };
    
        return {
          success: true,
          data: {
            ...batteryInfo,
            deviceId: deviceId || this.adbClient.getDefaultDevice()
          },
          message: 'Battery information retrieved successfully'
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
          message: 'Failed to get battery info'
        };
      }
    }
  • Tool schema definition including name, description, and input schema (optional deviceId).
    {
      name: 'adb_get_battery_info',
      description: 'Get battery information from the device',
      inputSchema: {
        type: 'object',
        properties: {
          deviceId: {
            type: 'string',
            description: 'Device ID (optional)',
          },
        },
        required: [],
      },
    },
  • src/index.ts:477-478 (registration)
    Switch case registration that maps tool name to the shellTools.getBatteryInfo handler.
    case 'adb_get_battery_info':
      return await this.handleToolCall(this.shellTools.getBatteryInfo(args?.deviceId as string));
  • Private helper method used by getBatteryInfo to parse key-value pairs from 'dumpsys battery' output.
    private extractValue(text: string, key: string): string {
      const regex = new RegExp(`${key}:\\s*(.+)`);
      const match = text.match(regex);
      return match ? match[1].trim() : 'N/A';
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it 'gets' information, implying a read-only operation, but doesn't clarify if it requires device connectivity, has side effects, or details the return format. This is inadequate for a tool with zero annotation coverage.

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 directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations, no output schema, and a simple parameter, the description is incomplete. It doesn't explain what battery information is returned (e.g., level, status, health), potential errors, or dependencies like device connection. For a tool in a complex ADB context, this leaves significant gaps.

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 description adds no parameter-specific information beyond what the input schema provides. With 100% schema description coverage (the deviceId parameter is documented as optional), the baseline is 3. The description doesn't compensate with additional context like when to use deviceId or what happens if omitted.

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 action ('Get') and resource ('battery information from the device'), making the tool's purpose immediately understandable. It doesn't explicitly differentiate from siblings like adb_get_device_info or adb_get_system_info, which might also provide battery-related data, so it doesn't reach the highest 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 provides no guidance on when to use this tool versus alternatives. With siblings like adb_get_device_info that might include battery info, there's no indication of when this specific tool is preferred or necessary, leaving the agent to guess based on tool names alone.

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/richard0913/adb-mcp'

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