The MCP Command History server provides a powerful way to explore and manage your shell command history through the Model Control Protocol interface. It enables convenient access, searching, and retrieval of previously executed shell commands, offering seamless integration with Cursor and other MCP-compatible tools.
Clone the repository and install the required dependencies:
# Clone the repository
git clone https://github.com/yourusername/mcp-cmd-history.git
cd mcp-cmd-history
# Install dependencies
pip install -r requirements.txt
To launch the server, run:
python mcp_history_server.py
By default, the server will automatically read your shell history from the location specified in the HISTFILE
environment variable. If this variable is not set, it will default to reading from ~/.bash_history
.
Once your server is up and running, you can leverage these MCP tools within Cursor:
View Recent Commands:
Please show me my most recent shell commands.
Search Your Command History:
Please search my command history for 'git commit' and show me the results.
Retrieve Specific Commands: After listing or searching commands, you can fetch a specific command by referencing its ID.
Search Commands:
search_commands(query: str)
- Find commands matching your search query
Get Recent Commands:
get_recent_commands(limit: int = 10)
- Retrieve your most recently used commands
Get Specific Command:
get_command(command_id: int)
- Fetch a particular command by its ID
history://recent/{limit}
- Retrieve recent command historyhistory://search/{query}
- Search through command historyThere are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.