Skip to main content
Glama

android-shell

Execute shell commands on Android devices via the DroidMind MCP server. Specify device serial, command, and control output size. Ideal for device management, debugging, and system analysis.

Instructions

Run a shell command on the device.

Args: serial: Device serial number command: Shell command to run max_lines: Maximum lines of output to return (default: 1000) Use positive numbers for first N lines, negative for last N lines Set to None for unlimited (not recommended for large outputs) max_size: Maximum output size in characters (default: 100000) Limits total response size regardless of line count

Returns: Command output

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes
max_linesNo
max_sizeNo
serialYes

Implementation Reference

  • The async 'shell_command' function, decorated with @mcp.tool('android-shell'), implements the tool logic: connects to the device, assesses command risk, executes the shell command via device.run_shell, formats output with warnings and markdown, and handles errors.
    @mcp.tool("android-shell") async def shell_command( serial: str, command: str, ctx: Context, max_lines: int | None = 1000, max_size: int | None = 100000 ) -> str: """ Run a shell command on the device. Args: serial: Device serial number command: Shell command to run max_lines: Maximum lines of output to return (default: 1000) Use positive numbers for first N lines, negative for last N lines Set to None for unlimited (not recommended for large outputs) max_size: Maximum output size in characters (default: 100000) Limits total response size regardless of line count Returns: Command output """ device = await get_device_manager().get_device(serial) if device is None: return f"Error: Device {serial} not found." # Assess command risk level risk_level = assess_command_risk(command) # Add warning for high-risk commands warning = "" if risk_level in (RiskLevel.HIGH, RiskLevel.CRITICAL): warning = f"⚠️ WARNING: This command has been assessed as {risk_level.name} risk.\n\n" logger.warning("High risk command requested: %s (Risk: %s)", command, risk_level.name) try: result = await device.run_shell(command, max_lines, max_size) # If the result starts with "Error: Command rejected", it means security validation failed if result.startswith("Error: Command rejected"): return f"{warning}{result}" # Format the output to match the expected format in tests output = f"# Command Output from {serial}\n\n" if warning: output += f"{warning}\n\n" # Add the command output output += f"```\n{result}\n```" return output except Exception as e: logger.exception("Error executing shell command: %s", e) return f"Error executing shell command: {e!s}"

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/hyperb1iss/droidmind'

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