Skip to main content
Glama

adb_get_logcat

Retrieve logcat output from Android devices to monitor logs, filter by tags, and specify device ID or line count for targeted debugging and analysis.

Instructions

Get logcat output from the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceIdNoDevice ID (optional)
linesNoNumber of lines to retrieve (default: 100)
tagNoFilter by tag (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.
    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' }; } }
  • The tool schema definition including name, description, and input schema for parameters: lines (number, optional), tag (string, optional), deviceId (string, optional).
    { 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)
    The switch case registration that maps the tool call to ShellTools.getLogcat method, passing parsed arguments.
    case 'adb_get_logcat': return await this.handleToolCall(this.shellTools.getLogcat(args?.lines as number, args?.tag as string, args?.deviceId as string));

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