Skip to main content
Glama

adb_list_files

List files in a directory on an Android device using ADB commands to view and manage device file systems.

Instructions

List files in a directory on the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
remotePathYesRemote directory path on device
deviceIdNoDevice ID (optional)

Implementation Reference

  • The listFiles method in the FileTools class that implements the tool logic: checks device connection, executes 'adb shell ls -la' command, parses the ls output into structured file information (permissions, size, date, name), and returns formatted result.
    async listFiles(remotePath: string, deviceId?: string) {
      try {
        const connected = await this.adbClient.isDeviceConnected(deviceId);
        if (!connected) {
          return {
            success: false,
            error: 'Device not connected',
            message: 'Cannot list files - device is not connected'
          };
        }
    
        const command = `shell ls -la "${remotePath}"`;
        const result = await this.adbClient.executeCommand(command, deviceId);
        
        if (!result.success) {
          return {
            success: false,
            error: result.error,
            message: 'Failed to list files'
          };
        }
    
        const files = result.output
          .split('\n')
          .slice(1) // Skip the first line (total)
          .map(line => {
            const parts = line.trim().split(/\s+/);
            if (parts.length >= 9) {
              return {
                permissions: parts[0],
                size: parts[4],
                date: `${parts[5]} ${parts[6]} ${parts[7]}`,
                name: parts.slice(8).join(' ')
              };
            }
            return null;
          })
          .filter(file => file !== null);
    
        return {
          success: true,
          data: { 
            path: remotePath,
            files,
            count: files.length,
            deviceId: deviceId || this.adbClient.getDefaultDevice()
          },
          message: `Listed ${files.length} files in ${remotePath}`
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
          message: 'Failed to list files'
        };
      }
    }
  • Defines the tool metadata including name, description, and input schema for 'adb_list_files' in the ListTools response.
    {
      name: 'adb_list_files',
      description: 'List files in a directory on the device',
      inputSchema: {
        type: 'object',
        properties: {
          remotePath: {
            type: 'string',
            description: 'Remote directory path on device',
          },
          deviceId: {
            type: 'string',
            description: 'Device ID (optional)',
          },
        },
        required: ['remotePath'],
      },
    },
  • src/index.ts:469-470 (registration)
    Registers the tool handler by dispatching 'adb_list_files' calls to the FileTools.listFiles method in the CallToolRequest switch statement.
    case 'adb_list_files':
      return await this.handleToolCall(this.fileTools.listFiles(args?.remotePath as string, args?.deviceId as string));
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action but lacks details on permissions needed, error handling (e.g., invalid paths), output format (e.g., list structure), or side effects. This is inadequate for a tool with potential device access implications.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it highly efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like permissions, error cases, or return format, which are critical for a tool interacting with a device. The schema handles parameters well, but overall context is insufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, fully documenting both parameters ('remotePath' and 'deviceId'). The description doesn't add any meaning beyond the schema, such as path format examples or default device behavior, but the schema provides sufficient baseline information.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('files in a directory on the device'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'adb_list_apps' or 'adb_list_devices', which also list resources but different types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'adb_shell' that might offer similar functionality, nor does it specify prerequisites such as device connectivity or permissions required for listing files.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/richard0913/adb-mcp'

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