Skip to main content
Glama
README.md
# mcp-repo-search

An MCP (Model Context Protocol) server that lets AI assistants search code across multiple repositories in a workspace directory. Built for use with [Cursor](https://cursor.com), [Claude Code](https://claude.ai/code), and any MCP-compatible client.

## The Problem

You work across multiple repos in a single parent directory. You want your AI assistant to search for a keyword, endpoint, or usage pattern across **all** of them — without opening each one individually.

## What It Does

Point it at a directory that contains your repos, and it auto-discovers all subdirectories as searchable projects. No config files listing repos — just drop them in.

```
~/workspace/
├── api-server/       ← auto-discovered
├── web-app/          ← auto-discovered
├── shared-lib/       ← auto-discovered
└── mobile-app/       ← auto-discovered
```

## Tools Provided

| Tool | Description |
|---|---|
| `search_code` | Regex search across file contents (powered by ripgrep). Filter by file type, glob, or specific repos |
| `find_files` | Find files by name/glob pattern across all repos |
| `read_file` | Read file contents with optional line range |
| `list_repos` | List all discovered repositories |
| `repo_overview` | Get directory structure and config files for a specific repo |

## Prerequisites

- **Node.js** >= 18
- **[ripgrep](https://github.com/BurntSushi/ripgrep#installation)** (`rg`) installed and in PATH

```bash
# macOS
brew install ripgrep

# Ubuntu/Debian
sudo apt install ripgrep

# Windows
choco install ripgrep
```

## Setup

### Cursor

Add to `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "repo-search": {
      "command": "node",
      "args": ["/path/to/mcp-repo-search/index.js"],
      "env": {
        "REPO_SEARCH_ROOT": "/path/to/your/workspace"
      },
      "alwaysAllow": [
        "search_code",
        "find_files",
        "read_file",
        "list_repos",
        "repo_overview"
      ]
    }
  }
}
```

Restart Cursor. The tools will be available to the AI agent.

### Claude Code

```bash
claude mcp add repo-search node /path/to/mcp-repo-search/index.js \
  -e REPO_SEARCH_ROOT=/path/to/your/workspace
```

### VS Code (Copilot)

Add to `.vscode/mcp.json`:

```json
{
  "servers": {
    "repo-search": {
      "command": "node",
      "args": ["/path/to/mcp-repo-search/index.js"],
      "env": {
        "REPO_SEARCH_ROOT": "/path/to/your/workspace"
      }
    }
  }
}
```

### npx (any MCP client)

```bash
REPO_SEARCH_ROOT=/path/to/workspace npx mcp-repo-search
```

## Environment Variables

| Variable | Default | Description |
|---|---|---|
| `REPO_SEARCH_ROOT` | Current working directory | Parent directory containing your repos |
| `REPO_SEARCH_RG` | Auto-detected | Path to `rg` binary |
| `REPO_SEARCH_IGNORE` | `node_modules,.git,target,.svn,dist,build` | Comma-separated directories to ignore in `repo_overview` |
| `REPO_SEARCH_DEPTH` | `2` | Default directory tree depth for `repo_overview` |

## Usage Examples

Once configured, ask your AI assistant:

- *"Search for PaymentController across all repos"*
- *"Find all files named *.controller.ts"*
- *"Where is the /api/webhook endpoint defined?"*
- *"Give me an overview of the backend repo"*
- *"Search for 'fetchUser' but only in the frontend and shared-lib repos"*
- *"Find all .svelte files that import EmailBuilder"*

## License

MIT