本文へスキップ
Skillpedia
● 無料・オープンソース💻 ローカル🔓 APIキー不要データとデータベース

MCP Local RAG

AIエージェントが、自分のPDF、Word、Markdown、テキストのファイルを、埋め込みAPIに送らずに、ローカルで検索できるようにします。

429 GitHubのスター作者 shinprライセンス MIT更新 19 日前

導入方法

このMCPはローカル型です。あなたのパソコンで動きます。

パソコンに入れたアプリ(Claude Desktop、Claude Code、Cursor、VS Codeなど)で使えます。アプリを選んでください:

ターミナルに貼り付け:

claude mcp add local-rag -- npx -y mcp-local-rag

入力するもの

名前内容必須
BASE_DIRBase directory for document storage (defaults to current working directory). Ignored when BASE_DIRS is set.いいえ
BASE_DIRSJSON array of base directories (e.g. '["/a","/b"]'). Takes precedence over BASE_DIR.いいえ
IGNORE_PATHSJSON array of glob patterns for files to keep out of the index, each matched against the file's path relative to its root (e.g. '["plugs/**","**/*.draft.md"]').いいえ
DB_PATHPath to LanceDB database directory (defaults to ./lancedb/)いいえ
CACHE_DIRDirectory where Transformers.js models are cached (defaults to ./models/)いいえ
HF_ENDPOINTHugging Face model download endpoint. Set this to a mirror URL when direct downloads are blocked (defaults to https://huggingface.co).いいえ
MODEL_NAMEEmbedding model name (defaults to Xenova/all-MiniLM-L6-v2)いいえ
MAX_FILE_SIZEMaximum file size in bytes (defaults to 104857600 / 100MB)いいえ
RAG_MAX_DISTANCEMaximum 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_GROUPINGGrouping 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_FILESMaximum 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_LENGTHMinimum chunk length in characters (1-10000, defaults to 50). Chunks shorter than this threshold are filtered out during ingestion.いいえ
STORE_IMAGESStore supported PDF and DOCX images during ingestion and return them with matched chunks (defaults to false).いいえ
EMBED_TITLE_PREFIXEmbed each chunk together with its document title, which can help when passages don't restate the topic the title names (defaults to false). After changing it, use a new DB_PATH or delete the index and re-ingest.いいえ
EMBED_HEADING_PREFIXAdd section headings to chunk embeddings when they fit (defaults to false). Independent of EMBED_TITLE_PREFIX. Re-ingest documents after changing it.いいえ
RAG_DEVICEExecution 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_DTYPEEmbedding quantization dtype for the embedder (defaults to fp32). Opt-in and pass-through; accepts any dtype the chosen model provides (fp32, fp16, q8, int8, ...). If the model has no variant for the requested dtype, the server throws an error. Changing this changes the embedding space — re-ingest existing data.いいえ
RAG_HYBRID_WEIGHTKeyword 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.いいえ
RAG_RERANK_CMDExternal reranker command template. Use {query} and {top} for query text and result count; unset disables reranking.いいえ
RAG_RERANK_TIMEOUT_MSTime budget per rerank call in milliseconds (100-600000, defaults to 10000). On timeout the spawned command is killed and the pre-rerank ordering is returned.いいえ

準備完了!試してみましょう

アプリを再起動して、次のどれかをチャットに貼ってください:

設定されたフォルダーのすべての文書を同期して、終わったら教えてください。
APIのドキュメントは、認証について何と書いていますか?

概要

このサーバーは、お使いのパソコン上で文書にインデックスを作り、意味と完全一致のキーワードの両方で検索します。結果には、元の一節と、可能な場合は見出し、行番号、ページ番号が含まれます。モデルを最初にダウンロードした後は、インデックスの作成と検索はオフラインで動きます。

できること

  • sync_start: インデックスを、お使いのフォルダーと同じ最新の状態にします
  • sync_status: 実行中の同期を確認します
  • ingest_file: 1つのファイルを追加または置き換えます
  • ingest_data: クライアントが持つテキスト、Markdown、HTMLを追加します
  • query_documents: 意味とキーワードの一致で検索します
  • read_chunk_neighbors: 結果の前後のテキストを読みます
  • list_files: ファイルと、そのインデックスの状態を表示します
  • delete_file: インデックス化されたファイルを削除します

使う場面

  • ›プライベートな文書のフォルダーについて、質問したいとき
  • ›エラーコードやAPI名などの完全一致と、意味による検索の両方が必要なとき
  • ›ページや行の参照付きで、出典を確認できる回答が欲しいとき

必要なもの

Node.js 22.20以降と、BASE_DIRに設定した文書のフォルダーが必要です。パッケージと約90MBの埋め込みモデルを、初回にダウンロードするためにインターネットが必要です。APIキー、Docker、Pythonは不要です。

相性のいいスキル

⭐ Skillpedia MCP · 無料エージェントが自分で最適なスキルを見つけます当サイトのMCPを入れると、必要なときにエージェントが15,000+件のスキルから探します。無料で導入 →

よくある質問

データはクラウドに送られますか?

いいえ。埋め込みのAPIは使わず、モデルをダウンロードした後はオフラインで動きます。

どのファイルに対応していますか?

PDF、DOCX、TXT、Markdown、そしてクライアントが渡すHTMLまたはテキストです。Excel、PowerPoint、画像、ソースコードのファイルは対応していません。

APIキーは必要ですか?

いいえ。APIキー、Docker、Python、外部のデータベースは不要です。

コマンドラインはありますか?

はい。npx mcp-local-rag ingest、query、sync、list、status、deleteを使えます。

ファイルへのアクセスはどのように制限されていますか?

BASE_DIRがファイル操作のセキュリティの境界で、MCPのファイルパスは絶対パスで、設定されたルートの中になければなりません。

モデルを変えられますか?

はい。MODEL_NAMEで変更できます。モデルを変えたら、新しいDB_PATHで新しいインデックスを作ってください。

うまく動かないとき

  • ›プロジェクトごとにインデックスが作られないように、BASE_DIR、DB_PATH、CACHE_DIRを絶対パスに設定してください。
  • ›最初の同期には、モデルのダウンロードのため1〜2分かかることがあります。
  • ›Hugging Faceのダウンロードがブロックされている場合は、HF_ENDPOINTにミラーのURLを設定してください。

毎週5つの新しいスキル。1分で読めます。