getBatteryInfo
Retrieve battery status and details for the current device, including charge level and power source, to monitor system power conditions.
Instructions
获取当前设备的电池信息
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "getBatteryInfo"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:633-640 (handler)The handler function for the 'getBatteryInfo' tool. It calls si.battery() from the systeminformation library to fetch battery details and returns the JSON-stringified result.
case "getBatteryInfo": { const batteryInfo = await si.battery(); return { content: [{ type: "text", text: JSON.stringify(batteryInfo, null, 2) }] }; - src/index.ts:191-198 (registration)Registration of the 'getBatteryInfo' tool in the tools list, including name, description, and input schema (empty object). This is returned by the list tools handler.
name: "getBatteryInfo", description: "获取当前设备的电池信息", inputSchema: { type: "object", properties: {}, required: [] } }, - src/index.ts:193-197 (schema)Input schema for 'getBatteryInfo' tool: an empty object with no required properties.
inputSchema: { type: "object", properties: {}, required: [] }