Skip to main content
Glama

create_interactive_session

Attach to a running process to establish an interactive REPL session for executing commands and analyzing runtime behavior.

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
NameRequiredDescriptionDefault
process_idYesThe ID of the process to attach to for creating an interactive session.
device_idNoOptional ID of the device where the process is running. Uses smart selection when omitted.

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the create_interactive_session tool. It attaches to the specified process on the resolved device, creates a unique session_id, stores the session globally, and returns session details.
    @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)}
  • Global dictionaries used by create_interactive_session to store active sessions, messages, and locks for thread safety.
    # Global dictionary to store scripts and their messages # This allows us to retrieve messages from scripts after they've been created _scripts = {} _script_messages = {} _message_locks = {} global_persistent_scripts = {} # Added for managing persistent scripts
  • The @mcp.tool() decorator registers the create_interactive_session function as an MCP tool.
    @mcp.tool()

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

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