Skip to main content
Glama
GongRzhe

Terminal Controller for MCP

get_command_history

Retrieve a formatted record of recent terminal commands. Specify the number of commands to review past actions.

Instructions

Get recent command execution history

Args:
    count: Number of recent commands to return

Returns:
    Formatted command history record

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
countNo

Implementation Reference

  • The handler function for the 'get_command_history' MCP tool. Registered with @mcp.tool() decorator, it reads from the global 'command_history' list (populated by run_command) and returns a formatted string of recent commands with success/failure status.
    @mcp.tool()
    async def get_command_history(count: int = 10) -> str:
        """
        Get recent command execution history
        
        Args:
            count: Number of recent commands to return
        
        Returns:
            Formatted command history record
        """
        if not command_history:
            return "No command execution history."
        
        count = min(count, len(command_history))
        recent_commands = command_history[-count:]
        
        output = f"Recent {count} command history:\n\n"
        
        for i, cmd in enumerate(recent_commands):
            status = "✓" if cmd["success"] else "✗"
            output += f"{i+1}. [{status}] {cmd['timestamp']}: {cmd['command']}\n"
        
        return output
  • Registration of the tool via the @mcp.tool() decorator on the FastMCP instance 'mcp'.
    @mcp.tool()
  • The docstring serves as the schema/description for the tool, defining the 'count' parameter (int, default 10) and the return type (str).
    """
    Get recent command execution history
    
    Args:
        count: Number of recent commands to return
    
    Returns:
        Formatted command history record
    """
  • The run_command helper function populates the global 'command_history' list that get_command_history reads from.
    # Add to history
    command_history.append({
        "timestamp": datetime.now().isoformat(),
        "command": cmd,
        "success": return_code == 0
    })
Behavior2/5

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

Despite no annotations, the description only vaguely mentions 'recent' and returns 'Formatted command history record', omitting details on ordering, session scope, or side effects.

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 brief and front-loaded with the purpose, but the structure could be improved by placing the parameter description inline rather than in an unstructured list.

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?

For a simple tool with one optional parameter and no output schema, the description covers the basics but lacks details on default behavior, ordering, and format of the history.

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 description adds meaning to the 'count' parameter by stating it controls the number of recent commands returned, compensating for the 0% schema description coverage.

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 action (Get) and resource (recent command execution history), which distinguishes it from sibling tools that focus on file and directory operations.

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?

No guidance is provided on when to use this tool versus alternatives, nor are there any exclusions or prerequisites mentioned.

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

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