Mercurial MCP服务器(FastMCP)
通过stdio将Mercurial和Arcanist实用程序暴露给MCP兼容客户端(如Windsurf)的最小MCP服务器。
提供的工具(见 server.py):
get_file_at_commitblame_filelog_commitsget_commit_summarysearch_across_filesget_revision_summary_by_idget_revision_changes_by_idget_task_summary_by_id
如何设置项目
- 先决条件
- Python 3.9+ - 汞(hg)在PATH上可用 - 可选(用于修订/任务工具):Arcanist(arc)已配置访问权限
- 安装依赖项
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# On Windows: .venv\\Scripts\\activate
pip install --upgrade pip
pip install -r requirements.txt- 环境变量
- HG_REPO_ROOT (必填):回购的绝对路径 .hg 目录(例如。, /path/to/repo/.hg) - TOKEN_LIMIT (可选):分页大输出的字符预算(默认值:4096)
- 本地运行(手动测试)
export HG_REPO_ROOT=/abs/path/to/your/repo/.hg
export TOKEN_LIMIT=4096 # optional
python server.py该服务器旨在由MCP客户端通过stdio启动;以上仅验证它是否正确启动。
如何将Mercurial MCP添加到Windsurf(stdio)
您可以使用stdio将此服务器作为自定义MCP服务器添加到Windsurf。
Windsurf MCP配置的示例条目(适应您的文件格式/位置):
{
"mercurial": {
"command": "/home/chirag/repo/mercurial_mcp/run.sh",
"args": [],
"env": {
"HG_REPO_ROOT": "/home/chirag/repo/devel/.hg",
"TOKEN_LIMIT": "10000"
},
"disabled": false,
"disabledTools": [
"search_across_files"
]
}
}更新run.sh
创建或更新 run.sh 并启动服务器:
#!/bin/bash
cd /home/chirag/repo/mercurial_mcp/
source .venv/bin/activate
python3 server.py使其可执行:
chmod +x /home/chirag/repo/mercurial_mcp/run.sh- 验证
- 在Windsurf中,打开MCP面板,确认服务器被列为“Mercurial MCP”。 - 工具来自 server.py 应该出现并可调用。
备注
- 依赖于Arcanist的命令(例如。,
get_revision_*,get_task_*)要求arc以及适当的认证。 - 大输出使用分页
TOKEN_LIMIT;请求后续页面page参数(如适用)。
