list_apps
Search and list installed Android apps matching a specific name pattern using ADB commands, enabling efficient app management and testing workflows.
Instructions
List installed apps matching a name pattern
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_name | Yes | Name pattern to search for in app packages |
Implementation Reference
- src/tools/handlers.ts:65-77 (handler)The asynchronous handler function for the 'list_apps' tool. It extracts 'app_name' from args, runs an ADB command to list packages matching the pattern using 'pm list packages | findstr', and returns the result as text content or a no-match message.list_apps: async (args: any) => { const { app_name } = args as { app_name: string }; const result = await executeCommand(`adb shell pm list packages | findstr "${app_name}"`); return { content: [ { type: 'text', text: result || 'No apps found matching the pattern', }, ], }; },
- src/tools/definitions.ts:16-29 (schema)The schema definition for the 'list_apps' tool, including name, description, and inputSchema specifying the required 'app_name' string parameter.{ name: 'list_apps', description: 'List installed apps matching a name pattern', inputSchema: { type: 'object', properties: { app_name: { type: 'string', description: 'Name pattern to search for in app packages', }, }, required: ['app_name'], }, },
- src/index.ts:26-30 (registration)Registers the MCP 'listTools' request handler, which returns all tool definitions including the 'list_apps' schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions, }; });
- src/index.ts:32-46 (registration)Registers the MCP 'callTool' request handler, which dispatches tool execution to the corresponding handler in toolHandlers based on the tool name, enabling 'list_apps' execution.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const handler = toolHandlers[name as keyof typeof toolHandlers]; if (!handler) { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`); } return await handler(args); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError(ErrorCode.InternalError, `Tool execution failed: ${errorMessage}`); } });