get_device
Retrieve detailed information about a specific mobile or desktop device by its unique ID using Frida MCP server. This tool enables device identification and status checking for dynamic instrumentation and runtime analysis workflows.
Instructions
Get a device by its ID.
Returns:
Information about the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_id | Yes | The ID of the device to get |
Implementation Reference
- src/frida_mcp/cli.py:270-285 (handler)The primary MCP tool handler for 'get_device'. Registers the tool via @mcp.tool(), defines input schema via Pydantic Field, and executes logic by resolving the device and returning its details.@mcp.tool() def get_device( device_id: str = Field(description="The ID of the device to get"), ) -> Dict[str, Any]: """Get a device by its ID. Returns: Information about the device """ device = _resolve_device_or_raise(device_id) return { "id": device.id, "name": device.name, "type": device.type, }
- src/frida_mcp/cli.py:176-204 (helper)Helper function called by the get_device tool handler to resolve the device ID using device_selection.resolve_device and raise user-friendly ValueError on failure.def _resolve_device_or_raise(device_id: Optional[str] = None) -> Any: """Resolve a Frida device using the smart selector and convert errors.""" try: logger.debug("Resolving device for id=%s", device_id or "<default>") device = resolve_device(device_id) logger.debug( "Resolved device id=%s -> %s (%s)", device_id or "<default>", getattr(device, "id", "<unknown>"), getattr(device, "type", "<unknown>"), ) return device except DeviceSelectionError as exc: if exc.reasons: attempts = "; ".join(exc.reasons) logger.error( "Device resolution failed for id=%s: %s (attempts: %s)", device_id or "<default>", exc, attempts, ) raise ValueError(f"{exc}. Attempts: {attempts}") from exc logger.error( "Device resolution failed for id=%s: %s", device_id or "<default>", exc, ) raise ValueError(str(exc)) from exc
- Public helper function that initializes the DeviceSelector if needed and delegates to its get_device method.def resolve_device(device_id: Optional[str] = None) -> Any: global _selector if _selector is None: _selector = DeviceSelector() try: return _selector.get_device(device_id) except DeviceSelectionError: # re-raise so callers can handle uniformly raise
- Core implementation logic in DeviceSelector class for resolving device_id to a Frida device object, using explicit ID, config defaults, or auto-selection fallbacks.def get_device(self, device_id: Optional[str] = None) -> Any: identifier = (device_id or "").strip() if identifier: return self._get_by_identifier(identifier) default_choice = (self._config.default_device or "").strip() if default_choice and default_choice.lower() not in {"auto", "smart"}: return self._get_by_identifier(default_choice) return self._auto_select()