Shell History MCP server

Powerful shell command history exploration tool that allows searching, retrieving, and programmatically accessing past shell commands across different environments like Bash and Zsh.
Back to servers
Provider
rajpdus
Release date
Mar 18, 2025
Language
Python
Stats
1 star

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.

Installation Requirements

Prerequisites

  • Python 3.6 or higher
  • A shell with history support (Bash, Zsh, etc.)

Installation Steps

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

Using the Command History Server

Starting the Server

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.

Interacting with Cursor

Once your server is up and running, you can leverage these MCP tools within Cursor:

Common Commands

  1. View Recent Commands:

    Please show me my most recent shell commands.
    
  2. Search Your Command History:

    Please search my command history for 'git commit' and show me the results.
    
  3. Retrieve Specific Commands: After listing or searching commands, you can fetch a specific command by referencing its ID.

API Functions

Available MCP Tools

  • 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

HTTP Endpoints

  • history://recent/{limit} - Retrieve recent command history
  • history://search/{query} - Search through command history

How to add this MCP server to Cursor

There 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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later