Skip to main content
Glama
UserB1ank

interactive-process-mcp

by UserB1ank

resize_pty

Resize the terminal dimensions (rows and columns) of an active PTY session to adapt to display changes or window resizing requirements.

Instructions

Resize the PTY terminal dimensions for a session.

Only works in pty mode.

Args: session_id: The session ID. rows: New row count. cols: New column count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
rowsNo
colsNo

Implementation Reference

  • Core handler: The Session.resize_pty() method that performs the actual PTY resize via pexpect's setwinsize(). It validates mode is 'pty' and process is running, then sets dimensions.
    def resize_pty(self, rows: int, cols: int) -> None:
        if self.mode != "pty":
            raise RuntimeError("PTY resize only available in pty mode")
        if self.status != SessionStatus.RUNNING:
            raise RuntimeError("Process not running")
        self._process.setwinsize(rows, cols)
        self._rows = rows
        self._cols = cols
  • MCP tool definition with typed parameters (session_id: str, rows: int=24, cols: int=80) and docstring, registered via @mcp.tool() decorator.
    @mcp.tool()
    def resize_pty(
        session_id: str,
        rows: int = 24,
        cols: int = 80,
    ) -> dict:
        """Resize the PTY terminal dimensions for a session.
    
        Only works in pty mode.
    
        Args:
            session_id: The session ID.
            rows: New row count.
            cols: New column count.
        """
        session = _mgr.get(session_id)
        if not session:
            return {"error": f"Session '{session_id}' not found"}
        try:
            session.resize_pty(rows=rows, cols=cols)
            return {"success": True}
        except RuntimeError as e:
            return {"error": str(e)}
  • Alternative handler: The resize_pty function in tools.py (used by the non-decorator tool registration path) that gets session from manager and calls session.resize_pty().
    def resize_pty(args: dict) -> dict:
        session = _get_session(args["session_id"])
        session.resize_pty(rows=args["rows"], cols=args["cols"])
        return {"success": True}
  • Registration: The tool is registered in the tuple list returned by create_tools() at line 99 as ('resize_pty', resize_pty).
    return [
        ("start_process", start_process),
        ("send_input", send_input),
        ("read_output", read_output),
        ("send_and_read", send_and_read),
        ("list_sessions", list_sessions),
        ("terminate_process", terminate_process),
        ("resize_pty", resize_pty),
        ("get_session_info", get_session_info),
    ]
  • Registration: The @mcp.tool() decorator on line 183 registers resize_pty as an MCP tool in the FastMCP server.
    @mcp.tool()
    def list_sessions() -> dict:
        """List all interactive process sessions."""
        return {"sessions": _mgr.list_all()}
    
    
    @mcp.tool()
    def terminate_process(
        session_id: str,
        force: bool = False,
        grace_period: float = 5.0,
    ) -> dict:
        """Terminate an interactive process.
    
        Args:
            session_id: The session ID to terminate.
            force: Use SIGKILL instead of SIGTERM. Default False.
            grace_period: Seconds to wait after SIGTERM before SIGKILL. Default 5.
        """
        session = _mgr.get(session_id)
        if not session:
            return {"error": f"Session '{session_id}' not found"}
        session.terminate(force=force, grace_period=grace_period)
        return {"success": True}
    
    
    @mcp.tool()
    def resize_pty(
        session_id: str,
        rows: int = 24,
        cols: int = 80,
    ) -> dict:
        """Resize the PTY terminal dimensions for a session.
    
        Only works in pty mode.
    
        Args:
            session_id: The session ID.
            rows: New row count.
            cols: New column count.
        """
        session = _mgr.get(session_id)
        if not session:
            return {"error": f"Session '{session_id}' not found"}
        try:
            session.resize_pty(rows=rows, cols=cols)
            return {"success": True}
        except RuntimeError as e:
            return {"error": str(e)}
Behavior2/5

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

No annotations are provided, so the description bears full burden. It mentions no side effects, auth requirements, or behavioral traits beyond the mode constraint. For a resize operation, it is safe but lacks detail on response or error behavior.

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 short and to the point, including a constraint and parameter list. It could be more concise by omitting the redundant 'Args' section that repeats schema names, but overall it avoids unnecessary filler.

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

Completeness2/5

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

Given no output schema and 3 parameters with defaults, the description is incomplete. It does not explain return values, what happens on error, or the relationship to other session tools. Adequate for simple use but lacks depth for an autonomous agent.

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

Parameters2/5

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

Schema description coverage is 0%, meaning the description must compensate. It lists params with brief explanations (e.g., 'New row count'), which adds minimal value over the schema titles and defaults. No deeper semantics like allowed ranges or units.

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 'Resize the PTY terminal dimensions' with a specific resource (PTY terminal dimensions for a session). It distinguishes from sibling tools like start_process or send_input by focusing on resizing, but does not explicitly differentiate.

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

Usage Guidelines2/5

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

The description includes a constraint 'Only works in pty mode' but provides no guidance on when to use this tool vs alternatives like send_and_read or start_process. No exclusions or context for selection.

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/UserB1ank/interactive-process-mcp'

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