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
| Name | Required | Description | Default |
|---|---|---|---|
| package | Yes | App package name (e.g., 'com.spotify.music') | |
| device_id | No | Device ID (optional) |
Implementation Reference
- src/frida_mcp/adb.py:48-57 (handler)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} - src/frida_mcp/tools.py:73-84 (registration)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"], }, ), - src/frida_mcp/server.py:43-44 (registration)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"))