Skip to main content
Glama

adb_devices

Lists connected Android devices using ADB commands, enabling device management and interaction for tasks like app installation, file transfer, and shell execution via the ADB MCP Server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
random_stringNo

Implementation Reference

  • Inline handler function for the adb_devices tool. Logs the action and executes 'adb devices' via the executeAdbCommand helper, returning the list of connected devices.
    async (_args: Record<string, never>, _extra: RequestHandlerExtra) => { log(LogLevel.INFO, "Listing connected devices"); return executeAdbCommand(["devices"], "Error executing adb devices"); },
  • src/index.ts:410-418 (registration)
    MCP server.tool registration for 'adb_devices', specifying name, input schema shape, inline handler function, and tool description.
    server.tool( "adb_devices", AdbDevicesSchema.shape, async (_args: Record<string, never>, _extra: RequestHandlerExtra) => { log(LogLevel.INFO, "Listing connected devices"); return executeAdbCommand(["devices"], "Error executing adb devices"); }, { description: ADB_DEVICES_TOOL_DESCRIPTION } );
  • Input schema object literal for adb_devices tool (effectively accepts no required parameters).
    export const adbDevicesInputSchema = { random_string: z.string().optional() };
  • Zod schema definition AdbDevicesSchema created from adbDevicesInputSchema, used in tool registration.
    export const AdbDevicesSchema = z.object(adbDevicesInputSchema);
  • Helper function that executes ADB commands, handles stdout/stderr/output formatting, error conditions, and returns standardized MCP response. Called by adb_devices handler with ['devices'].
    async function executeAdbCommand(args: string[], errorMessage: string) { const commandString = ["adb", ...args].join(" "); try { log(LogLevel.DEBUG, `Executing command: ${commandString}`); const { stdout, stderr } = await runAdb(args); const stderrText = stderr.trim(); // Some ADB commands output to stderr but are not errors if (stderrText && !stdout.includes("List of devices attached") && !stdout.includes("Success")) { const nonErrorWarnings = [ "Warning: Activity not started, its current task has been brought to the front", "Warning: Activity not started, intent has been delivered to currently running top-most instance." ]; if (nonErrorWarnings.some((warning) => stderrText.includes(warning))) { log(LogLevel.WARN, `Command warning (not error): ${stderrText}`); return { content: [{ type: "text" as const, text: stderrText.replace(/^Error: /, "") // Remove any 'Error: ' prefix if present }] // Do NOT set isError }; } log(LogLevel.ERROR, `Command error: ${stderrText}`); return { content: [{ type: "text" as const, text: `Error: ${stderrText}` }], isError: true }; } log(LogLevel.DEBUG, `Command successful: ${commandString}`); const commandSummary = args[0] ? `${args[0]}` : commandString; log(LogLevel.INFO, `ADB command executed successfully: ${commandSummary}`); return { content: [{ type: "text" as const, text: stdout || "Command executed successfully" }] }; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); log(LogLevel.ERROR, `${errorMessage}: ${errorMsg}`); return { content: [{ type: "text" as const, text: `${errorMessage}: ${errorMsg}` }], isError: true }; } }

Other Tools

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

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