adb-logcat
Read Android device logs to debug applications, filter by package, level, or time, and retrieve log summaries for analysis.
Instructions
Read device logs. Returns summary with logId.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lines | No | Default: 100 | |
| package | No | ||
| tags | No | ||
| level | No | ||
| rawFilter | No | ||
| since | No | e.g., '01-20 15:30:00.000' |
Implementation Reference
- src/tools/adb-logcat.ts:35-68 (handler)The core handler function for the adb-logcat tool.
export async function handleAdbLogcatTool( input: AdbLogcatInput, context: ServerContext ): Promise<Record<string, unknown>> { const device = await context.deviceState.ensureDevice(context.adb); const deviceId = device.id; const filter = buildLogcatFilter(input); const output = await context.adb.logcat(deviceId, { lines: input.lines, filter, since: input.since, package: input.package, }); const logId = context.cache.generateId("logcat"); context.cache.set(logId, { output, deviceId, filter }, "logcat", CACHE_TTLS.LOGCAT); const lines = output.split("\n").filter(Boolean); const errorCount = lines.filter((l) => l.includes(" E ")).length; const warnCount = lines.filter((l) => l.includes(" W ")).length; return { logId, summary: { lineCount: lines.length, errorCount, warnCount, }, preview: lines.slice(0, 20).join("\n"), deviceId, }; } - src/tools/adb-logcat.ts:5-12 (schema)The input schema for the adb-logcat tool.
export const adbLogcatInputSchema = z.object({ lines: z.number().optional().default(100), package: z.string().optional(), tags: z.array(z.string()).optional(), level: z.enum(["verbose", "debug", "info", "warn", "error"]).optional(), rawFilter: z.string().optional(), since: z.string().optional(), }); - src/tools/adb-logcat.ts:70-90 (registration)The tool definition (registration metadata) for adb-logcat.
export const adbLogcatToolDefinition = { name: "adb-logcat", description: "Read device logs. Returns summary with logId.", inputSchema: { type: "object", properties: { lines: { type: "number", description: "Default: 100" }, package: { type: "string" }, tags: { type: "array", items: { type: "string" } }, level: { type: "string", enum: ["verbose", "debug", "info", "warn", "error"] }, rawFilter: { type: "string" }, since: { type: "string", description: "e.g., '01-20 15:30:00.000'" }, }, }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, };