Skip to main content
Glama

adb-shell

Execute Android Debug Bridge shell commands with built-in safety controls like timeouts and output limits to manage Android devices securely.

Instructions

Execute shell commands with safety guards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes
timeoutNoms, default: 30000, max: 120000
maxCharsNoTruncate output to N chars
summaryOnlyNoCompact preview only
previewCharsNoPreview length (default: 200)

Implementation Reference

  • The handleAdbShellTool function serves as the handler for the adb-shell tool, executing shell commands on an Android device via ADB and formatting/truncating the output based on provided input parameters.
    export async function handleAdbShellTool(
      input: AdbShellInput,
      context: ServerContext
    ): Promise<Record<string, unknown>> {
      const device = await context.deviceState.ensureDevice(context.adb);
      const deviceId = device.id;
    
      const ADB_SHELL_MAX_TIMEOUT = 120_000;
      const timeout = input.timeout ? Math.min(input.timeout, ADB_SHELL_MAX_TIMEOUT) : undefined;
      const result = await context.adb.shell(deviceId, input.command, timeout);
    
      if (input.summaryOnly) {
        const previewChars = input.previewChars ?? 200;
        return {
          exitCode: result.exitCode,
          deviceId,
          summarized: true,
          stdoutPreview: result.stdout.slice(0, previewChars),
          stderrPreview: result.stderr.slice(0, previewChars),
          originalStdoutChars: result.stdout.length,
          originalStderrChars: result.stderr.length,
        };
      }
    
      const maxChars = input.maxChars;
      const stdout = maxChars ? result.stdout.slice(0, maxChars) : result.stdout;
      const stderr = maxChars ? result.stderr.slice(0, maxChars) : result.stderr;
      const truncated = !!maxChars && (result.stdout.length > maxChars || result.stderr.length > maxChars);
    
      const response: Record<string, unknown> = {
        stdout,
        stderr,
        exitCode: result.exitCode,
        deviceId,
        truncated,
      };
    
      if (maxChars !== undefined) {
        response.originalStdoutChars = result.stdout.length;
        response.originalStderrChars = result.stderr.length;
      }
    
      return response;
    }
  • The Zod schema defining the input requirements and validation for the adb-shell tool.
    export const adbShellInputSchema = z.object({
      command: z.string(),
      timeout: z.number().optional(),
      maxChars: z.number().min(1).optional(),
      summaryOnly: z.boolean().optional(),
      previewChars: z.number().min(1).optional(),
    });
  • The MCP tool definition object for adb-shell, including metadata like name, description, and input schema.
    export const adbShellToolDefinition = {
      name: "adb-shell",
      description: "Execute shell commands with safety guards.",
      inputSchema: {
        type: "object",
        properties: {
          command: { type: "string" },
          timeout: { type: "number", description: "ms, default: 30000, max: 120000" },
          maxChars: { type: "number", description: "Truncate output to N chars" },
          summaryOnly: { type: "boolean", description: "Compact preview only" },
          previewChars: { type: "number", description: "Preview length (default: 200)" },
        },
        required: ["command"],
      },
      annotations: {
        readOnlyHint: false,
        destructiveHint: true,
        idempotentHint: false,
        openWorldHint: true,
      },
    };
Behavior2/5

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

With no annotations, the description must carry full behavioral disclosure. While it mentions 'safety guards,' it fails to explain what these are (likely referring to timeout/maxChars parameters), what happens when timeouts occur, output formatting, or execution scope (persistent vs temporary sessions).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely brief at 5 words. Efficiently front-loaded with the core verb, though 'with safety guards' consumes space without payoff since it remains unexplained. No redundancy or filler beyond that vague phrase.

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?

For a high-risk shell execution tool with 5 parameters, no output schema, and zero annotations, the description is dangerously thin. It omits critical context: return value structure, error handling behavior, character limit enforcement, and the specific nature of the 'safety' mechanisms mentioned.

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 coverage is 80% (4 of 5 parameters documented), establishing baseline 3. The description adds no parameter context, particularly for the required 'command' field which lacks schema description. No credit awarded for merely implying safety limits without connecting them to specific parameters.

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

Purpose3/5

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

The description states the core action ('Execute shell commands') but the 'safety guards' qualifier is undefined. Given sibling tools like adb-logcat and adb-app, it implies general shell access but doesn't explicitly differentiate when to use this versus adb-app for specific app operations.

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?

No guidance provided on when to prefer this over sibling tools (adb-app, adb-device) or when to avoid it. No mention of prerequisites like requiring an active device connection or risks of arbitrary command execution.

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/thecombatwombat/replicant-mcp'

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