CCM
/MCP
SkillsMCPMarketplacesDigestToolsAdvertise

This week in Claude

Every Monday: Claude Code, Agent SDK, MCP, and the Anthropic platform moves worth your time.

Skills by Category
Frontend DevelopmentBackend & APIsTesting & QASecurityDevOps & CI/CDGit & Pull RequestsDocumentationCode Review & QualityAI & Agent BuildingSkill Development
MCP Servers by Category
Sales & MarketingWeb & Browser AutomationDatabasesAI & LLM ToolsCloud & InfrastructureCommunication & MessagingDeveloper ToolsDesign & CreativeDocuments & KnowledgeSearch & Web Crawling
Marketplaces by Category
AI Agents & OrchestrationLLM IntegrationDevelopment ToolsFrontend & UIBackend & APIsDatabasesTesting & Code QualityDevOps & CloudSecurity & ComplianceGit & Version Control

Claude Code Marketplaces

Discover Claude Code plugins, extensions, and tools. Automatically updated directory of Anthropic Claude AI marketplaces with development tools, productivity plugins, and integrations.

Resources

  • Browse Skills
  • Browse MCP Servers
  • Browse Marketplaces
  • Plugins Reference

Community

  • About
  • Tools
  • Feedback
  • Privacy Policy
  • Advertise

Built for the Claude Code community with Claude Code by mertbuilds.com

Independent project, not affiliated with Anthropic

Mcp Local Rag

shinpr/mcp-local-rag
307STDIOregistry active
Summary

Provides local semantic search across your technical documents and code through MCP tools for ingesting PDFs, DOCX, Markdown, and HTML content. Exposes query_documents, ingest_file, ingest_data, list_files, delete_file, and status operations to Claude and other MCP clients. Uses local embeddings with keyword boosting to catch exact technical terms like function names and error codes that pure semantic search might miss. Runs entirely offline after initial setup with no external API dependencies. Also works as a standalone CLI tool. Good for searching internal documentation, API specs, and codebases where you need both semantic understanding and exact term matching without sending data to third-party services.

CodeRabbit
CodeRabbit
AI writes the code. CodeRabbit catches the slop.
Try For Free →
Email for Agents: Free tier availableEmail for Agents: Free tier available
Email for Agents: Free tier available
Give your AI agent a complete email layer—sending, inbound inboxes, and sandbox testing.
Get 4K emails/month free →
Make your agent a DeFi expert
Make your agent a DeFi expert
Agent, run crypto. Access onchain data & trade routes via 1inch.
Install now →
AppSignal
AppSignal
Monitor with ease. Code with confidence.
Start Free Trial →
Capacitor - Shared memory for your team’s coding agents.
Capacitor - Shared memory for your team’s coding agents.
Capacitor makes coding agent sessions - Searchable, Shareable, Vendor-neutral & Scored.
Try For Free →
Give your AI the whole web as clean markdownGive your AI the whole web as clean markdown
Give your AI the whole web as clean markdown
Integrate web data into your AI product. One API to scrape website & brand data.
Get API Key Now →
belt - the only tool your agent needs
belt - the only tool your agent needs
belt cli automatically finds the best tools and skills for your agent. image, video, music, tts...
one prompt install →
inference shell
inference shell
create and run specialised agents in minutes
build now →
CodeRabbit
CodeRabbit
AI writes the code. CodeRabbit catches the slop.
Try For Free →
Email for Agents: Free tier availableEmail for Agents: Free tier available
Email for Agents: Free tier available
Give your AI agent a complete email layer—sending, inbound inboxes, and sandbox testing.
Get 4K emails/month free →
Make your agent a DeFi expert
Make your agent a DeFi expert
Agent, run crypto. Access onchain data & trade routes via 1inch.
Install now →
AppSignal
AppSignal
Monitor with ease. Code with confidence.
Start Free Trial →
Capacitor - Shared memory for your team’s coding agents.
Capacitor - Shared memory for your team’s coding agents.
Capacitor makes coding agent sessions - Searchable, Shareable, Vendor-neutral & Scored.
Try For Free →
Give your AI the whole web as clean markdownGive your AI the whole web as clean markdown
Give your AI the whole web as clean markdown
Integrate web data into your AI product. One API to scrape website & brand data.
Get API Key Now →
belt - the only tool your agent needs
belt - the only tool your agent needs
belt cli automatically finds the best tools and skills for your agent. image, video, music, tts...
one prompt install →
inference shell
inference shell
create and run specialised agents in minutes
build now →

