About MCP Command History
MCP Command History exposes Bash and Zsh command history to MCP-compatible clients. Developers can retrieve recent commands, search history, or fetch an entry by its ID.
Key features
- 01Access shell command history
- 02Search commands by text
- 03Retrieve recent commands
- 04Fetch a command by ID
Use cases
- 01Find a previously used command
- 02Review recent shell activity
- 03Retrieve a command found in search results
MCP support
The server exposes tools for searching history, listing recent commands, and retrieving an entry by ID, plus resources for recent and searched history.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEMCP Command History
A powerful tool for exploring, searching, and managing your shell command history through the MCP (Model Control Protocol) interface. This project allows you to easily access, search, and retrieve your previously executed shell commands.
Features
- Command History Access: Access your shell command history programmatically
- Powerful Search: Search through your command history with text queries
- Recent Commands: Quickly retrieve your most recently executed commands
- MCP Integration: Seamlessly integrates with Cursor and other MCP-compatible tools
Installation
Prerequisites
- Python 3.6 or higher
- A shell with history support (Bash, Zsh, etc.)
Install from Source
# Clone the repository
git clone https://github.com/yourusername/mcp-cmd-history.git
cd mcp-cmd-history
# Install dependencies
pip install -r requirements.txt
Usage
Starting the Server
python mcp_history_server.py
By default, the server will read your shell history from the location specified in the HISTFILE environment variable, or fall back to ~/.bash_history.
Using with Cursor
Once the server is running, you can use the following MCP tools in Cursor:
-
Get Recent Commands:
Please show me my most recent shell commands. -
Search Command History:
Please search my command history for 'git commit' and show me the results. -
Get Specific Command: You can retrieve a specific command by its ID after searching or listing recent commands.
API Reference
MCP Tools
search_commands(query: str): Search for commands in shell historyget_recent_commands(limit: int = 10): Get the most recent commands from historyget_command(command_id: int): Get a specific command by ID
MCP Resources
history://recent/{limit}: Get recent commands (HTTP endpoint)history://search/{query}: Search for commands (HTTP endpoint)
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.