get_command_history
Retrieve recent command execution history from the Terminal Controller for MCP. Specify the number of commands to return for efficient tracking and review of terminal activities.
Instructions
Get recent command execution history
Args:
count: Number of recent commands to return
Returns:
Formatted command history record
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | No |
Implementation Reference
- terminal_controller.py:145-168 (handler)The main handler function for the 'get_command_history' tool. It is decorated with @mcp.tool(), which registers it as an MCP tool. The function retrieves the most recent commands from the global 'command_history' list, formats them with status indicators, and returns a string summary.@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
- terminal_controller.py:13-17 (helper)Global list 'command_history' that stores executed commands (populated by 'run_command' function used in 'execute_command' tool) and MAX_HISTORY_SIZE constant used to limit the history size. This is the data source for the 'get_command_history' tool.# List to store command history command_history = [] # Maximum history size MAX_HISTORY_SIZE = 50
- terminal_controller.py:145-145 (registration)The @mcp.tool() decorator on the get_command_history function registers it as an available MCP tool.@mcp.tool()