# rag-mcp

The rag-mcp MCP server for Claude Code searches selected files and folders. It retrieves passages by exact terms or meaning, then can answer questions from that material.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 9 repo stars
- Author: MasihMoafi
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/MasihMoafi/rag-mcp
- Updated: 2026-11-15
- Security check: automated, 2026-11-17 (text) — warning: a command downloads a script from raw.githubusercontent.com and runs it right away. Do not run such commands without an explicit yes from the human.
- HTML: https://affpapa.org/en/nevibecode/mcp/rag-mcp

## What it does

rag-mcp searches local files within a chosen scope and returns passages relevant to a question. BM25 handles exact-term retrieval; semantic search uses embeddings, and a separate model can rerank results. The MCP server can also produce answers grounded in the retrieved material.

Exact-term search needs no account or API key. Semantic retrieval requires a selected embedding provider; written answers can use a Codex session with a ChatGPT plan or an OpenRouter key. With `OPENROUTER_API_KEY` set, OpenRouter also receives the query and retrieved passages for reranking, which is enabled automatically. Source files and the index stay local.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `OPENROUTER_API_KEY` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add rag-mcp -e OPENROUTER_API_KEY=<OPENROUTER_API_KEY> -- uvx ragmcp-cli
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from ragmcp-cli <command>

### Codex

**Platform CLI**
```bash
codex mcp add rag-mcp --env OPENROUTER_API_KEY=<OPENROUTER_API_KEY> -- uvx ragmcp-cli
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from ragmcp-cli <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "rag-mcp": {
            "command": "uvx",
            "args": [
                "ragmcp-cli"
            ],
            "env": {
                "OPENROUTER_API_KEY": "<OPENROUTER_API_KEY>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from ragmcp-cli <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "rag-mcp": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "ragmcp-cli"
            ],
            "env": {
                "OPENROUTER_API_KEY": "<OPENROUTER_API_KEY>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from ragmcp-cli <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e OPENROUTER_API_KEY=<OPENROUTER_API_KEY> rag-mcp uvx ragmcp-cli
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from ragmcp-cli <command>

## When to use it
- find relevant passages in a selected folder
- retrieve material by meaning when wording differs
- draft an answer from local documents

## Example prompts
- Find information about upload limits in `./docs` and answer from those files.
- Search `./docs` for material describing changes to the requirements.
- Find the file-retention period after account closure in `./docs`.

## Similar
- [rag-agent-builder](https://affpapa.org/en/nevibecode/skills/rag-agent-builder.md) — skill · 263 installs
- [mcp-local-rag](https://affpapa.org/en/nevibecode/mcp/mcp-local-rag.md) — MCP server · ★ 436 repo stars
- [langchain-rag](https://affpapa.org/en/nevibecode/skills/langchain-rag.md) — skill · 18600 installs
- [rag](https://affpapa.org/en/nevibecode/skills/rag.md) — skill · 3900 installs
- [rag-retrieval](https://affpapa.org/en/nevibecode/skills/rag-retrieval.md) — skill · 1500 installs
- [rag-construction](https://affpapa.org/en/nevibecode/skills/rag-construction.md) — skill · 123 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
