YD

yairwein/document-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

22 stars 6 forks 质量 58 趋势 0MIT

MCP服务器用于访问本地文档

概览

基于Python的MCP(模型上下文协议)服务器,用于本地文档索引和搜索,使用LanceDB矢量数据库和本地LLM进行检索。 - : 自动索引配置文件夹中的新文档和修改文档 - : 处理PDF、Word(docx/doc)、文本、Markdown和RTF文件 - : 使用Ollama进行文档摘要和关键词提取。你的电脑永远不会有东西离开 - : 使用LanceDB和句子变换器进行语义搜索 - : 通过Model Context Protocol暴露搜索和目录工具 - : 仅处理修改文件以节省资源 - : 设计为标准笔记本(如M1/M2 MacBook)上的良好性能 使用环境变量或 .env 文件配置索引器: 添加到你的Claude桌面配置中(~/Library/Application Support/Claude/claude_desktop_config.json): 索引器通过MCP暴露以下工具: 使用自然语言查询搜索文档。

概述(AI 翻译)

基于Python的MCP(模型上下文协议)服务器,用于本地文档索引和搜索,使用LanceDB矢量数据库和本地LLM进行检索。

特色

  • 实时文档监控:自动索引配置文件夹中的新文档和修改文档
  • 多格式支持:支持PDF、Word(docx/doc)、文本、Markdown和RTF文件
  • 本地LLM集成:使用Ollama进行文档摘要和关键词提取。你的电脑永远不会有东西流出
  • 向量搜索:使用LanceDB和句子变换器进行语义搜索
  • MCP 集成:通过模型上下文协议(Model Context Protocol)暴露搜索和目录工具
  • 增量索引:只有进程会更改文件以节省资源
  • 性能优化:设计用于标准笔记本(如M1/M2 MacBook)上的良好性能

安装

先决条件

  1. Python 3.9+ 已安装

  2. uv 包管理器:

  3. Ollama(针对本地LLM):

安装MCP文档索引器

配置

使用环境变量或 .env 文件配置索引器:

用途

作为独立服务运行

与Claude Desktop集成

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Document Indexer

A Python-based MCP (Model Context Protocol) server for local document indexing and search using LanceDB vector database and local LLMs.

Features

  • Real-time Document Monitoring: Automatically indexes new and modified documents in configured folders
  • Multi-format Support: Handles PDF, Word (docx/doc), text, Markdown, and RTF files
  • Local LLM Integration: Uses Ollama for document summarization and keyword extraction. Nothing ever leaves your computer
  • Vector Search: Semantic search using LanceDB and sentence transformers
  • MCP Integration: Exposes search and catalog tools via Model Context Protocol
  • Incremental Indexing: Only processes changed files to save resources
  • Performance Optimized: Designed for decent performance on standard laptops (e.g. M1/M2 MacBook)

Installation

Prerequisites

  1. Python 3.9+ installed
  2. uv package manager:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Ollama (for local LLM):
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Pull a model (e.g., llama3.2)
ollama pull llama3.2:3b

Install MCP Document Indexer

# Clone the repository
git clone https://github.com/yairwein/mcp-doc-indexer.git
cd mcp-doc-indexer

# Install with uv
uv sync

# Or install as a package
uv add mcp-doc-indexer

Configuration

Configure the indexer using environment variables or a .env file:

# Folders to monitor (comma-separated)
WATCH_FOLDERS="/Users/me/Documents,/Users/me/Research"

# LanceDB storage path
LANCEDB_PATH="./vector_index"

# Ollama model for summarization
LLM_MODEL="llama3.2:3b"

# Text chunking settings
CHUNK_SIZE=1000
CHUNK_OVERLAP=200

# Embedding model (sentence-transformers)
EMBEDDING_MODEL="all-MiniLM-L6-v2"

# File types to index
FILE_EXTENSIONS=".pdf,.docx,.doc,.txt,.md,.rtf"

# Maximum file size in MB
MAX_FILE_SIZE_MB=100

# Ollama API URL
OLLAMA_BASE_URL="http://localhost:11434"

Usage

Run as Standalone Service

# Set environment variables
export WATCH_FOLDERS="/path/to/documents"
export LANCEDB_PATH="./my_index"

# Run the indexer
uv run python -m src.main

Integrate with Claude Desktop

Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "doc-indexer": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/path/to/mcp-doc-indexer",
        "python",
        "-m",
        "src.main"
      ],
      "env": {
        "WATCH_FOLDERS": "/Users/me/Documents,/Users/me/Research",
        "LANCEDB_PATH": "/Users/me/.mcp-doc-index",
        "LLM_MODEL": "llama3.2:3b"
      }
    }
  }
}

MCP Tools

The indexer exposes the following tools via MCP:

search_documents

Search for documents using natural language queries.

  • Parameters:
    • query: Search query text
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "doc-indexer": { "command": "uv", "args": [ "run", "--directory", "/path/to/mcp-doc-indexer", "python", "-m", "src.main" ], "env": { "WATCH_FOLDERS": "/Users/me/Documents,/Users/me/Research", "LANCEDB_PATH": "/Users/me/.mcp-doc-index", "LLM_MODEL": "llama3.2:3b" } } } }