Skip to main content
Glama

adb_push

Transfer base64-encoded files from a system to a specified path on Android devices using ADB commands, with optional device ID targeting for precise operations.

Input Schema

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

Implementation Reference

  • The handler function that executes the adb_push tool: decodes base64 file content to a temporary file, pushes it to the device using adb push, handles success/error, and cleans up.
    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 input schema defining parameters for adb_push: fileBase64 (required), remotePath (required), device (optional).
    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)") };
  • Main schema for adb_push tool created by wrapping adbPushInputSchema with z.object().
    export const AdbPushSchema = z.object(adbPushInputSchema);
  • src/index.ts:624-663 (registration)
    Registers the adb_push tool on the MCP server with server.tool(), using the tool name, AdbPushSchema.shape for input validation, the handler function, and ADB_PUSH_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 } );

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