devices
List connected Android devices to identify targets for preference editing during app development.
Instructions
Lists connected Android devices
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": "devices"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/common.ts:13-32 (handler)The handler function for the 'devices' tool. It asynchronously lists connected Android devices using the imported listDevices function, maps each device's serial to a text content block, and handles errors by returning an error message.
server.tool("devices", "Lists connected Android devices", async () => { try { return { content: (await listDevices()).map((device) => ({ type: "text", text: device.serial, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } }); - src/tools/common.ts:13-32 (registration)The 'devices' tool is registered here within the configureCommonTools function using server.tool(). This registration includes the description and the inline handler.
server.tool("devices", "Lists connected Android devices", async () => { try { return { content: (await listDevices()).map((device) => ({ type: "text", text: device.serial, })), }; } catch (error) { return { isError: true, content: [ { type: "text", text: error instanceof Error ? error.message : "Unknown error", }, ], }; } }); - src/schema.ts:3-5 (schema)DeviceSchema defines the input structure for tools that interact with a specific Android device, using deviceId (serial number), which is relevant to the 'devices' tool that lists such serials.
export const DeviceSchema = z.object({ deviceId: z.string().describe("The device's serial number."), }); - src/index.ts:21-22 (registration)configureCommonTools(server) is called here, which in turn registers the 'devices' tool.
configurePreferenceTools(server); configureCommonTools(server);