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));

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