Skip to main content
Glama
zero-trust-mcp-pdf

zero-trust-mcp-pdf

README.md
[![CI](https://github.com/FrederikOuvrard/zero-trust-mcp-pdf/actions/workflows/ci.yml/badge.svg)](https://github.com/FrederikOuvrard/zero-trust-mcp-pdf/actions/workflows/ci.yml)
![Python 3.12](https://img.shields.io/badge/python-3.12-blue.svg)
![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)
# zero-trust-mcp-pdf

A security-first, strictly read-only **Model Context Protocol (MCP)** server for querying local PDF corpora with Claude Desktop and Claude Code — without exposing raw filesystem access, network egress, or raw untrusted text to the model.

## Security Model & Guarantees

Most local-file MCP servers grant broad filesystem access or inject raw extracted text directly into the LLM context. `zero-trust-mcp-pdf` enforces a fail-closed boundary:

- **Strict Read-Only & Stdio-Only:** Runs exclusively over `stdio` with zero network access, no shell execution, and no write operations.
- **Minimal Tool Surface:** Exposes only two bounded tools:
  - `search_corpus` — full-text search over the pre-indexed SQLite FTS5 corpus.
  - `get_passage` — bounded excerpt retrieval by document/page reference.
- **Hardcoded Root Whitelist:** Prevents path traversal and arbitrary file reads outside the configured corpus directory.
- **Verifiable Provenance:** Deterministic multi-pass ingestion (PyMuPDF + Tesseract OCR), streaming SHA-256 integrity checks, and HMAC-signed search/pagination receipts (`corpus-these-search-receipt/1.0`).
- **Prompt Injection Defense:** Every returned passage is wrapped in `<untrusted_context>` tags to isolate document content from system instructions.

## Installation

Requires Python 3.12+.

```bash
git clone https://github.com/FrederikOuvrard/zero-trust-mcp-pdf.git
cd zero-trust-mcp-pdf
python -m venv .venv
source .venv/bin/activate  # Windows: .\.venv\Scripts\Activate.ps1
pip install -e ".[dev]"
```

## Configuration

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "zero-trust-pdf": {
      "command": "python",
      "args": ["-m", "corpus_these.server"],
      "env": {
        "MCP_CORPUS_ROOT": "/path/to/your/indexed/corpus"
      }
    }
  }
}
```

*(Adjust `-m corpus_these.server` and `MCP_CORPUS_ROOT` if your entrypoint or environment variable name differs.)*

## Development & Testing

```bash
ruff check .
pytest
```

## License

MIT License — see [LICENSE](LICENSE).

## Roadmap

- **Configurable storage roots:** Remove the hardcoded `D:\` volume constraint via explicit configuration.
- **Cross-platform support:** Extend fail-closed file-handle locking and path validation to Linux and macOS.
- **Hybrid retrieval:** Add optional local vector search alongside SQLite FTS5 while preserving deterministic citation receipts.
- **Security hardening:** Publish formal threat-model tests and automated fuzzing for malformed PDFs and FTS5 queries.