Skip to main content
Glama

list_files

Browse files and directories on an Android device to view names, types, sizes, and permissions at any specified path.

Instructions

List files and directories at a given path on the Android device. Returns file names, types, sizes, and permissions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path on the Android device (e.g. /sdcard/Download)
device_idNoDevice serial number

Implementation Reference

  • The actual handler function that executes 'ls -la' via ADB and parses the output into a FileEntry array.
    export async function listFiles(remotePath: string, deviceId?: string): Promise<FileEntry[]> {
      const resolved = await deviceManager.resolveDeviceId(deviceId);
      const validPath = validateDevicePath(remotePath);
    
      const result = await adbShell(['ls', '-la', validPath], resolved);
    
      const entries: FileEntry[] = [];
      const lines = result.stdout.split('\n').filter(l => l.trim());
    
      for (const line of lines) {
        // Skip the 'total' line
        if (line.startsWith('total ')) continue;
    
        // Parse ls -la output: drwxr-xr-x 2 root root 4096 2024-01-01 00:00 dirname
        const match = line.match(
          /^([a-z\-ldrwxsSt@+]+)\s+\d+\s+\S+\s+\S+\s+(\d+)\s+(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2})\s+(.+)$/
        );
    
        if (match) {
          const [, permissions, sizeStr, date, time, name] = match;
    
          let type: FileEntry['type'] = 'unknown';
          if (permissions.startsWith('d')) type = 'directory';
          else if (permissions.startsWith('l')) type = 'symlink';
          else if (permissions.startsWith('-')) type = 'file';
    
          entries.push({
            name: name.trim(),
            type,
            permissions,
            size: parseInt(sizeStr, 10),
            date,
            time,
          });
        }
      }
    
      log.info(`Listed ${entries.length} files`, { remotePath: validPath, deviceId: resolved });
      return entries;
    }
  • The MCP tool registration for 'list_files', which defines its schema and connects the tool to the listFiles implementation.
    server.registerTool(
      'list_files',
      {
        description: 'List files and directories at a given path on the Android device. Returns file names, types, sizes, and permissions.',
        inputSchema: {
          path: z.string().describe('Absolute path on the Android device (e.g. /sdcard/Download)'),
          device_id: z.string().optional().describe('Device serial number'),
        },
      },
      async ({ path, device_id }) => {
        return await metrics.measure('list_files', device_id || 'default', async () => {
          const files = await listFiles(path, device_id);
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({ success: true, path, count: files.length, files }, null, 2),
            }],
          };
        });
      }
    );
Behavior3/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. It partially compensates by disclosing return values ('Returns file names, types, sizes, and permissions'), which is critical given the lack of output schema. However, it omits safety characteristics (read-only vs destructive), error handling for invalid paths, and whether hidden files are included.

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 consists of two efficient sentences with zero waste. The first sentence front-loads the action and target, while the second sentence addresses the return value. Every word earns its place.

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

Completeness4/5

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

For a simple two-parameter listing tool without output schema, the description is reasonably complete. It compensates for the missing output schema by detailing the return structure. It could be improved by mentioning error cases (e.g., permission denied, path not found) given the lack of annotations.

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?

With 100% schema description coverage, the schema already fully documents both parameters (path with example, device_id as serial number). The description references 'given path' and 'Android device' but adds no semantic meaning beyond what the schema already provides, warranting the baseline score.

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

Purpose5/5

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

The description clearly states the specific verb (List) and resource (files and directories) with scope (at a given path on the Android device). It effectively distinguishes from siblings like pull_file (which retrieves content) and list_apps (which lists applications rather than filesystem entries).

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 does not mention that this is for browsing directories before using pull_file, or caution against using it for listing installed applications (which requires list_apps).

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/divineDev-dotcom/android_mcp'

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