Skip to main content
Glama
GongRzhe

Terminal Controller for MCP

get_command_history

Retrieve recent command execution history from the Terminal Controller for MCP server to review and analyze previous terminal operations.

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 that implements the logic for the 'get_command_history' tool. It uses the global command_history list to return a formatted string of recent commands with success status and timestamps.
    @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
  • The @mcp.tool() decorator registers the get_command_history function as an MCP tool.
    @mcp.tool()
  • Global variables that store the command history list and maximum size limit, essential for the get_command_history tool's functionality.
    # List to store command history command_history = [] # Maximum history size MAX_HISTORY_SIZE = 50

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