Skip to main content
Glama
cbxss
by cbxss

get_pid

Retrieve the process ID (PID) of a running Android app by its package name, enabling Frida attachment for dynamic analysis.

Instructions

Get PID of a running app by package name. Useful before attaching with connect().

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
packageYesApp package name (e.g., 'com.spotify.music')
device_idNoDevice ID (optional)

Implementation Reference

  • The actual implementation of get_pid. Uses adb_shell('pidof', package) to get the PID of a running Android app. Returns a dict with package name and pid (or None if not running).
    def get_pid(package: str, device_id: str | None = None) -> dict:
        """Get PID of running app by package name."""
        output = adb_shell(["pidof", package], device_id)
        if output:
            pid_str = output.split()[0]
            try:
                return {"package": package, "pid": int(pid_str)}
            except ValueError:
                return {"package": package, "pid": None, "error": f"Invalid PID: {pid_str}"}
        return {"package": package, "pid": None}
  • Tool registration/schema definition for get_pid. Defines name, description, and inputSchema with required 'package' and optional 'device_id' parameters.
    Tool(
        name="get_pid",
        description="Get PID of a running app by package name. Useful before attaching with connect().",
        inputSchema={
            "type": "object",
            "properties": {
                "package": {"type": "string", "description": "App package name (e.g., 'com.spotify.music')"},
                "device_id": {"type": "string", "description": "Device ID (optional)"},
            },
            "required": ["package"],
        },
    ),
  • Dispatch routing in call_tool() that maps the 'get_pid' tool name to adb.get_pid() with arguments extracted from the request.
    elif name == "get_pid":
        return adb.get_pid(arguments["package"], arguments.get("device_id"))
Behavior3/5

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

No annotations are provided, so the description carries full burden. It states the basic function but does not disclose behaviors like error handling (e.g., app not running) or permission requirements.

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

Conciseness5/5

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

Two sentences, front-loaded with the action, no wasted words. Efficient and well-structured.

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

Completeness3/5

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

With no output schema, the description should hint at the return value (e.g., integer PID). It also does not mention the optional device_id parameter's purpose. However, for a simple tool, it covers essential context.

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 the schema already documents both parameters. The description adds no additional meaning beyond what the schema provides.

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?

The description clearly states the verb 'Get PID' and the resource 'running app by package name'. It distinguishes from sibling tools by specifying its use as a prerequisite for connect().

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?

It explicitly mentions when to use the tool ('before attaching with connect()'), providing clear context. However, it does not specify when not to use it or mention alternatives.

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

Install Server

Other Tools

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/cbxss/frida-mcp'

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