Skip to main content
Glama
@atef_andrus/mcp-ripgrep

@atef_andrus/mcp-ripgrep

by AtefAndrus

@atef_andrus/mcp-ripgrep

npm version CI License: MIT

An MCP server that provides ripgrep search capabilities.

Prerequisites

  • ripgrep (rg) installed and available on PATH

  • Node.js 22+ or Bun 1.3+

Related MCP server: ripgrep-mcp

Installation

npm install @atef_andrus/mcp-ripgrep

Usage

Use as an MCP Server

Add the following to your MCP client configuration:

{
  "mcpServers": {
    "ripgrep": {
      "command": "npx",
      "args": ["@atef_andrus/mcp-ripgrep"]
    }
  }
}

Startup Options

Option

Description

--allow-dir <path>

Restrict search scope to the specified directory (can be specified multiple times)

--max-result-chars <number>

Maximum characters in results. Truncates at line boundaries when exceeded (default: 50,000)

--max-output-bytes <number>

Maximum bytes of ripgrep output. Terminates the process and truncates results when exceeded (default: 20 MB)

Configuration example with startup options:

{
  "mcpServers": {
    "ripgrep": {
      "command": "npx",
      "args": [
        "@atef_andrus/mcp-ripgrep",
        "--allow-dir", "/home/user/project",
        "--max-result-chars", "50000",
        "--max-output-bytes", "20000000"
      ]
    }
  }
}

Tools

Tool

Description

search

Pattern search with regex, literal strings, multiline matching, OR matching, context lines, and various filters. Prepends a summary of match count and file count to results

search-and-replace

Search-and-replace preview (read-only). Supports multiline matching and capture groups ($1, ${name})

search-count

Count matches per file (by line count or total matches). Supports sorting results

search-files

List files that match or do not match a pattern

list-files

List all files within the search scope

list-file-types

List file types supported by ripgrep

Key Parameters

Parameter

Description

pattern

Search pattern (regex by default)

path

Directory or file to search

fixedStrings

Treat the pattern as a literal string

caseSensitive

true = case-sensitive, false = case-insensitive, omitted = smart-case

fileType

Filter by file type (e.g., "ts", ["ts", "js"]). String or array

fileTypeNot

Exclude file types (e.g., "json", ["json", "md"]). String or array

glob

Filter by glob pattern (e.g., "*.test.ts", ["src/**", "!vendor/**"]). String or array

includeHidden

Include hidden files

followSymlinks

Follow symbolic links

maxDepth

Maximum directory traversal depth

noIgnore

Ignore .gitignore rules and search files that are normally excluded

multiline

Enable multiline matching (function signatures, import blocks, etc.)

additionalPatterns

Additional patterns for OR matching (array)

sortBy

Sort results. search / search-files / list-files: "path" "modified" "created". search-count: "path" "count" "count-asc"

maxCharacters

Maximum characters in results. Truncates at line boundaries and appends a summary when exceeded

Parameter Support by Tool

Parameter

list-file-types

list-files

search

search-and-replace

search-count

search-files

pattern

-

-

o

o

o

o

path

-

o

o

o

o

o

fixedStrings

-

-

o

o

o

o

caseSensitive

-

-

o

o

o

o

wordMatch

-

-

o

o

o

o

multiline

-

-

o

o

-

-

fileType

-

o

o

o

o

o

fileTypeNot

-

o

o

o

o

o

glob

-

o

o

o

o

o

maxResults

-

-

o

o

-

-

contextLines

-

-

o

-

-

-

beforeContext

-

-

o

-

-

-

afterContext

-

-

o

-

-

-

invertMatch

-

-

o

-

-

o

includeHidden

-

o

o

o

o

o

followSymlinks

-

o

o

o

o

o

maxDepth

-

o

o

o

o

o

additionalPatterns

-

-

o

-

-

-

jsonOutput

-

-

o

-

-

-

maxColumns

-

-

o

-

-

-

noIgnore

-

o

o

o

o

o

sortBy

-

o

o

-

o

o

maxCharacters

o

o

o

o

o

o

replacement

-

-

-

o

-

-

onlyMatching

-

-

-

o

-

-

countMode

-

-

-

-

o

-

includeZero

-

-

-

-

o

-

Development

# Install dependencies
bun install

# Run tests
bun test

# Type check
bunx tsc --noEmit

# Lint and format
bunx biome check --write .

# Build
bunx tsc

# Start in development mode
bun run dev

Security

  • This server passes arguments as an array via spawn("rg", args) (no shell interpolation). Patterns and paths are placed after a -- separator to prevent flag injection.

  • The --allow-dir option restricts the search scope to specified directories. Paths are resolved to absolute paths using path.resolve() and validated via prefix matching.

  • Limitation: When followSymlinks is enabled, symbolic links may allow access to directories outside the allowed scope. Be aware of this when using --allow-dir together with followSymlinks.

License

MIT

Available Tools

6 tools
list-filesRipgrep List FilesA

List all files in the search scope using ripgrep. No pattern matching — just lists files that would be searched.

Inputs: path (required), glob, sortBy, fileType, +6 more.

list-file-typesRipgrep List File TypesA

List all file types supported by ripgrep. Useful for finding valid values for the fileType parameter.

Inputs: maxCharacters.

search-and-replaceRipgrep Search and Replace PreviewA

Read-only preview of search-and-replace results using ripgrep. Does NOT modify files. Useful for previewing replacements and testing capture groups ($1, $2, ${name}).

Inputs: path (required), pattern (required), replacement (required), glob, +13 more.

search-countRipgrep Search CountB

Count pattern matches per file using ripgrep. Returns file paths with their match counts.

Inputs: path (required), pattern (required), glob, sortBy, +12 more.

search-filesRipgrep Search FilesA

List files that match (or do not match) a pattern using ripgrep. Returns file paths only, no line content.

Inputs: path (required), pattern (required), glob, sortBy, +11 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool exposes a distinct ripgrep operation: content search, count, file-list matching, all-file listing, file-type listing, and a read-only replace preview. Descriptions clearly differentiate outputs and use cases, leaving minimal risk of misselection.

    Naming Consistency4/5

    Names follow a lowercase-hyphenated convention (search, search-count, search-files, list-files, list-file-types), which is readable and mostly predictable. Minor inconsistencies exist: 'search' is a bare verb and 'search-and-replace' uses a compound phrase rather than a strict verb_noun pattern.

    Tool Count5/5

    Six tools are well-scoped for a ripgrep wrapper, covering the core search, count, listing, and preview operations without redundancy. Each tool earns its place and the set avoids bloat.

    Completeness4/5

    The surface covers ripgrep's main search and inspection workflows: pattern search, counting, file matching, full file listing, file-type enumeration, and replace preview. A minor gap is the lack of an actual file-modification tool, but the read-only design is clearly intentional.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Provides ripgrep search capabilities to MCP clients like Claude, enabling high-performance text searches across files on your system.
      5
      15 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A stdio-based MCP server for fast, bounded search and navigation of large code repositories using ripgrep, with tools for project-wide search, symbol lookup, file listing, and code reading.
      5 npm
      1
      MIT