mcp-histfile

This repository provides a tool to access, search, and manage shell command history through the MCP interface, enabling users to retrieve recent commands and search for specific commands easily.

1
0

MCP Command History

This project provides a tool for exploring, searching, and managing shell command history through the MCP (Model Control Protocol) interface. It allows users to access, search, and retrieve previously executed shell commands.

Features

  • Command History Access: Programmatic access to shell command history.
  • Powerful Search: Search command history using text queries.
  • Recent Commands: Quickly retrieve recently executed commands.
  • MCP Integration: Integrates with Cursor and other MCP-compatible tools.

Installation

Prerequisites

  • Python 3.6+
  • Shell with history support (Bash, Zsh, etc.)

Install from Source

git clone https://github.com/yourusername/mcp-cmd-history.git
cd mcp-cmd-history
pip install -r requirements.txt

Usage

Starting the Server

python mcp_history_server.py

The server reads shell history from the HISTFILE environment variable or ~/.bash_history.

Using with Cursor

Example MCP tools in Cursor:

  1. Get Recent Commands: Please show me my most recent shell commands.
  2. Search Command History: Please search my command history for 'git commit'.

API Reference

MCP Tools

  • search_commands(query: str): Searches shell history.
  • get_recent_commands(limit: int = 10): Gets recent commands.
  • get_command(command_id: int): Gets a command by ID.

MCP Resources

  • history://recent/{limit}: Recent commands (HTTP endpoint).
  • history://search/{query}: Search commands (HTTP endpoint).

Repository

RA
rajpdus

rajpdus/mcp-histfile

Created

March 13, 2025

Updated

March 23, 2025

Language

Python

Category

Developer Tools