Back to MCP directory
publicPublicdnsLocal runtime

mcp-ripgrep

一个提供ripgrep搜索能力的MCP服务器

article

README

🚀 MCP 通用grep 服务器

这是一个 MCP 服务器,提供了强大的 ripgrep(rg)搜索功能,任何 MCP 客户端(如 Claude)都能使用,可对系统文件进行高性能文本搜索。

🚀 快速开始

此服务器为强大的ripgrep搜索工具提供了 Model Context Protocol (MCP) 接口。它使 Claude AI 和其他与 MCP 兼容的客户端能够对系统上的文件执行高性能文本搜索。

✨ 主要特性

  • 为 ripgrep 搜索工具提供 MCP 接口,供 Claude 等 MCP 客户端使用。
  • 支持多种搜索模式,如基本搜索、高级搜索、计算匹配次数、列出文件和文件类型等。

📦 安装指南

先决条件

  • Node.js(v18 或更高版本)
  • ripgrep (rg) 命令已安装并添加到 PATH 中。使用 brew install ripgrep 在 macOS 上安装。

💻 使用示例

与Claude Desktop一起使用

要将此 MCP 服务器与 Claude Desktop 一起使用:

  1. 编辑你的 Claude Desktop 配置文件:
    • macOS:~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows:%APPDATA%\Claude\claude_desktop_config.json
  2. 将以下内容添加到你的配置中:
    {
      "mcpServers": {
        "ripgrep": {
          "command": "npx",
          "args": ["-y", "mcp-ripgrep@latest"]
        }
      }
    }
    
    /path/to/mcp-ripgrep 替换为你克隆此仓库的绝对路径。
  3. 重启 Claude Desktop。

可用工具使用示例

基本搜索

基本 ripgrep 搜索:

模式:error
路径:./src

高级搜索

带更多选项的高级搜索:

模式:function
路径:./src
固定字符串:true
文件类型:ts
包含隐藏文件:false

计算匹配次数

计算模式出现的次数:

模式:TODO
路径:./src
计算行数:true

列出文件

列出将要搜索的文件,而不实际执行搜索:

路径:./src
文件类型:js

列出文件类型

列出 ripgrep 支持的所有文件类型。

⚠️ 安全注意事项

此 MCP 服务器使用 ripgrep 工具执行 shell 命令。尽管已努力安全地转义参数,但提供输入时请小心,因为它会在你的机器上运行命令。

📄 许可证

MIT

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client