open_app
Launch Android applications by specifying their package name, enabling automated app testing and device control through ADB commands.
Instructions
Open an app using its package name and activity
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| package_name | Yes | Full package name of the app (e.g., com.example.app) |
Implementation Reference
- src/tools/handlers.ts:79-95 (handler)The main handler function for the 'open_app' tool. It extracts the package_name from args, runs 'adb shell monkey -p {package_name} 1' to launch the app, sleeps for 5 seconds, and returns a text confirmation.open_app: async (args: any) => { const { package_name } = args as { package_name: string; }; await executeCommand(`adb shell monkey -p ${package_name} 1`); await sleep(5000); return { content: [ { type: 'text', text: `App opened: ${package_name}`, }, ], }; },
- src/tools/definitions.ts:30-43 (schema)The schema definition for the 'open_app' tool, specifying the input schema that requires a 'package_name' string.{ name: 'open_app', description: 'Open an app using its package name and activity', inputSchema: { type: 'object', properties: { package_name: { type: 'string', description: 'Full package name of the app (e.g., com.example.app)', }, }, required: ['package_name'], }, },
- src/index.ts:26-30 (registration)Registration of tool list handler, which returns all tool definitions including 'open_app' schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions, }; });
- src/index.ts:32-46 (registration)Registration of tool call handler, which dispatches to the specific tool handler like 'open_app' based on name.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}`); } });