MCP Local RAG — Search below the surface.

MCP Local RAG

GitHub stars npm version License: MIT MCP Registry

Search private documents from an MCP client or the terminal without sending them to an embedding API.

mcp-local-rag indexes PDF, DOCX, Markdown, and text files on your machine. Search combines semantic similarity with keyword matching, so queries can match both intent and exact technical terms such as API names, class names, and error codes.

Features

  • Runs locally — document parsing, embeddings, storage, and search run on your machine. After the initial model download, text ingestion and search work offline.
  • Hybrid search — semantic retrieval finds related concepts, while keyword matching boosts exact technical terms.
  • Semantic chunking — documents are split at topic boundaries instead of fixed character counts. Markdown code blocks stay intact.
  • MCP and CLI — use the same index from an AI coding tool or directly from the terminal.

No API key, Docker, Python, or external database is required.

Quick Start

Requirements

  • Node.js 22 or later
  • Internet access on first use to download the npm package and embedding model
  • A directory containing the documents you want to search

Set BASE_DIR to that directory. It is also the security boundary for file operations. Replace /absolute/path/to/your/documents below with the directory's absolute path.

mcp-local-rag uses the standard MCP protocol over a local stdio server, so it works with AI coding tools and other MCP hosts that support local MCP servers.

Use one of the examples below, or register npx -y mcp-local-rag and set BASE_DIR using your client's MCP configuration format.

For Claude Code — Run this command:

claude mcp add local-rag --scope user --env BASE_DIR=/absolute/path/to/your/documents -- npx -y mcp-local-rag

For Codex — Add to ~/.codex/config.toml:

[mcp_servers.local-rag]
command = "npx"
args = ["-y", "mcp-local-rag"]

[mcp_servers.local-rag.env]
BASE_DIR = "/absolute/path/to/your/documents"

For OpenCode — Add to ~/.config/opencode/opencode.json (or opencode.jsonc):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "local-rag": {
      "type": "local",
      "command": ["npx", "-y", "mcp-local-rag"],
      "environment": {
        "BASE_DIR": "/absolute/path/to/your/documents"
      }
    }
  }
}

For Cursor — Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "local-rag": {
      "command": "npx",
      "args": ["-y", "mcp-local-rag"],
      "env": {
        "BASE_DIR": "/absolute/path/to/your/documents"
      }
    }
  }
}

Restart the client, then ask it to build the index:

Sync all documents in the configured root and wait until it finishes.

The first sync downloads the default embedding model (about 90 MB) and may take 1–2 minutes before ingestion starts. Later runs use the local cache.

Once the sync completes:

What does the API documentation say about authentication?

CLI Quick Start

To use the CLI without an MCP client:

npx mcp-local-rag ingest ./docs/
npx mcp-local-rag query "authentication API"

The CLI uses the current directory as its document root by default. Run both commands from the same directory so they use the same default index, or set BASE_DIR and DB_PATH explicitly.

Why This Exists

Some document sets cannot be sent to a hosted embedding service because of confidentiality or organizational policy. Keeping the index local makes them searchable without adding a per-query API cost.

Semantic search alone can miss exact identifiers that matter in technical documentation. Keyword reranking keeps those terms visible without giving up natural-language retrieval.

Supported Content

InputHow to ingest
PDF, DOCX, TXT, MarkdownFile ingestion or directory sync
HTML already fetched by the clientingest_data; cleaned with Readability and converted to Markdown
Plain text or Markdown held in memoryingest_data with a stable source identifier

HTML fetching is not built into the server. An MCP client can fetch a page and pass its HTML to ingest_data.

Excel, PowerPoint, standalone images, and source-code file extensions are not supported by file ingestion. PDFs can optionally use a local vision model to describe figures, but this is not OCR or image search.

MCP Tools

ToolPurpose
sync_startReconcile the index with all configured roots or one path
sync_statusPoll a running sync job
ingest_fileIngest or replace one file
ingest_dataIngest text, Markdown, or HTML already held by the client
query_documentsSearch with semantic matching and keyword boost
read_chunk_neighborsRead surrounding chunks from a search result
list_filesShow supported files and their ingestion state
delete_fileDelete an indexed file or an ingest_data item
statusShow index and search status

Syncing a Document Root

sync_start ingests new and changed files, skips byte-identical files, and removes index entries for files that no longer exist:

Sync everything under the configured document roots and wait for completion.

The tool returns a jobId immediately. Clients should poll sync_status until its state becomes succeeded or failed. There is no visual mode during sync; changed PDFs are ingested as text.

