Skip to main content
Glama
timid2020-dot

DocScan MCP Server

README.md
# DocScan MCP Server

DocScan is a Model Context Protocol (MCP) server that allows you to scan, index, and search through your local documents using advanced document understanding (via Docling) and local vector search.

## Features

- **Multi-format Support**: Parses PDF, DOCX, PPTX, XLSX, HTML, Markdown, and more.
- **Image Support (Performance-first)**: OCRs standalone images and selectively OCRs weak/empty-text PDF pages.
- **Advanced PDF Parsing**: Uses [Docling](https://github.com/DS4SD/docling) for high-fidelity document understanding, including tables and complex layouts.
- **Vector Search**: Indexes document chunks into a local persistent vector index for semantic search.
- **Asynchronous Indexing**: Decouples indexing from searching to prevent timeouts on large document sets.
- **MCP Integration**: Exposes `search_docs` and `reindex_docs` tools.

## Setup

### Prerequisites

- Python (preferably 3.14)
- `uv` (recommended for dependency management)

### Installation

1. Clone this repository.
2. Install dependencies:
   ```bash
   uv sync
   ```
3. Put `uv run src/main.py` in your MCP config

Example for Copilot:

```json
{
  "mcpServers": {
    "docscan": {
      "type": "stdio",
      "command": "uv",
      "args": ["--directory", "/absolute/path/to/docscan", "run", "src/main.py"]
    }
  }
}
```

### Adding Documents

Place the documents you want to index into the `store/` directory. Supported formats include:

- `.pdf`, `.docx`, `.pptx`, `.xlsx`
- `.md`, `.txt`, `.html`
- `.png`, `.jpg`, `.jpeg` (via OCR)

## Usage

### Running the Server

You can run the server directly:

```bash
uv run src/main.py
```

Or via fastmcp

```bash
fastmcp run src/main.py --transport http --port 8001 --host 0.0.0.0
```

(change transport and arguments to taste)

### Indexing Documents

Before you can search, you must build the index. Use the `reindex_docs` tool from your MCP client. This only needs to be done once or when you add/change files.
**Note**: Large documents (like some PDFs) may take a few minutes to process.

`reindex_docs` is incremental: it persists a manifest (`vectorstore.db.manifest.json`) and only reprocesses files whose size/mtime changed, reuses unchanged chunks and embeddings, and removes deleted files from the index.