MCP Command History

MCP Command History

site icon
2025.03.13 1
Python命令历史管理开发工具开发效率
MCP Command History 是一个强大的工具,用于通过 MCP(模型控制协议)接口探索、搜索和管理 shell 命令历史记录。该项目允许用户轻松访问、搜索和检索之前执行的 shell 命令。
View on GitHub

Overview

基本能力

产品定位

MCP Command History 是一个用于管理和搜索 shell 命令历史的工具,旨在提高开发者的工作效率。

核心功能

  • 命令历史访问:以编程方式访问 shell 命令历史。
  • 强大的搜索功能:通过文本查询搜索命令历史。
  • 最近命令检索:快速获取最近执行的命令。
  • MCP 集成:与 Cursor 和其他 MCP 兼容工具无缝集成。

适用场景

  • 开发者需要快速查找之前执行的命令。
  • 团队协作时共享或回顾命令历史。
  • 自动化脚本需要访问历史命令。

工具列表

  • search_commands(query: str):在 shell 历史中搜索命令。
  • get_recent_commands(limit: int = 10):获取最近的命令。
  • get_command(command_id: int):通过 ID 获取特定命令。

常见问题解答

  • 如何指定历史文件路径?:默认从 HISTFILE 环境变量或 ~/.bash_history 读取。
  • 如何与 Cursor 集成?:启动服务器后,可以在 Cursor 中使用 MCP 工具。

使用教程

使用依赖

  • Python 3.6 或更高版本。
  • 支持历史的 shell(如 Bash、Zsh 等)。

安装教程

# 克隆仓库
git clone https://github.com/yourusername/mcp-cmd-history.git
cd mcp-cmd-history

# 安装依赖
pip install -r requirements.txt

调试方式

启动服务器:

python mcp_history_server.py

默认情况下,服务器会从 HISTFILE 环境变量或 ~/.bash_history 读取历史记录。

在 Cursor 中使用 MCP 工具:

  1. 获取最近命令Please show me my most recent shell commands.

  2. 搜索命令历史Please search my command history for 'git commit' and show me the results.

  3. 获取特定命令:在搜索或列出最近命令后,可以通过 ID 获取特定命令。

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。