Package-level declarations

Types

Link copied to clipboard
object AppsTools

Provider for the app tools (ListInstalledAppsTool, GetAppInfoTool, LaunchAppTool, GetAppUsageTool). Results may be subject to API 30+ package-visibility rules. GetAppUsageTool needs Usage access, a special access granted in Settings (check it with io.droidmcp.core.support.UsageAccess.isGranted); without it that tool returns an error and the others still work, so requiredPermissions stays empty.

Link copied to clipboard
class GetAppInfoTool(context: Context) : McpTool

Returns details for one installed app identified by package_name. No permissions; the module's manifest declares a <queries> element for MAIN/LAUNCHER intents so API 30+ package-visibility filtering doesn't hide launchable apps — a package with no launcher activity (background-only) is still invisible (reported as "App not found"). Output: app_name, package_name, version_name, version_code, install_date, last_update, and permissions (the app's requested permissions).

Link copied to clipboard
class GetAppUsageTool(context: Context) : McpTool

Per-app screen time from UsageStatsManager.queryEvents, computed by ScreenTime from activity resume/pause/stop, screen-off and shutdown/boot events (more accurate than the daily-bucketed queryUsageStats, whose buckets don't start at local midnight). Events are read from LOOKBACK_MS before the window so an app already open at its start is counted. The default home-screen launcher is left out. Needs Usage access (UsageAccess); without it the tool returns an error, since queryEvents would silently return nothing. Params: days (1-7, default 1 = since local midnight today; Android keeps only a few days of events), limit (1-100, default 10), package_name filter. Output: the window (start, end), total_seconds, and apps most-used first with foreground_seconds and last_used (yyyy-MM-dd HH:mm, device timezone). app_label is null for apps hidden by package visibility (no launcher activity).

Link copied to clipboard
class LaunchAppTool(context: Context) : McpTool

Launches an installed app via its main launch intent (FLAG_ACTIVITY_NEW_TASK), identified by package_name. Errors if the app is not found or exposes no launcher activity. No permissions; the module's manifest declares a <queries> element for MAIN/LAUNCHER intents so API 30+ package-visibility filtering doesn't hide launchable targets (a package with no launcher activity — background-only — is still invisible). On API 29+ the host must be in the foreground (or hold SYSTEM_ALERT_WINDOW), otherwise the system silently blocks the launch; the tool detects this up front and returns an error. Output: success (true) and package_name.

Link copied to clipboard

Lists installed applications, sorted by display label, optionally including system apps (include_system param, default false). No permissions; the module's manifest declares a <queries> element for MAIN/LAUNCHER intents so API 30+ package-visibility filtering doesn't reduce this to a handful of force-visible packages — apps with no launcher activity (background-only) are still excluded by design. Output: apps (each {app_name, package_name, version, is_system_app}) capped at the limit param, plus count and include_system.