Skip to main content
Glama

terminal_get_output

Read-onlyIdempotent

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,
        },
    )
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false. The description adds valuable behavioral context beyond annotations: it explains that output includes both command inputs and outputs, mentions a slight delay due to asynchronous capture, and specifies default/max lines. This enhances understanding of the tool's behavior.

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

Conciseness5/5

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

The description is well-structured and front-loaded with purpose, followed by detailed sections (Args, Returns, Examples, Note). Every sentence adds value: no repetition or fluff, and information is efficiently organized for clarity.

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

Completeness5/5

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

Given the tool's moderate complexity, no output schema, and rich annotations, the description is complete. It covers purpose, usage, parameters, return values, examples, and behavioral notes. The annotations handle safety and idempotency, while the description fills in operational details adequately.

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

Parameters4/5

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

Schema description coverage is 0%, so the description carries full burden. It effectively explains both parameters: session_id's source (from terminal_create_or_get) and lines' purpose (number to retrieve from the end), default (100), and max (1000). This adds meaningful semantics beyond the bare schema.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('Get the output', 'Retrieves the recent output') and resource ('from a terminal'). It distinguishes from siblings by focusing on output retrieval rather than session management (terminal_create_or_get, terminal_close), listing (terminal_list), or input sending (terminal_send_input).

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

Usage Guidelines4/5

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

The description provides clear context for usage: it's for retrieving terminal output, with session_id from terminal_create_or_get. However, it doesn't explicitly state when NOT to use it or name alternatives for similar functions, though siblings suggest distinct purposes.

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

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