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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/categories/system.ts:103-113 (handler)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 `, },
- src/framework.ts:221-232 (registration)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);
- src/framework.ts:280-294 (handler)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, }, ], };