Skip to main content
Glama
sichang824

MCP Terminal

by sichang824

get_terminal_info

Retrieve terminal environment details to understand system configuration and capabilities for executing commands.

Instructions

Gets terminal information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_terminal_info' tool. It fetches terminal type via controller, platform info, current directory (preferring terminal pwd), user, shell, and terminal size, returning a TerminalInfoResponse.
    @mcp.tool(name="get_terminal_info", description="Gets terminal information")
    async def get_terminal_info() -> TerminalInfoResponse:
        try:
            # Ensure we have a controller
            if not self.controller:
                self._init_controller()
    
            # Get terminal type
            terminal_type = await self.controller.get_terminal_type()
    
            # Get platform
            import getpass
            import os
            import platform
            import shutil
    
            platform_name = platform.system()
    
            # Get current directory directly
            current_dir = None
            try:
                pwd_result = await self.controller.execute_command(
                    "pwd", wait_for_output=True, timeout=5
                )
                if pwd_result.get("success") and pwd_result.get("output"):
                    # Clean the output by splitting lines and finding a valid path
                    lines = pwd_result.get("output").splitlines()
                    for line in lines:
                        line = line.strip()
                        # On macOS/Linux, a valid path should start with /
                        if line.startswith("/"):
                            current_dir = line
                            break
            except Exception as e:
                logger.debug(f"Error getting current directory from terminal: {e}")
    
            # Fallback to Python's os.getcwd()
            if not current_dir:
                current_dir = os.getcwd()
    
            # Get user
            user = getpass.getuser()
    
            # Get shell
            shell = os.environ.get("SHELL", None)
    
            # Get terminal size if possible
            terminal_size = None
            try:
                cols, rows = shutil.get_terminal_size(fallback=(80, 24))
                terminal_size = {"rows": rows, "columns": cols}
            except Exception:
                pass
    
            return TerminalInfoResponse(
                terminal_type=terminal_type,
                platform=platform_name,
                current_directory=current_dir,
                user=user,
                shell=shell,
                terminal_size=terminal_size,
            )
        except Exception as e:
            logger.error(f"Error getting terminal info: {e}")
            return TerminalInfoResponse(
                terminal_type="unknown",
                platform="unknown",
                current_directory="unknown",
                user="unknown",
            )
  • Pydantic model defining the output schema (TerminalInfoResponse) for the get_terminal_info tool.
    class TerminalInfoResponse(BaseModel):
        """Response model for terminal information."""
    
        terminal_type: str = Field(..., description="The type of terminal being used")
        platform: str = Field(..., description="The platform the terminal is running on")
        current_directory: str = Field(
            ..., description="Current working directory of the terminal"
        )
        user: str = Field(..., description="Current user name")
        shell: Optional[str] = Field(None, description="Shell being used")
        terminal_size: Optional[dict] = Field(
            None, description="Terminal dimensions (rows, columns)"
        )
  • Code that instantiates the TerminalTool and calls its register_mcp method, which defines and registers the get_terminal_info tool with the FastMCP instance.
    terminal_tool = TerminalTool(
        self.controller_type,
        whitelist_file=self.whitelist_file,
        blacklist_file=self.blacklist_file,
        whitelist_mode=self.whitelist_mode,
    )
    file_tool = FileTool()
    terminal_tool.register_mcp(self.mcp)
    file_tool.register_mcp(self.mcp)
    self.tools["terminal"] = terminal_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. It states 'Gets terminal information', implying a read-only operation, but doesn't specify what information is returned (e.g., format, structure), whether it requires permissions, or if there are rate limits. The description is too vague to provide meaningful behavioral context beyond the basic action.

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

Conciseness3/5

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

The description 'Gets terminal information' is concise with a single sentence, but it's under-specified rather than efficiently informative. It lacks front-loaded detail that could clarify the tool's purpose, making it too brief to be truly helpful. While not verbose, it fails to earn its place by providing sufficient value.

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 the tool's simplicity (0 parameters, no output schema, no annotations), the description is incomplete. It doesn't explain what 'terminal information' entails, the return format, or any behavioral aspects. For a tool with no structured data to rely on, the description should provide more context to be fully usable by an agent.

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?

The tool has 0 parameters, and the input schema has 100% description coverage (though empty). With no parameters to document, the description doesn't need to add parameter semantics. A baseline score of 4 is appropriate as the schema fully covers the parameterless nature, and the description doesn't introduce confusion.

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

Purpose2/5

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

The description 'Gets terminal information' is a tautology that essentially restates the tool name 'get_terminal_info'. It provides a verb ('Gets') and resource ('terminal information'), but lacks specificity about what information is retrieved (e.g., terminal type, dimensions, capabilities) and doesn't differentiate from sibling tools like 'execute_command' or 'file_modify'. This makes it vague and minimally informative.

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

Usage Guidelines1/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any context, prerequisites, or exclusions, and fails to distinguish it from sibling tools such as 'execute_command' (for running commands) or 'file_modify' (for file operations). This absence of usage instructions leaves the agent without direction.

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

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