DocLens
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@DocLens read quarterly-report.pdf and pull the revenue table with exact decimals"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
DocLens
给 AI 编程 agent 的高保真文档读取器。
Claude Code、Codex、Cursor 这类 agent 读 PDF 和 Excel 时会出错,而且错得很安静:表格被压成一条文本流,列关系丢失;金额经过 float 往返,精度掉了;多栏排版的左右栏交错读出;扫描件被当成空文档。
DocLens 是一个 MCP 服务,把这些读完再交给 agent——表格按行列对齐,金额保留原始精度,公式单独标出,有损的地方明确告诉你。
为什么需要它
用 pdftotext 读同一份财务报表,你得到的是:
Enterprise 8,450,000.00 12.4% Consumer 3,120,500.00 -3.8% Overseas 1,980,000.00 24.1%用 DocLens:
| Division | Revenue | YoY |
|---|---|---|
| Enterprise | 8,450,000.00 (`8450000.00`) | 12.4% (`12.4`) |
| Consumer | 3,120,500.00 (`3120500.00`) | -3.8% (`-3.8`) |
| Overseas | 1,980,000.00 (`1980000.00`) | 24.1% (`24.1`) |前者让 agent 猜哪个数字属于哪一行,后者直接告诉它。
Related MCP server: okraPDF PDF MCP server
安装
pip install doclens-mcp或者直接从 GitHub 安装(PyPI 未发布时用这条):
pip install git+https://github.com/fendoushaonian/doclens从源码开发:
git clone https://github.com/fendoushaonian/doclens
cd doclens
pip install -e ".[dev]"用容器运行(镜像已公开发布,匿名可拉):
docker run -i --rm ghcr.io/fendoushaonian/doclens:latest在 MCP 宿主里用镜像,把 command 换成:
{
"mcpServers": {
"doclens": {
"command": "docker",
"args": ["run", "-i", "--rm", "ghcr.io/fendoushaonian/doclens:latest"]
}
}
}接入 agent
Claude Code
claude mcp add doclens -- doclensCursor
在 ~/.cursor/mcp.json 里加:
{
"mcpServers": {
"doclens": {
"command": "doclens"
}
}
}其他 MCP 宿主
任何支持 stdio 传输的 MCP 客户端都能用它——启动命令就是 doclens,没有端口,没有 API key。
工具
工具 | 用途 |
| 读取整份文档,返回结构化 Markdown。主工具。 |
| 在文档里定位文本,返回页码和上下文。长文档先用它。 |
| 只读某一张表,表格多的文档用它能省上下文。 |
| 诊断解析质量:有没有数字被降级成文本、公式缺缓存值、扫描页缺文字层。 |
| 列目录里能读的文件。 |
| 并排展示「结构还原」与「朴素文本流」的差异。 |
支持的格式
PDF、XLSX、XLSM、CSV、TSV、DOCX、MD、TXT、JSON、YAML、LOG。
独有之处
无边框表格:不依赖可见表格线,按字形坐标聚类还原行列。真实世界里从网页打印的 PDF、排版软件导出的报表大多没有线。
数字不经过 float:
12,000.00全程是字符串,同时给出可计算的裸值12000.00,精度不丢。识别会计式负数:
(1,234.56)正确解析为-1234.56。不静默丢内容:两栏排版的正文不会被误判成表格吞掉;截断、扫描页、公式缺值都会明说。
Excel 公式保留:
=B2+B3和它的计算结果分别可见,模型的错误通常在公式里。
已知限制
扫描件需要 OCR:没有文字层的 PDF 会明确报告,但不会自动 OCR。
跨页续表是启发式判断:列数一致且页码相邻时才合并,会在输出里说明,需要人工确认。
超长文档分段:默认 PDF 读前 200 页、Excel 每表前 5000 行,超出会提示而不是静默截断。
复杂合并单元格:docx 的合并单元格会被展开成重复文本,不保留 span 语义。
许可
MIT
Available Tools
6 toolscompare_extractionA
把 DocLens 的表格还原结果与「朴素文本流」抽取的结果并排给出,用于判断这份文档如果不做结构还原会错在哪里。适合在向别人解释这份工具的必要性时用。
Inputs: path (required), index. Returns: result
extract_tableA
只读取指定序号的那一张表,输出完整 Markdown 表格。文档里表格很多时用它,避免整份读进来。序号从 1 开始。
Inputs: path (required), index. Returns: result
inspect_documentA
诊断一份文档的解析质量:表格是否完整、有没有数字被降级成文本、有没有扫描页缺文字层、有没有公式缺缓存值。在把解析结果用于重要决策之前跑一次,能提前发现读错的风险。
Inputs: path (required). Returns: result
list_documentsA
列出目录里 DocLens 能读的文件,附带大小和是否受支持。用于在批量处理前先摸清有哪些文档。
Inputs: directory (required), recursive. Returns: result
read_documentA
读取一份文档,返回结构化的 Markdown:表格按行列对齐、金额保留原始精度、公式单独标注、正文按页标注。这是主工具,处理财务/合同/报表时优先用它。
Inputs: path (required), max_chars. Returns: result
search_documentA
在文档里搜索文本,返回命中的页码和上下文。长文档不必整份读进来,先用它定位。
Inputs: path (required), query (required), limit, context_chars. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Core reading tools are well-separated: list_documents enumerates, search_document locates hits, read_document does full structured reads, and extract_table targets a single table to avoid full-document reads. The only soft overlap is between inspect_document (parse-quality diagnostics) and compare_extraction (naive-vs-structured side-by-side), which both serve a validation purpose but differ in intent (risk check vs. demonstration).
All six tools follow a strict snake_case verb_noun pattern: list_documents, read_document, search_document, extract_table, inspect_document, compare_extraction. Verbs are distinct and consistently placed first.
Six tools is a tight, well-scoped set for a document-reading server, with each tool mapping to a distinct user need (enumerate, read, locate, table extraction, quality check, comparison). Nothing feels redundant or missing at the count level.
The surface covers listing, reading, searching, table extraction, and diagnostics, but has notable gaps: no way to read a specific page range, no batch/parallel read despite list_documents mentioning bulk processing, and no remediation path (e.g. OCR) when inspect_document reports scanned pages lacking a text layer. Output is read-only with no export or save operation.
Maintenance
Related MCP Connectors
Hosted MCP server: convert PDFs to clean, LLM-ready Markdown with tables, formulas and OCR.
Document conversion MCP server: PDF to Markdown, image OCR, spreadsheet parsing.
Document-to-Markdown MCP server — convert PDF, Office and HTML into LLM-ready Markdown.
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that lets AI assistants read and visually analyze local documents — PDFs, Excel spreadsheets, CSV files, Word documents, PowerPoint presentations, and images.449 npm100 PyPIMIT
- AlicenseAqualityDmaintenanceThis MCP server enables AI agents to view PDFs as accessible HTML with bounding-box citations, and provides tools for layout-aware parsing, schema extraction, cross-document Q&A, and PDF rendering.27MIT
- FlicenseNot gradedqualityDmaintenanceA local MCP server that extracts text-layer content from PDF files, enabling AI agents to inspect, extract text, outlines, and page content.-
- AlicenseNot gradedqualityBmaintenanceThis MCP server enables safe local access to tables and spreadsheets for AI agents, providing typed tools for reading, previewing, and committing table changes through a permission-brokered interface.MIT