Skip to main content
Glama
rahulkr
by rahulkr

list_files

Retrieve file listings from Android device directories to manage storage, locate files, and verify content during development and testing workflows.

Instructions

List files in a directory on the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
remote_pathNo/sdcard/
device_serialNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The list_files tool handler function. Decorated with @mcp.tool() for automatic registration in FastMCP. Executes 'adb shell ls -la' on the specified remote path to list files and directories with details.
    @mcp.tool()
    def list_files(remote_path: str = "/sdcard/", device_serial: str | None = None) -> str:
        """List files in a directory on the device"""
        return run_adb(["shell", "ls", "-la", remote_path], device_serial)
  • Utility function used by list_files (and other tools) to run ADB commands safely, handling device serial, timeouts, and errors.
    def run_adb(args: list[str], device_serial: str | None = None, timeout: int = 30) -> str:
        """Run an ADB command and return output"""
        cmd = ["adb"]
        if device_serial:
            cmd.extend(["-s", device_serial])
        cmd.extend(args)
        
        try:
            result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
            if result.returncode != 0 and result.stderr:
                return f"Error: {result.stderr}"
            return result.stdout
        except subprocess.TimeoutExpired:
            return "Error: Command timed out"
        except Exception as e:
            return f"Error: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It states what the tool does but doesn't disclose important traits like whether it requires device permissions, what format the output takes, if it's paginated, or potential error conditions. 'List files' implies a read operation, but no safety or performance characteristics are described.

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 zero wasted words. It's front-loaded with the core purpose and efficiently communicates the essential action without unnecessary elaboration.

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

Completeness3/5

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

Given that there's an output schema (which handles return values), no annotations, and only 2 parameters, the description is minimally complete. It states the basic purpose but lacks context about device state requirements, error handling, or output structure beyond what the output schema will provide. For a simple read operation, this is adequate but not thorough.

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?

Schema description coverage is 0%, so the schema provides no parameter descriptions. The tool description mentions 'in a directory' which hints at the 'remote_path' parameter's purpose, but doesn't explain 'device_serial' or provide any format details. Since there are only 2 parameters and the description gives some context for one, it meets the baseline but doesn't fully compensate for the schema gap.

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 action ('List files') and target resource ('in a directory on the device'), making the purpose immediately understandable. However, it doesn't differentiate from potential siblings like 'list_devices' or 'list_packages' that also list things, though those are clearly different resources.

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 prerequisites like device connectivity, nor does it compare with other file-related tools like 'read_file' or 'pull_file' that might be used in similar contexts.

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/rahulkr/r_adb_mcp_server'

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