MCP Ripgrep 服务器
为任何 MCP 客户端(例如 Claude)提供 ripgrep(rg)搜索功能的 MCP 服务器。
概述
该服务器为强大的ripgrep搜索工具提供了模型上下文协议 (MCP) 接口。它使 Claude AI 和其他兼容 MCP 的客户端能够在系统上的文件中执行高性能文本搜索。
先决条件
- Node.js(v18 或更高版本)
- ripgrep (
rg
) 命令已安装并添加到你的 PATH 中。在 macOS 上使用brew install ripgrep
命令安装。
与 Claude 桌面版一起使用
要将此 MCP 服务器与 Claude for Desktop 一起使用:
- 编辑 Claude for Desktop 配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- 将以下内容添加到您的配置中:
{
"mcpServers": {
"ripgrep": {
"command": "npx",
"args": ["-y", "mcp-ripgrep@latest"]
}
}
}
将/path/to/mcp-ripgrep
替换为您克隆此存储库的绝对路径。 - 重新启动 Claude 桌面版。
可用工具
搜索
使用 ripgrep 进行基本搜索:
Pattern: error
Path: ./src
高级搜索
具有附加选项的更高级搜索:
Pattern: function
Path: ./src
FixedStrings: true
FileType: ts
IncludeHidden: false
计数匹配
计算某个模式出现的次数:
Pattern: TODO
Path: ./src
CountLines: true
列出文件
列出将被搜索但不实际搜索的文件:
列出文件类型
列出 ripgrep 中支持的所有文件类型。
安全注意事项
此 MCP 服务器使用 ripgrep 工具执行 shell 命令。虽然已尽力安全地转义参数,但在输入时请务必谨慎,因为它会在您的计算机上运行命令。
执照
麻省理工学院