Only one sync job is retained by the server process. A newer job replaces a finished record, and restarting the server discards it.

Ingesting One File

ingest_file accepts PDF, DOCX, TXT, and Markdown. MCP file paths must be absolute and must stay inside a configured document root:

Ingest the document at /Users/me/docs/api-spec.pdf.

Re-ingesting the same path replaces its existing chunks.

Searching and Reading More Context

What does the API documentation say about authentication?
Find the documented behavior of ERR_CONNECTION_REFUSED.

Results contain the text, source path, title, chunk index, and relevance score. Pass the chunkIndex and either filePath or source from a result to read_chunk_neighbors when the answer needs more context:

Read the surrounding chunks for that authentication result.

Both query_documents and list_files accept an optional absolute scope path prefix, or a list of prefixes. A prefix matches the exact path and its descendants.

Ingesting HTML

Use ingest_data after the MCP client fetches a page:

Fetch https://example.com/docs and ingest the HTML.

The server extracts the main article, converts it to Markdown, and stores it under the supplied source identifier. Reusing the same source updates the existing content.

Respect the source site's terms and copyright when indexing external content.

PDF Figures

Visual mode adds a generated caption for figure-heavy PDF pages. It is opt-in and does not load a vision model during normal ingestion.

Ingest /Users/me/docs/research-paper.pdf with visual: true.
npx mcp-local-rag ingest ./docs/research-paper.pdf --visual
ProfileModel cacheUse case
fast (default)about 250 MBLightweight visual indexing
qualityabout 2.9 GBFigures containing labels, annotations, or other in-image text

Select the larger model with visualQuality: "quality" over MCP or --visual-quality quality over CLI. Measured CPU inference was about twice as slow as fast, though results depend on hardware and model updates.

Captions are auxiliary text, not faithful transcriptions. Treat retrieved captions and document text as untrusted input rather than instructions.

CLI

The CLI uses the same parser, embedder, and vector store without an MCP client:

npx mcp-local-rag ingest ./docs/
npx mcp-local-rag sync ./docs/
npx mcp-local-rag query "authentication API"
npx mcp-local-rag query "auth" --scope /docs/api --scope /docs/guide
npx mcp-local-rag read-neighbors --file-path /abs/path.md --chunk-index 5
npx mcp-local-rag list
npx mcp-local-rag status
npx mcp-local-rag delete ./docs/old.pdf
npx mcp-local-rag delete --source "https://example.com/docs"

Global options such as --db-path, --cache-dir, and --model-name go before the subcommand. Subcommand options go after it:

npx mcp-local-rag --db-path ./my-db query "authentication"

Run npx mcp-local-rag --help for the complete command reference.

The CLI does not read MCP client configuration. Set the same environment variables or flags if both interfaces should share an index. In particular, MODEL_NAME and the CLI --model-name must match for a shared database.

Search Tuning

Keyword boost is enabled by default. Relevance-gap grouping and the distance and file filters are optional controls for corpora that need tighter result selection.

VariableDefaultDescription
RAG_HYBRID_WEIGHT0.6Keyword boost factor (0.0–1.0). 0 disables keyword reranking; 1 applies the maximum boost.
RAG_GROUPING(not set)similar keeps the first relevance group; related keeps up to two, using significant vector-distance gaps as boundaries.
RAG_MAX_DISTANCE(not set)Filter out low-relevance results (e.g., 0.5).
RAG_MAX_FILES(not set)Limit results to top N files (e.g., 1 for single best file).

For API specifications and other documents containing many identifiers, a stronger keyword weight can improve exact-term ranking:

"env": {
  "RAG_HYBRID_WEIGHT": "0.7"
}
  • 0.7 — slightly stronger exact-term reranking than the default
  • 1.0 — maximum keyword boost

How It Works

During ingestion:

  1. The parser extracts text for the input format.
  2. The semantic chunker finds topic boundaries and preserves Markdown code blocks.
  3. Transformers.js creates embeddings locally.
  4. LanceDB stores the chunks, metadata, vectors, and full-text index.

During search:

  1. The query is embedded with the same model.
  2. Vector search retrieves semantically related chunks.
  3. Optional distance and relevance-group filters narrow the candidates when configured.
  4. Full-text matches boost exact query terms.

Agent Skills

Agent Skills provide query and ingestion guidance for AI assistants:

npx mcp-local-rag skills install --claude-code
npx mcp-local-rag skills install --claude-code --global
npx mcp-local-rag skills install --codex

