create_interactive_session
Attach to a running process to establish an interactive REPL session for executing commands and scripts, enabling dynamic instrumentation and runtime analysis.
Instructions
Create an interactive REPL-like session with a process.
This returns a session ID that can be used with execute_in_session to run commands.
Returns:
Information about the created session
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. | |
| process_id | Yes | The ID of the process to attach to for creating an interactive session. |
Implementation Reference
- src/frida_mcp/cli.py:459-498 (handler)The core handler function for the 'create_interactive_session' MCP tool. Decorated with @mcp.tool(), it handles process attachment via Frida, session creation/storage, and returns a session ID for subsequent interactions.@mcp.tool() def create_interactive_session( process_id: int = Field( description="The ID of the process to attach to for creating an interactive session." ), device_id: Optional[str] = Field( default=None, description="Optional ID of the device where the process is running. Uses smart selection when omitted.", ), ) -> Dict[str, Any]: """Create an interactive REPL-like session with a process. This returns a session ID that can be used with execute_in_session to run commands. Returns: Information about the created session """ try: # Attach to process device = _resolve_device_or_raise(device_id) session = device.attach(process_id) # Generate a unique session ID session_id = f"session_{process_id}_{int(time.time())}" # Store the session _scripts[session_id] = session _script_messages[session_id] = [] _message_locks[session_id] = threading.Lock() return { "status": "success", "process_id": process_id, "session_id": session_id, "message": f"Interactive session created for process {process_id}. Use execute_in_session to run JavaScript commands.", } except Exception as e: return {"status": "error", "error": str(e)}