Skip to main content
Glama

adb_get_logcat

Retrieve Android device logcat output for debugging and monitoring system events, with options to filter by tag, specify device, and control line count.

Instructions

Get logcat output from the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
linesNoNumber of lines to retrieve (default: 100)
tagNoFilter by tag (optional)
deviceIdNoDevice ID (optional)

Implementation Reference

  • The handler function that executes the ADB logcat command, checks device connection, builds the logcat command with optional lines and tag filters, executes it via adbClient, and returns formatted log output or error.
    async getLogcat(lines: number = 100, tag?: string, deviceId?: string) {
      try {
        const connected = await this.adbClient.isDeviceConnected(deviceId);
        if (!connected) {
          return {
            success: false,
            error: 'Device not connected',
            message: 'Cannot get logcat - device is not connected'
          };
        }
    
        let command = `shell logcat -d -t ${lines}`;
        if (tag) {
          command += ` -s ${tag}`;
        }
    
        const result = await this.adbClient.executeCommand(command, deviceId);
        
        if (!result.success) {
          return {
            success: false,
            error: result.error,
            message: 'Failed to get logcat'
          };
        }
    
        return {
          success: true,
          data: {
            logs: result.output,
            lines,
            tag,
            deviceId: deviceId || this.adbClient.getDefaultDevice()
          },
          message: `Retrieved ${lines} logcat lines${tag ? ` for tag: ${tag}` : ''}`
        };
      } catch (error: any) {
        return {
          success: false,
          error: error.message,
          message: 'Failed to get logcat'
        };
      }
    }
  • Input schema definition for the adb_get_logcat tool, specifying optional parameters for lines, tag, and deviceId.
    inputSchema: {
      type: 'object',
      properties: {
        lines: {
          type: 'number',
          description: 'Number of lines to retrieve (default: 100)',
        },
        tag: {
          type: 'string',
          description: 'Filter by tag (optional)',
        },
        deviceId: {
          type: 'string',
          description: 'Device ID (optional)',
        },
      },
      required: [],
    },
  • src/index.ts:401-422 (registration)
    Registration of the adb_get_logcat tool in the tools list, including name, description, and input schema.
    {
      name: 'adb_get_logcat',
      description: 'Get logcat output from the device',
      inputSchema: {
        type: 'object',
        properties: {
          lines: {
            type: 'number',
            description: 'Number of lines to retrieve (default: 100)',
          },
          tag: {
            type: 'string',
            description: 'Filter by tag (optional)',
          },
          deviceId: {
            type: 'string',
            description: 'Device ID (optional)',
          },
        },
        required: [],
      },
    },
  • src/index.ts:479-480 (registration)
    Switch case that dispatches the adb_get_logcat tool call to the shellTools.getLogcat handler.
    case 'adb_get_logcat':
      return await this.handleToolCall(this.shellTools.getLogcat(args?.lines as number, args?.tag 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 what the tool does but lacks critical details: it doesn't specify if this is a read-only operation (implied but not explicit), whether it requires device permissions, how it handles errors, or the format/volume of the returned logcat output. For a tool that interacts with a device, this is a significant gap.

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, efficient sentence that directly states the tool's purpose without any fluff. It's appropriately sized for a simple retrieval tool and front-loads the essential information.

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 device interaction and the lack of annotations and output schema, the description is insufficient. It doesn't explain what logcat output is, the typical structure of the data returned, potential side effects, or error conditions. For a tool that could return large amounts of diagnostic data, more context is needed.

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?

The input schema has 100% description coverage, with clear documentation for all three parameters (lines, tag, deviceId). The description adds no additional parameter information beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

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 ('Get') and resource ('logcat output from the device'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like adb_get_device_info or adb_get_system_info, which also retrieve device information but for 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 (e.g., device connectivity), typical use cases (e.g., debugging), or how it differs from other adb_get_* tools that retrieve different types of device data.

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