Skip to main content
Glama

terminal_get_output

Retrieve recent terminal output including command inputs and results for monitoring or debugging purposes. Specify session ID and number of lines to capture from terminal history.

Instructions

Get the output from a terminal.

Retrieves the recent output from the terminal's history. This includes
both command inputs and their outputs.

Args:
    session_id: The terminal session ID returned by terminal_create_or_get.
    lines: Number of lines to retrieve from the end (default: 100, max: 1000).

Returns:
    dict: Contains success status, session_id, and the output text.

Examples:
    - Get last 100 lines: terminal_get_output(session_id="abc123")
    - Get last 50 lines: terminal_get_output(session_id="abc123", lines=50)

Note:
    Output may have a slight delay as it's captured asynchronously from
    the terminal process.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
linesNo

Implementation Reference

  • The implementation of the terminal_get_output tool handler, which retrieves terminal output from the SessionManager.
    async def terminal_get_output(session_id: str, lines: int = 100) -> dict:
        """Get the output from a terminal.
    
        Retrieves the recent output from the terminal's history. This includes
        both command inputs and their outputs.
    
        Args:
            session_id: The terminal session ID returned by terminal_create_or_get.
            lines: Number of lines to retrieve from the end (default: 100, max: 1000).
    
        Returns:
            dict: Contains success status, session_id, and the output text.
    
        Examples:
            - Get last 100 lines: terminal_get_output(session_id="abc123")
            - Get last 50 lines: terminal_get_output(session_id="abc123", lines=50)
    
        Note:
            Output may have a slight delay as it's captured asynchronously from
            the terminal process.
        """
        manager = SessionManager.get_instance()
        session = await manager.get_session(session_id)
    
        if not session:
            return {
                "success": False,
                "error": f"Session '{session_id}' not found. It may have been closed or never existed.",
                "suggestion": "Use terminal_create_or_get to create a new terminal.",
            }
    
        # Clamp lines to reasonable range
        lines = max(1, min(lines, 1000))
    
        output = await manager.get_output(session_id, lines)
        return {
            "success": True,
            "session_id": session_id,
            "terminal_name": session.name,
            "output": output,
            "lines_requested": lines,
        }
  • MCP tool registration for terminal_get_output.
    @mcp.tool(
        name="terminal_get_output",
        annotations={
            "title": "Get Terminal Output",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False,
        },
    )

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/Hor1zonZzz/terminal-mcp'

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