Installed skills cover query formulation, result refinement, and HTML ingestion. Ask the assistant to use the mcp-local-rag skill explicitly if it does not activate automatically.

Configuration

The MCP server reads environment variables. The CLI accepts the same variables plus the listed flags, with CLI flags taking precedence.

Environment VariableCLI FlagDefaultDescription
BASE_DIR--base-dirCurrent directoryOne document root; the CLI flag is repeatable on ingest and list
BASE_DIRS—(unset)JSON array of document roots; takes precedence over BASE_DIR
DB_PATH--db-path./lancedb/Vector database location
CACHE_DIR--cache-dir./models/Model cache directory
MODEL_NAME--model-nameXenova/all-MiniLM-L6-v2Hugging Face embedding model
MAX_FILE_SIZE--max-file-size104857600 (100MB)Maximum file size in bytes
CHUNK_MIN_LENGTH--chunk-min-length50Minimum chunk length in characters (1–10000)
RAG_DEVICE—cpuONNX Runtime execution device
RAG_DTYPE—fp32Embedding dtype supplied by the selected model

Document Roots (BASE_DIR and BASE_DIRS)

mcp-local-rag only allows file operations inside configured roots. For multiple roots, BASE_DIRS must be a JSON array of non-empty paths:

export BASE_DIRS='["/Users/me/Documents/work","/Users/me/Projects/specs"]'

Root configuration is resolved in this order:

  1. CLI --base-dir <path> flags (repeatable on ingest and list)
  2. BASE_DIRS
  3. BASE_DIR
  4. Current directory

Each source replaces the lower-priority source rather than merging with it. Invalid BASE_DIRS configuration fails instead of falling back to BASE_DIR or the current directory. status remains available in MCP so the client can report the configuration error.

npx mcp-local-rag ingest --base-dir /Users/me/work --base-dir /Users/me/specs /Users/me/work/readme.md
npx mcp-local-rag list --base-dir /Users/me/work --base-dir /Users/me/specs
BASE_DIRS='["/Users/me/work","/Users/me/specs"]' npx mcp-local-rag list

Storage and Models

DB_PATH and CACHE_DIR are relative to the process working directory by default. Set absolute paths when the MCP client may start the server from different project directories.

Changing MODEL_NAME, RAG_DEVICE, or RAG_DTYPE can make existing vectors incompatible. Use a new DB_PATH or delete the existing index and re-ingest after changing the embedding configuration.

Model examples:

  • Multilingual documents: onnx-community/embeddinggemma-300m-ONNX
  • Scientific papers: sentence-transformers/allenai-specter

Security and Operation

  • File access is restricted to BASE_DIR, BASE_DIRS, or CLI --base-dir roots.
  • Symlinks that resolve outside every configured root are rejected.
  • Document processing and search make no network requests after the required models are cached.
  • The server is designed for one local user and does not provide authentication or access control.
  • Do not run multiple CLI or MCP writers against the same DB_PATH. Read-only queries can run while a sync is active.
  • Back up an index by copying its DB_PATH directory while no writer is active.
Troubleshooting

"No results found"

Documents must be ingested first. Run "List all ingested files" to verify.

Model download failed

Check internet connection. If behind a proxy, configure network settings. The model can also be downloaded manually.

"File too large"

Default limit is 100MB. Split large files or increase MAX_FILE_SIZE.

Slow queries

Check chunk count with status. Large documents with many chunks may slow queries. Consider splitting very large files.

"Path outside BASE_DIR"

Ensure file paths are within one of the configured roots (BASE_DIR, any BASE_DIRS entry, or any CLI --base-dir). Use absolute paths.

"BASE_DIRS must be a JSON array..."

BASE_DIRS accepts a JSON array of one or more non-empty path strings:

  • Valid: BASE_DIRS='["/Users/me/work","/Users/me/specs"]'
  • Invalid: BASE_DIRS=/a:/b (delimiter syntax not supported)
  • Invalid: BASE_DIRS='[]' (empty array)

MCP client doesn't see tools

  1. Verify config file syntax
  2. Restart client completely (Cmd+Q on Mac for Cursor)
  3. Test directly: npx mcp-local-rag should run without errors

Contributing

Contributions welcome! See CONTRIBUTING.md for setup and guidelines.

License

MIT License. Free for personal and commercial use.

Blog Posts

  • Building a Local RAG for Agentic Coding — Technical deep-dive into the semantic chunking and hybrid search design.

Acknowledgments

