MCP Local RAG
يتيح لوكيل الذكاء الاصطناعي البحث في ملفات PDF وWord وMarkdown والنصوص الخاصة بك محليًا، دون إرسالها إلى واجهة تضمين عبر الإنترنت.
429 نجمة على GitHubمن shinprالترخيص MITآخر تحديث قبل 28 يومًا
طريقة التثبيت
هذا MCP محلي: يعمل على جهازك.
يعمل في التطبيقات المثبّتة على حاسوبك (Claude Desktop وClaude Code وCursor وVS Code…). اختر تطبيقك:
الصق في الطرفية:
claude mcp add local-rag -- npx -y mcp-local-rag
ما الذي تملؤه
| الاسم | ما هو | مطلوب |
|---|---|---|
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. | لا |
IGNORE_PATHS | JSON 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_PATH | Path to LanceDB database directory (defaults to ./lancedb/) | لا |
CACHE_DIR | Directory where Transformers.js models are cached (defaults to ./models/) | لا |
HF_ENDPOINT | Hugging Face model download endpoint. Set this to a mirror URL when direct downloads are blocked (defaults to https://huggingface.co). | لا |
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. | لا |
STORE_IMAGES | Store supported PDF and DOCX images during ingestion and return them with matched chunks (defaults to false). | لا |
EMBED_TITLE_PREFIX | Embed 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_PREFIX | Add section headings to chunk embeddings when they fit (defaults to false). Independent of EMBED_TITLE_PREFIX. Re-ingest documents after changing it. | لا |
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_DTYPE | Embedding 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_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. | لا |
RAG_RERANK_CMD | External reranker command template. Use {query} and {top} for query text and result count; unset disables reranking. | لا |
RAG_RERANK_TIMEOUT_MS | Time 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: إضافة ملف أو استبدالهingest_data: إضافة نص أو Markdown أو HTML يحتفظ به العميلquery_documents: البحث بالمعنى ومطابقة الكلمات المفتاحيةread_chunk_neighbors: قراءة النص المحيط بنتيجةlist_files: عرض الملفات وحالة فهرستهاdelete_file: حذف ملف مفهرس
متى تستخدمه
- ›عندما تريد أن تسأل عن مجلد من المستندات الخاصة
- ›عندما تحتاج إلى مطابقات دقيقة مثل رموز الأخطاء وأسماء الواجهات البرمجية، إلى جانب البحث بالمعنى
- ›عندما تريد إجابات مع أرقام الصفحات أو الأسطر لتتحقق من المصدر
ما الذي تحتاجه
مهارات تتكامل معه
MCP أم مهارة؟
يمنح MCP الوكيل اليدين. وتعلّمه المهارة الطريقة الصحيحة لاستخدامهما. معًا تكون النتيجة أفضل وتستهلك رموزًا أقل.
google-cloud-solution-rag-enterprise-search-gke-sqldbيصمم نظام بحث مؤسسي خاصًا يجيب عن الأسئلة من مستنداتك، باستخدام متجهات AlloyDB ونموذج مفتوح وGKE.xerj-knowledgeيساعد وكيلك على البحث في ملفاتك المحلية، مثل الملاحظات وPDF والجداول والبريد، ويذكر الملف والصفحة التي جاءت منها كل إجابة.doc-readerيتيح لوكيلك قراءة النصوص من ملفات PDF وWord وExcel وعروض PowerPoint والصور وأنواع مستندات أخرى كثيرة، من خلال أداة واحدة.الأسئلة الشائعة
هل تُرسل بياناتي إلى السحابة؟
لا. لا يستخدم واجهة تضمين عبر الإنترنت، وبعد تنزيل النموذج يعمل دون إنترنت.
ما الملفات المدعومة؟
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 على مسارات مطلقة حتى لا ينشئ كل مشروع فهرسه الخاص
- ›قد تستغرق المزامنة الأولى من دقيقة إلى دقيقتين أثناء تنزيل النموذج
- ›إذا كانت تنزيلات Hugging Face محجوبة، فاضبط HF_ENDPOINT على عنوان مرآة
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.