docprov-mcp
Deterministic PDF & Markdown Citation Provenance Verification MCP Server, CLI, and Agent Skill.
docprov-mcp gives AI coding agents, RAG pipelines, and evaluation suites an auditable verification layer that checks whether generated claims, numbers, and page citations actually appear in the source PDF or Markdown file—without relying on another LLM call.
Why docprov-mcp?
RAG systems and LLM assistants frequently hallucinate wrong page numbers or subtle numeric distortions (e.g., citing 18.4% when page 12 reports 14.8%). docprov-mcp solves this with fast, deterministic provenance checks:
- Exact & Lexical Verification: Combines normalized verbatim substring checks with sentence/window overlap scoring.
- Strict Numeric Guardrails: Extracts numbers, percentages, currencies, and years from every claim and flags
missing_numbersso numeric hallucinations never pass silently. - Page Mismatch Detection: Distinguishes
verified,page_mismatch(points you to the truematched_page),partial_match, andnot_found. - PDF & Printed Page Awareness: Captures 1-based
pdf_pageindices alongside/PageLabelsor header/footerprinted_pagenumbers. - CI-Ready CLI + Stdio MCP Server + Companion Agent Skill: Run locally from any MCP client (Qoder, Claude Desktop, Cursor) or enforce
--strictquality gates in automated tests.
Architecture
flowchart LR
Doc["PDF / Markdown / Text"] --> Loader["load_document() + SHA-256 + Page Labels"]
Loader --> Index["DocumentIndex (PageRecord[])"]
Index --> Search["search_document() (BM25 + Phrase Boost)"]
Index --> Verify["verify_citation() (Lexical + Numeric Gate)"]
Verify --> Audit["audit_citations() -> ProvenanceReport"]
Search --> MCP["MCPServer (docprov-mcp)"]
Verify --> MCP
Audit --> MCP
Audit --> CLI["CLI Quality Gate (docprov)"]
Installation
Using uv (recommended):
uv tool install docprov-mcp
# or run from source:
uv sync --extra dev
Using pip:
pip install docprov-mcp
Quick Start (MCP Server)
Add docprov-mcp to your MCP client configuration (works with Qoder, Claude Desktop, Cursor, or any stdio MCP host).
Using uvx
{
"mcpServers": {
"docprov": {
"command": "uvx",
"args": ["docprov-mcp"]
}
}
}
Running from a local clone
{
"mcpServers": {
"docprov": {
"command": "uv",
"args": ["--directory", "/path/to/docprov-mcp", "run", "docprov-mcp"]
}
}
}
Exposed MCP Tools & Prompts
| Type | Name | Purpose |
|---|---|---|
| Tool | inspect_document |
Inspect file type, SHA-256 fingerprint, total pages, and printed page labels |
| Tool | extract_pages |
Extract verbatim text for a 1-based inclusive page range |
| Tool | search_document |
BM25-inspired ranking with page-anchored snippets and character offsets |
| Tool | verify_citation |
Verify a claim (and optional cited_page), catching mismatches and missing numbers |
| Tool | audit_citations |
Batch-audit a list of citations and compute overall pass_rate |
| Prompt | grounded_qa_workflow |
Structured agent workflow enforcing verification before final answers |
CLI Usage & CI Quality Gates
Inspect a document
docprov inspect ./annual_report.pdf --json
Search for evidence
docprov search ./annual_report.pdf "operating margin" --top-k 3
Extract specific pages
docprov extract ./annual_report.pdf --pages 12-13
Verify a single claim (exit code 0 if verified, 2 otherwise)
docprov verify ./annual_report.pdf \
--claim "Operating margin improved to 18.4% in FY2025." \
--page 12 \
--json
Batch audit citations in CI
Given claims.json:
[
{"claim": "Operating margin improved to 18.4% in FY2025.", "cited_page": 12},
{"claim": "Total capital expenditure reached USD 42M.", "cited_page": 14}
]
Run:
docprov audit ./annual_report.pdf --citations ./claims.json --format markdown --strict
Companion Agent Skill
This repository also ships a portable Agent Skill at skills/docprov-verification/SKILL.md that instructs AI coding and research agents to run inspect_document -> search_document -> extract_pages -> audit_citations before answering questions from documents.
Development
git clone https://github.com/afiffathin31/docprov-mcp.git
cd docprov-mcp
uv sync --extra dev
uv run ruff check src tests
uv run pytest -v
uv build
Roadmap
- v0.1.0 (Current): Deterministic PDF/Markdown/Text loader, SHA-256 provenance, BM25 search, numeric & page-mismatch verification, stdio MCP server, CLI quality gates, Agent Skill.
- v0.2.0 (Planned): Table cell coordinate verification, optional OCR/Docling JSON adapter, SARIF/JUnit audit export for CI pipelines, and PyPI Trusted Publishing.
License
MIT License — see LICENSE.
Metadata
Release files for docprov-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| docprov_mcp-0.1.0.tar.gz | 98.6 kB | Without provenance | Details for docprov_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docprov_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for docprov_mcp-0.1.0-py3-none-any.whl |
Total release size: 116.2 kB
Release files / docprov_mcp-0.1.0.tar.gz
| Download URL | docprov_mcp-0.1.0.tar.gz |
|---|---|
| Size | 98.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba031f676c520b24df6b039290d26e4b771465d7230e3552fff8f16119d08818
|
|
BLAKE2b-256 checksum How to use checksums |
20a2d21210a0da6fd48ea1cbd5507a1f1de95e44a9d86ab7c612b67b93e6ce3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / docprov_mcp-0.1.0-py3-none-any.whl
| Download URL | docprov_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e47c25fde0c00df974539b130866a95cc2703d1cdcae8149abc61d7a1bebec8c
|
|
BLAKE2b-256 checksum How to use checksums |
db6fa70045d4e81299960469f3d2ccb6d1b9b424cc5ccf724a1b49e24954d9f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for docprov-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.