attach_to_process
Attach to a running process by its ID to enable dynamic instrumentation and runtime analysis using Frida's capabilities for mobile and desktop applications.
Instructions
Attach to a process by ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | No | Optional ID of the device where the process is running. Uses smart selection when omitted. | |
| pid | Yes | The ID of the process to attach to. |
Implementation Reference
- src/frida_mcp/cli.py:341-359 (handler)The core handler function for the 'attach_to_process' MCP tool. It resolves the device, attaches Frida to the specified process PID, and returns success status or error.@mcp.tool() def attach_to_process( pid: int = Field(description="The ID of the process to attach to."), device_id: Optional[str] = Field( default=None, description="Optional ID of the device where the process is running. Uses smart selection when omitted.", ), ) -> dict: """Attach to a process by ID.""" try: device = _resolve_device_or_raise(device_id) device.attach(pid) return { "pid": pid, "success": True, "is_detached": False, # New session is not detached } except Exception as e: return {"success": False, "error": str(e)}