Skip to main content
Glama

adb_logcat

Capture and manage Android device logs using logcat. Specify filters, device IDs, and line counts to extract relevant debugging information for app development and troubleshooting.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deviceNoSpecific device ID (optional)
filterNoLogcat filter expression (optional)
linesNoNumber of lines to return (default: 50)

Implementation Reference

  • Full handler implementation and registration for the 'adb_logcat' tool. Executes 'adb logcat -d' on the specified device with optional filter expression (parsed into arguments) and limits the output to the last N lines (default 50). Handles errors and returns log text or error message.
    // Add adb logcat tool server.tool( "adb_logcat", AdbLogcatSchema.shape, async (args: z.infer<typeof AdbLogcatSchema>, _extra: RequestHandlerExtra) => { const lines = args.lines || 50; const filterExpr = args.filter ? args.filter : ""; log(LogLevel.INFO, `Reading logcat (${lines} lines, filter: ${filterExpr || 'none'})`); const deviceArgs = buildDeviceArgs(args.device); const filterArgs = filterExpr ? splitCommandArguments(filterExpr) : []; const adbArgs = [...deviceArgs, "logcat", "-d", ...filterArgs]; try { const { stdout, stderr } = await runAdb(adbArgs); if (stderr) { log(LogLevel.WARN, `logcat returned stderr: ${stderr}`); } const logLines = stdout.split(/\r?\n/); const limitedLines = lines > 0 ? logLines.slice(-lines) : logLines; const text = limitedLines.join("\n"); return { content: [{ type: "text" as const, text }] }; } catch (error) { const errorMsg = error instanceof Error ? error.message : String(error); log(LogLevel.ERROR, `Error reading logcat: ${errorMsg}`); return { content: [{ type: "text" as const, text: `Error reading logcat: ${errorMsg}` }], isError: true }; } }, { description: ADB_LOGCAT_TOOL_DESCRIPTION } );
  • Object literal defining the input parameters schema for adb_logcat tool using Zod descriptions.
    export const adbLogcatInputSchema = { filter: z.string().optional().describe("Logcat filter expression (optional)"), device: z.string().optional().describe("Specific device ID (optional)"), lines: z.number().optional().default(50).describe("Number of lines to return (default: 50)") };
  • Zod schema creation for adb_logcat tool by wrapping the input schema object.
    export const AdbLogcatSchema = z.object(adbLogcatInputSchema);
  • src/index.ts:113-120 (registration)
    Tool description constant used in the registration of the adb_logcat tool.
    * Tool description for adb-logcat */ const ADB_LOGCAT_TOOL_DESCRIPTION = "Retrieves Android system and application logs from a connected device. " + "Ideal for debugging app behavior, monitoring system events, and identifying errors. " + "Supports filtering by log tags or expressions to narrow down relevant information. " + "Results can be limited to a specific number of lines, making it useful for both brief checks and detailed analysis. " + "Use when troubleshooting crashes, unexpected behavior, or performance issues.";

Other Tools

Related 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/srmorete/adb-mcp'

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