Skip to main content
Glama

adb_push

Push files from your computer to an Android device using ADB commands. Specify the file content and destination path to transfer files to the device.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileBase64YesBase64 encoded file content to push
remotePathYesRemote file path on the device
deviceNoSpecific device ID (optional)

Implementation Reference

  • The core handler function for the 'adb_push' tool. It decodes the base64-encoded file input, writes it to a temporary local file, executes the 'adb push' command to transfer it to the specified remote path on the device (optionally targeting a specific device), handles the result or errors, and cleans up the temporary file.
    async (args: z.infer<typeof AdbPushSchema>, _extra: RequestHandlerExtra) => { log(LogLevel.INFO, `Pushing file to device: ${args.remotePath}`); const deviceArgs = buildDeviceArgs(args.device); const tempFilePath = createTempFilePath("adb-mcp", basename(args.remotePath)); try { // Decode the base64 file data and write to temporary file const fileData = Buffer.from(args.fileBase64, 'base64'); await writeFilePromise(tempFilePath, fileData); // Push the temporary file to the device const remotePath = args.remotePath.trim(); if (!remotePath) { throw new Error("Remote path must not be empty"); } const result = await executeAdbCommand([...deviceArgs, "push", tempFilePath, remotePath], "Error pushing file"); if (!result.isError) { log(LogLevel.INFO, `File pushed to device successfully: ${remotePath}`); } return result; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); log(LogLevel.ERROR, `Error pushing file: ${errorMsg}`); return { content: [{ type: "text" as const, text: `Error pushing file: ${errorMsg}` }], isError: true }; } finally { // Clean up the temporary file await cleanupTempFile(tempFilePath); } },
  • Zod schema fields defining the input parameters for the adb_push tool: base64 file content, destination path on device, and optional device ID.
    export const adbPushInputSchema = { fileBase64: z.string().describe("Base64 encoded file content to push"), remotePath: z.string().describe("Remote file path on the device"), device: z.string().optional().describe("Specific device ID (optional)") };
  • Zod schema object construction for adb_push tool input validation using the defined input fields.
    export const AdbPushSchema = z.object(adbPushInputSchema);
  • src/index.ts:624-662 (registration)
    Registration of the 'adb_push' tool with the MCP server, specifying the tool name, input schema shape, inline handler function, and tool description.
    server.tool( "adb_push", AdbPushSchema.shape, async (args: z.infer<typeof AdbPushSchema>, _extra: RequestHandlerExtra) => { log(LogLevel.INFO, `Pushing file to device: ${args.remotePath}`); const deviceArgs = buildDeviceArgs(args.device); const tempFilePath = createTempFilePath("adb-mcp", basename(args.remotePath)); try { // Decode the base64 file data and write to temporary file const fileData = Buffer.from(args.fileBase64, 'base64'); await writeFilePromise(tempFilePath, fileData); // Push the temporary file to the device const remotePath = args.remotePath.trim(); if (!remotePath) { throw new Error("Remote path must not be empty"); } const result = await executeAdbCommand([...deviceArgs, "push", tempFilePath, remotePath], "Error pushing file"); if (!result.isError) { log(LogLevel.INFO, `File pushed to device successfully: ${remotePath}`); } return result; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); log(LogLevel.ERROR, `Error pushing file: ${errorMsg}`); return { content: [{ type: "text" as const, text: `Error pushing file: ${errorMsg}` }], isError: true }; } finally { // Clean up the temporary file await cleanupTempFile(tempFilePath); } }, { description: ADB_PUSH_TOOL_DESCRIPTION }
  • Detailed description string for the adb_push tool, used during registration to inform clients about its purpose and usage.
    * Tool description for adb-push */ const ADB_PUSH_TOOL_DESCRIPTION = "Transfers a file from the server to a connected Android device. " + "Useful for uploading test data, configuration files, media content, or any file needed on the device. " + "The file must be provided as base64-encoded content. " + "Requires specifying the full destination path on the device where the file should be placed. " + "Use this when setting up test environments, restoring backups, or modifying device files.";

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