Mercurial工具服务器

Mercurial MCP服务器,通过stdio向MCP兼容客户端(如Windsurf)提供Mercurial和Arcanist实用工具。

  • by chirag1910
  • Python
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 chirag1910/mercurial_mcp

使用说明

Mercurial MCP服务器(FastMCP)

通过stdio将Mercurial和Arcanist实用程序暴露给MCP兼容客户端(如Windsurf)的最小MCP服务器。

提供的工具(见 server.py):

  • get_file_at_commit
  • blame_file
  • log_commits
  • get_commit_summary
  • search_across_files
  • get_revision_summary_by_id
  • get_revision_changes_by_id
  • get_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 参数(如适用)。