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.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the return value (session ID and session information) and hints at a workflow with 'execute_in_session', it lacks critical details such as whether this operation requires specific permissions, what happens if the process is already in a session, or any rate limits. The description doesn't contradict annotations (none exist), but it's insufficient for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with three sentences: the first states the purpose, the second explains the return value usage, and the third clarifies the return content. It's front-loaded with the core action, and each sentence adds value without redundancy. Minor improvements could include integrating the return details more seamlessly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which covers return values) and 100% schema description coverage for inputs, the description doesn't need to detail parameters or return values. However, as a mutation tool with no annotations, it should provide more behavioral context (e.g., side effects, permissions). The description is adequate but leaves gaps in usage and transparency.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional meaning about the parameters beyond what the schema provides (e.g., it doesn't explain 'process_id' or 'device_id' further). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('create an interactive REPL-like session') and resource ('with a process'), making the purpose immediately understandable. It distinguishes from some siblings like 'attach_to_process' or 'spawn_process' by focusing on session creation rather than process attachment or spawning. However, it doesn't explicitly differentiate from all possible alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning the returned session ID can be used with 'execute_in_session', suggesting a workflow. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'attach_to_process' or 'spawn_process', nor does it mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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