MCP Ripgrep搜索
为MCP客户端(如克劳德)提供ripgrep搜索功能,允许在系统中的文件上进行高性能的文本搜索。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"ripgrep": {
"args": [
"-y",
"mcp-ripgrep@latest"
],
"command": "npx"
}
}
}
可用工具 (5 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
search 7 个参数 需填 2 项
Search files for patterns using ripgrep (rg)
必填参数:pattern、path
advanced-search 15 个参数 需填 2 项
Advanced search with ripgrep with more options
必填参数:pattern、path
count-matches 6 个参数 需填 2 项
Count matches in files using ripgrep
必填参数:pattern、path
list-files 4 个参数 需填 1 项
List files that would be searched by ripgrep without actually searching them
必填参数:path
list-file-types
List all supported file types in ripgrep
该工具无需必填参数,直接调用即可
服务介绍
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一起使用:
-
编辑您的桌面版Claude配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
在您的配置中添加以下内容:
{ "mcpServers": { "ripgrep": { "command": "npx", "args": ["-y", "mcp-ripgrep@latest"] } } }将
/path/to/mcp-ripgrep替换为您克隆此仓库的绝对路径。 -
重启桌面版Claude。
可用工具
search
使用ripgrep的基本搜索:
Pattern: error
Path: ./src
advanced-search
带有额外选项的更高级搜索:
Pattern: function
Path: ./src
FixedStrings: true
FileType: ts
IncludeHidden: false
count-matches
统计模式出现次数:
Pattern: TODO
Path: ./src
CountLines: true
list-files
列出将被搜索的文件而不实际执行搜索:
Path: ./src
FileType: js
list-file-types
列出ripgrep支持的所有文件类型。
安全考虑
此MCP服务器通过ripgrep工具执行shell命令。尽管已经努力安全地转义参数,但在提供输入时仍需谨慎,因为它会在您的机器上运行命令。
许可证
MIT