MCP 命令历史记录是一款强大的工具,借助 MCP(模型控制协议)接口,可帮助您便捷地探索、搜索和管理 shell 命令历史记录。它让您能轻松访问、搜索和检索之前执行过的 shell 命令。
MCP 命令历史记录允许您程序化地访问 shell 命令历史记录,可使用文本查询进行搜索,还能快速获取最新执行的命令,并且能与 Cursor 和其他兼容 MCP 的工具无缝集成。
# 克隆仓库
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环境变量指定的位置读取您的 shell 历史记录,或者回退到~/.bash_history。
一旦服务器运行,您可以在 Cursor 中使用以下 MCP 工具:
请显示我最新的 shell 命令。
请在我的命令历史记录中搜索'git commit'并显示结果。
search_commands(query: str):在 shell 历史记录中搜索命令。get_recent_commands(limit: int = 10):获取最近年份的命令。get_command(command_id: int):按 ID 获取特定命令。history://recent/{limit}:获取最近的命令(HTTP 端点)。history://search/{query}:搜索命令(HTTP 端点)。欢迎贡献!请参见CONTRIBUTING.md了解指南。
此项目根据 MIT 许可证授权 - 有关详细信息,请参阅LICENSE文件。