Skip to main content
Glama

android-mcp-toolkit

clear-logcat-buffer

Clear Android logcat buffers to prepare for new debugging scenarios by running adb logcat -c command.

Instructions

Run adb logcat -c to clear buffers before a new scenario.

Input Schema

NameRequiredDescriptionDefault
timeoutMsNoTimeout per adb call in milliseconds

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "properties": { "timeoutMs": { "default": 5000, "description": "Timeout per adb call in milliseconds", "maximum": 15000, "minimum": 1000, "type": "integer" } }, "type": "object" }

Implementation Reference

  • The inline async handler function for the 'clear-logcat-buffer' tool. It executes 'adb logcat -c' using the runAdbCommand helper with the provided timeout and returns a success message.
    async params => { await runAdbCommand(['logcat', '-c'], params.timeoutMs); return { content: [{ type: 'text', text: 'Cleared logcat buffers.' }] }; }
  • Zod input schema definition for the 'clear-logcat-buffer' tool, specifying an optional timeoutMs parameter (default 5000ms).
    const clearLogcatInputSchema = z.object({ timeoutMs: z .number() .int() .min(1000) .max(15000) .default(5000) .describe('Timeout per adb call in milliseconds') });
  • Registers the 'clear-logcat-buffer' MCP tool on the server using server.registerTool, providing name, metadata (title, description, schema), and handler function.
    server.registerTool( 'clear-logcat-buffer', { title: 'Clear logcat buffer', description: 'Run adb logcat -c to clear buffers before a new scenario.', inputSchema: clearLogcatInputSchema }, async params => { await runAdbCommand(['logcat', '-c'], params.timeoutMs); return { content: [{ type: 'text', text: 'Cleared logcat buffers.' }] }; } );
  • Helper function to run adb shell commands asynchronously with timeout, buffer limits, and comprehensive error handling including stderr capture. Used by the clear-logcat-buffer handler.
    async function runAdbCommand(args, timeoutMs) { try { const { stdout } = await execFileAsync('adb', args, { timeout: timeoutMs, maxBuffer: 5 * 1024 * 1024 }); return stdout.trimEnd(); } catch (error) { const stderr = error && typeof error.stderr === 'string' ? error.stderr.trim() : ''; const message = [`adb ${args.join(' ')} failed`, error.message].filter(Boolean).join(': '); if (stderr) { throw new Error(`${message} | stderr: ${stderr}`); } throw new Error(message); } }
  • src/index.js:21-21 (registration)
    Top-level call to registerLogcatTool(server) in the main MCP server setup, which invokes the registration of clear-logcat-buffer and other logcat-related tools.
    registerLogcatTool(server);

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/Nam0101/android-mcp-toolkit'

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