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
| Name | Required | Description | Default |
|---|---|---|---|
| count | No |
Implementation Reference
- terminal_controller.py:145-168 (handler)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
- terminal_controller.py:145-145 (registration)The @mcp.tool() decorator registers the get_command_history function as an MCP tool.@mcp.tool()
- terminal_controller.py:13-17 (helper)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