Skip to main content
Glama
rahulkr
by rahulkr

read_file

Retrieve text file contents from Android devices to access logs, configuration files, or application data for debugging and analysis.

Instructions

Read a text file from the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
remote_pathYes
device_serialNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the MCP tool 'read_file'. Decorated with @mcp.tool() which registers the tool and automatically generates input/output schema from type hints. Executes 'adb shell cat' on the remote_path to read the file content.
    @mcp.tool()
    def read_file(remote_path: str, device_serial: str | None = None) -> str:
        """Read a text file from the device"""
        return run_adb(["shell", "cat", remote_path], device_serial)
  • Supporting utility function that runs ADB commands with optional device serial and timeout handling. Called by read_file to execute the 'adb shell cat' command.
    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)}"
  • Creation of the FastMCP server instance to which all tools including 'read_file' are registered via decorators.
    mcp = FastMCP("adb-dev-server")
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 mentions reading a text file but doesn't specify error handling (e.g., if the file doesn't exist), permissions required, or output format details. This leaves significant gaps for an agent to understand how the tool behaves in practice.

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, direct sentence with no wasted words, making it easy to parse quickly. It's front-loaded with the core action and resource, which is ideal for conciseness in tool descriptions.

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 should cover return values), the description's minimalism is somewhat acceptable. However, for a tool with 2 parameters (one required) and no annotations, it lacks details on error cases, device targeting, or file constraints, leaving the agent with incomplete operational context.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It doesn't explain what 'remote_path' or 'device_serial' mean, their expected formats, or how they interact. This lack of semantic context makes parameter usage unclear beyond the basic schema.

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 ('Read') and resource ('a text file from the device'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_files' or 'pull_file', which also involve file operations, so it doesn't achieve full sibling distinction.

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 like 'list_files' or 'pull_file', nor does it mention prerequisites such as device connectivity or file existence. It simply states what it does without contextual usage advice.

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