Mercurial MCP服务器
 ](https://badge.fury.io/js/mcp-server-mercurial)
用于Mercurial存储库交互和自动化的模型上下文协议服务器。此服务器提供通过大型语言模型读取、搜索和操作Mercurial存储库的工具,重点是基于主题的开发工作流。
特性
核心业务
hg_status-显示工作目录状态hg_diff-显示未提交的更改hg_diff_staged-显示所有未提交的更改(Mercurial没有暂存区)hg_diff_rev-显示特定变更集引入的更改hg_commit-记录对存储库的更改hg_add-将新文件添加到版本控制中hg_remove-从版本控制中删除文件hg_move-移动或重命名文件hg_revert-还原未提交的更改hg_log-显示提交历史记录
基于主题的开发(推荐)
hg_topic-创建新主题hg_topics-列出所有主题hg_topic_current-显示当前主题hg_update-对不同主题、分支或修订的更新hg_stack-显示当前主题堆栈
高级操作
hg_rebase-将更改重新定位到目标(比合并更可取)hg_evolve-改进存储库以解决不稳定问题
安装
来源
git clone
cd mcp-mercurial-server
npm install
npm run build
npm link配置
克劳德桌面
如果从源代码安装:
{
"mcpServers": {
"mercurial": {
"command": "mcp-server-mercurial"
}
}
}使用示例
基本工作流程
1. Check status: hg_status
2. View changes: hg_diff
3. Add new files: hg_add (files: ["file1.cpp"])
4. Remove files: hg_remove (files: ["file3.cpp"])
5. Move/rename files: hg_move (source: "file2.cpp", destination: "file4.cpp")
6. Commit with detailed message and explicit files:
hg_commit (
message: "Your commit message\n\n- Added a #1 file\n- Got rid of a file named 3 because it was useless\n- Fixed naming of file 4",
files: ["file1.cpp", "file3.cpp", "file4.cpp"]
)检查当前状态
# Get the current topic
hg_topic_current
# See the last 5 commits (default)
hg_log
# Get topic name using template
hg_log (max_count: 1, template: "{topic}")基于主题的开发
1. Create topic: hg_topic (topic_name: "feature-xyz")
2. Work on changes...
3. Commit to topic: hg_commit (message: "Implement feature XYZ", files: ["feature.cpp"])
4. Rebase topic: hg_rebase (destination: "default")需求
- Node.js 18或更高版本
- Mercurial已安装并可在PATH中使用
- Mercurial扩展(推荐):
- topics 基于主题的工作流扩展 - evolve 历史管理扩展
发展
# Install dependencies
npm install
# Run in development mode
npm run dev
# Build
npm run build
# Run tests
npm test
# Lint
npm run lint
# Format
npm run format调试
使用MCP检查器调试服务器:
npx @modelcontextprotocol/inspector npx mcp-server-mercurial与Git的主要区别
- 无暂存区:所有更改都直接提交
- 话题:用于功能开发的轻量级分支
- 首选重基:使用重基而不是合并,以获得更清晰的历史记录
- 进化:使用evolution扩展程序进行安全的历史编辑
最佳实践
- 始终在提交中明确列出文件 -不要依赖隐式文件选择
- 使用多行提交消息 为清楚起见,请使用要点:
Main description
- First change detail
- Second change detail
- Third change detail- 更喜欢主题而不是分支 用于功能开发
- 检查当前主题 开始工作前:
hg_topic_current
- 查看最近的提交 随着
hg_log(默认为最后5个)
许可证
麻省理工学院
