Skip to main content
Glama

ACTION_FOREGROUND_APP

Retrieves the foreground app's package name and activity class, falling back to shell dumpsys when accessibility is unavailable, and stores the result in workflow variables.

Instructions

获取前台应用包名/Activity(先无障碍,拿不到再走 shell dumpsys)(需无障碍或 Shizuku/root)。输出:foreground_package, foreground_success, foreground_activity, foreground_class。拿不到时写 unknown 且 foreground_success=false;foreground_class 为短类名。节点必须带 params(可为 {}),缺 params 字段时什么都不做。。字符串参数支持 ${var} 插值;结果以变量快照 JSON 返回。

Input Schema

NameRequiredDescriptionDefault
requireNo执行后要求为 true 的变量名(如 click_success),不满足按出错处理
on_errorNo节点出错时:skip=跳过继续(默认),stop=停止整个工作流
use_shellNotrue=跳过无障碍,直接用 shell(默认 false)
output_varNo包名另存到的变量名(默认 foreground_package)
activity_varNoActivity 类名另存到的变量名(默认 foreground_activity)
node_timeout_msNo单节点超时毫秒,0=不限;默认 30 分钟

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does disclose the permission prerequisites (accessibility or Shizuku/root), the fallback chain, the failure sentinel (unknown plus foreground_success=false), and the short-class-name format of foreground_class. It does not describe latency or whether the accessibility path consumes events, so it stops short of full disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the core purpose and output contract before the cross-cutting boilerplate about params, ${var} interpolation, and snapshot return. Slightly overpacked into one paragraph with a duplicated '。。' typo, but no substantive waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description correctly enumerates the returned variables and the failure-state values. Combined with the disclosed permission requirements and params requirement, an agent has enough to call it correctly; only latency and side effects are unstated.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so all six parameters including require, on_error, use_shell, and the two _var names are already documented in the schema. The description mainly restates defaults and adds the foreground_class short-name detail, which maps only indirectly to the activity_var parameter. Baseline 3 applies when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: '获取前台应用包名/Activity', and enumerates the exact output fields (foreground_package, foreground_success, foreground_activity, foreground_class). An agent can tell this reports the current foreground app rather than app metadata or launching apps.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives the acquisition strategy (accessibility first, shell dumpsys fallback), the prerequisite (accessibility or Shizuku/root), and points to the use_shell parameter to force the fallback. It does not explicitly say when to prefer sibling tools such as ACTION_GET_APP_INFO, but the operating context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.