Skip to main content
Glama

adb_shell

Execute shell commands on Android devices through the ADB MCP Server to automate device management, app operations, and system tasks remotely.

Instructions

Execute a shell command on the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesShell command to execute
deviceIdNoDevice ID (optional)

Implementation Reference

  • Main handler function for the 'adb_shell' tool. Performs device connection check, blocks dangerous commands, executes the shell command via ADB client, and formats the response.
    async executeShellCommand(command: string, deviceId?: string) {
      try {
        const connected = await this.adbClient.isDeviceConnected(deviceId);
        if (!connected) {
          return {
            success: false,
            error: 'Device not connected',
            message: 'Cannot execute shell command - device is not connected'
          };
        }
    
        // Basic security check - prevent potentially dangerous commands
        const dangerousCommands = [
          'rm -rf /',
          'format',
          'factory_reset',
          'reboot bootloader',
          'fastboot',
          'dd if='
        ];
    
        const lowerCommand = command.toLowerCase();
        for (const dangerous of dangerousCommands) {
          if (lowerCommand.includes(dangerous)) {
            return {
              success: false,
              error: 'Dangerous command blocked',
              message: `Command contains potentially dangerous operation: ${dangerous}`
            };
          }
        }
    
        const shellCommand = `shell ${command}`;
        const result = await this.adbClient.executeCommand(shellCommand, deviceId);
        
        return {
          success: result.success,
          data: { 
            command,
            output: result.output,
            error: result.error,
            deviceId: deviceId || this.adbClient.getDefaultDevice()
          },
          message: result.success ? 'Command executed successfully' : 'Command execution failed'
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
          message: 'Failed to execute shell command'
        };
      }
    }
  • Input schema definition for the 'adb_shell' tool, including parameters for command and optional deviceId.
      name: 'adb_shell',
      description: 'Execute a shell command on the device',
      inputSchema: {
        type: 'object',
        properties: {
          command: {
            type: 'string',
            description: 'Shell command to execute',
          },
          deviceId: {
            type: 'string',
            description: 'Device ID (optional)',
          },
        },
        required: ['command'],
      },
    },
  • src/index.ts:473-474 (registration)
    Registration of the 'adb_shell' tool handler in the switch statement for CallToolRequest, dispatching to ShellTools.executeShellCommand.
    case 'adb_shell':
      return await this.handleToolCall(this.shellTools.executeShellCommand(args?.command as string, args?.deviceId as string));
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but lacks critical details: it doesn't specify if this requires device connectivity, what permissions are needed, potential risks (e.g., destructive commands), or the format of output (e.g., text, error codes). This is inadequate for a tool that executes arbitrary shell commands.

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 zero wasted words. It is front-loaded and efficiently communicates the core function without unnecessary elaboration, making it easy to parse quickly.

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 complexity of executing shell commands (potentially destructive, variable outputs) and the lack of annotations and output schema, the description is incomplete. It fails to address safety, error handling, or result formatting, leaving significant gaps for an AI agent to use the tool effectively.

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 100%, with clear parameter descriptions in the schema. The description adds no additional meaning beyond implying execution of a shell command, which is already covered by the schema. This meets the baseline for high schema coverage without compensating value.

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 ('execute') and resource ('shell command on the device'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like adb_input_text or adb_get_system_info that also interact with devices, missing 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. It doesn't mention scenarios where adb_shell is preferred over specific sibling tools (e.g., adb_get_logcat for logs) or general usage contexts, leaving the agent to infer based on tool names alone.

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