Built with Model Context Protocol by Anthropic, LanceDB, and Transformers.js.

Featured
CodeRabbit
CodeRabbit
AI writes the code. CodeRabbit catches the slop.
Try For Free →
Email for Agents: Free tier availableEmail for Agents: Free tier available
Email for Agents: Free tier available
Give your AI agent a complete email layer—sending, inbound inboxes, and sandbox testing.
Get 4K emails/month free →
Make your agent a DeFi expert
Make your agent a DeFi expert
Agent, run crypto. Access onchain data & trade routes via 1inch.
Install now →
AppSignal
AppSignal
Monitor with ease. Code with confidence.
Start Free Trial →
Capacitor - Shared memory for your team’s coding agents.
Capacitor - Shared memory for your team’s coding agents.
Capacitor makes coding agent sessions - Searchable, Shareable, Vendor-neutral & Scored.
Try For Free →
Give your AI the whole web as clean markdownGive your AI the whole web as clean markdown
Give your AI the whole web as clean markdown
Integrate web data into your AI product. One API to scrape website & brand data.
Get API Key Now →
belt - the only tool your agent needs
belt - the only tool your agent needs
belt cli automatically finds the best tools and skills for your agent. image, video, music, tts...
one prompt install →
inference shell
inference shell
create and run specialised agents in minutes
build now →

Configuration

BASE_DIR

Base directory for document storage (defaults to current working directory). Ignored when BASE_DIRS is set.

BASE_DIRS

JSON array of base directories (e.g. '["/a","/b"]'). Takes precedence over BASE_DIR.

DB_PATH

Path to LanceDB database directory (defaults to ./lancedb/)

CACHE_DIR

Directory where Transformers.js models are cached (defaults to ./models/)

MODEL_NAME

Embedding model name (defaults to Xenova/all-MiniLM-L6-v2)

MAX_FILE_SIZE

Maximum file size in bytes (defaults to 104857600 / 100MB)

RAG_MAX_DISTANCE

Maximum distance threshold for filtering search results. Results with distance greater than this value will be excluded. Lower values mean stricter filtering (e.g., 0.5 for high relevance only)

RAG_GROUPING

Grouping mode for quality filtering. 'similar' returns only the most similar group (stops at first distance jump). 'related' includes related groups (stops at second distance jump). Unset means no grouping filter

RAG_MAX_FILES

Maximum number of files to keep in search results. Results are filtered to include only chunks from the top N best-scoring files. For example, 1 returns only the single best-matching file's chunks. Unset means no file filtering.

CHUNK_MIN_LENGTH

Minimum chunk length in characters (1-10000, defaults to 50). Chunks shorter than this threshold are filtered out during ingestion.

RAG_DEVICE

Execution device for the embedder (defaults to cpu). Passed straight to ONNX Runtime; see the Transformers.js device source for the supported backend names. If the requested device fails to initialize, the server throws an error.

RAG_HYBRID_WEIGHT

Keyword boost factor for hybrid search (0.0-1.0, defaults to 0.6). 0 means semantic similarity only; higher values increase the keyword-match contribution to the final score.

Categories
AI & LLM Tools
Registryactive
Packagemcp-local-rag
TransportSTDIO
UpdatedJun 7, 2026
View on GitHub

Related AI & LLM Tools MCP Servers

View all →
SkillFM LLM Cost Optimizer

io.github.ericm1018/skillfm-llm-cost-optimizer-openai-anthropic-usage

LLM cost optimizer for OpenAI, Anthropic, token usage, BYOK, and SkillFM Beacon audits.
Llm Orchestration Agent

io.github.mikerawsonnz/llm-orchestration-agent

Run a prompt through a LangChain (system + human) chain over Gemini on Vertex AI; optional LangSmith
Authenticated Llm Agent

io.github.mikerawsonnz/authenticated-llm-agent

JWT-gated LLM gateway: authenticate (bcrypt/JWT), then run a LangChain-on-Vertex Gemini completion.
Copilot Memory MCP

labforgedev/copilot-memory-mcp

Persistent semantic memory for AI agents using local ChromaDB vector search. No cloud required.
1
Agent Prompt Injection Firewall Mcp

csoai-org/agent-prompt-injection-firewall-mcp

The WAF for agents. Pattern-based + heuristic firewall scans prompts, RAG documents, tool argume...
Authenticated Multi Llm Agent

io.github.mikerawsonnz/authenticated-multi-llm-agent

Google-OAuth-gated LLM gateway: verify a Google ID token, then run a Gemini (Vertex AI) completion f