
A Model Context Protocol server for global law with read-only tools to find and read provisions by date, trace the law behind each word, search text and changes, and check cases or briefs against law in force.

An alpha-stage Model Context Protocol server that offers tools for extracting content, metadata, layout, tables, images, outlines and language from local PDF documents, with OCR fallback for scanned pages.
MCP server for extracting text, metadata, layout and tables from PDF documents is cataloged as an MCP server attributed to jaesharp. An alpha-stage Model Context Protocol server that offers tools for extracting content, metadata, layout, tables, images, outlines and language from local PDF documents, with OCR fallback for scanned pages. It is categorized under file systems-docs. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.
能力定义尚未审核。未核验的采集内容不会作为可信接口展示。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for MCP server for extracting text, metadata, layout and tables from PDF documents are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
Yes, by default it reads PDFs only from the directory set via DOCUMENT_UNDERSTANDING_BASE_PATH, and refuses to start without it unless --allow-any-path is used.
Yes, the extract_tables tool requires a Java runtime, and OCR fallback requires the Tesseract OCR engine.
Most tools cannot handle password-protected PDFs, with table extraction being the exception; encrypted files will likely fail processing.
README.md · ac9b2e2be0d5 · 采集于 2026-11-13 10:45:54 UTC
保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。
当前显示最后一次成功采集的文档快照,请以来源页面为准。
⚠️ WARNING: This server is currently in alpha stage and is intended for local development and testing only. It should not be deployed in production environments or exposed to untrusted networks. Please review SECURITY.md for important security considerations before running this server.
MCP server providing tools to extract text, metadata, layout, and search documents (primarily PDFs). This server implements the Model Context Protocol (MCP) specification, allowing AI models to interact with PDF documents through a standardized interface.
The Document Understanding MCP Server provides a set of tools for extracting information from PDF documents, including:
These tools can be used by AI models to analyze and understand PDF documents, enabling more sophisticated document processing workflows.
Future Plans: We're working on expanding support to multiple document types beyond PDF. See docs/plans/README.md for details on upcoming architectural changes.
git clone <repo-url>
cd document-understanding-mcp-server
uv: It's recommended to use uv for environment management.
pip install uv
uv venv # Create .venv
# Install core dependencies
uv pip sync pyproject.toml
# For development/testing, install optional extras:
uv pip install -e '.[dev,test]'
extract_tables tool relies on tabula-py, which requires a Java Runtime Environment (JRE). Install a JRE (e.g., OpenJDK) suitable for your system and ensure java is accessible in your system's PATH.extract_pdf_contents relies on pytesseract, which requires the Tesseract OCR engine itself. Install Tesseract for your OS (see Tesseract Installation) and ensure the tesseract command is in your system's PATH.DOCUMENT_UNDERSTANDING_BASE_PATH environment variable. This is the only directory the server will read PDFs from by default. Example:
export DOCUMENT_UNDERSTANDING_BASE_PATH=/path/to/your/pdf_working_directory
DOCUMENT_UNDERSTANDING_BASE_PATH (Environment Variable, Required):* Specifies the absolute path to the directory the server is allowed to access for reading PDFs. The server will refuse to start if this is not set, unless --allow-any-path is used.DOCUMENT_UNDERSTANDING_LOG_LEVEL (Environment Variable): Sets the minimum log level for console output (e.g., DEBUG, INFO, WARNING). Default=INFO.DOCUMENT_UNDERSTANDING_LOG_FORMAT (Environment Variable): Sets console log format (plain or json). Default=plain.DOCUMENT_UNDERSTANDING_LOG_FILE (Environment Variable): If set, specifies a path to write structured JSON logs (e.g., .tmp/logs/server.log). Directory will be created. Default=Disabled.DOCUMENT_UNDERSTANDING_LOG_FILE_LEVEL (Environment Variable): Minimum level for file logging (e.g., DEBUG, INFO). Default=INFO.DOCUMENT_UNDERSTANDING_DEFAULT_LANG (Environment Variable): Sets the default OCR language (e.g., eng, fra). Defaults to eng if not set.ENABLE_SAVE_IMAGES_TO_FILES (Environment Variable): When set to true, enables saving extracted images to files when using the extract_images tool with the output_directory parameter. Default=false.SAFE_OUTPUT_DIRECTORIES (Environment Variable): Colon-separated list of directories where images can be saved when ENABLE_SAVE_IMAGES_TO_FILES=true but ALLOW_ANY_PATH=false. For example: /tmp:/var/output:/data/images.--allow-no-java: If the Java runtime (required for extract_tables) is not found, the server will normally exit. Use this flag to allow startup, but the extract_tables tool will be disabled.--allow-no-tesseract: If the Tesseract executable (required for OCR fallback) is not found, the server will normally exit. Use this flag to allow startup, but OCR fallback in extract_pdf_contents will be disabled.--enable-experimental: Enables experimental tools (like find_nearby_content) which are disabled by default.--allow-any-path: (SECURITY RISK) If set, disables the PDF_SERVER_BASE_PATH restriction and allows the server to attempt reading files from any path provided in tool arguments. Use with extreme caution and only in trusted environments.The availability or full functionality of certain tools depends on external dependencies or flags.
| Tool Name | Capability | Dependency / Trigger | Check Performed At | Control Flag |
|---|---|---|---|---|
extract_tables | java_runtime | Java Runtime (JRE) | Server Startup | --allow-no-java |
extract_pdf_contents | tesseract_ocr (Opt.) | Tesseract OCR | Server Startup | --allow-no-tesseract |
| (Other Tools) | (None) | Python Packages | Installation | (N/A) |
*Note: If Tesseract OCR is unavailable (and --allow-no-tesseract is used), OCR fallback is disabled.
The server implements the following tools. The list presented to the LLM via the list_tools call is dynamic and depends on detected capabilities (e.g., Java availability) and startup flags.
See src/document_understanding/models.py for response schemas (e.g., TextContentResponse, MetadataResponse, etc.). Error responses follow the ErrorResponse schema.
Guidance: The pdf_path argument in all tools must refer to a file path accessible within the server's environment.
extract_pdf_contentspdf_path (string, required): Path to the local PDF file.pages (string, optional): Page spec (1-based, ranges, neg indices). E.g., "1, 3-5, -1". Default=all.ocr_language (string, optional): OCR language(s) for Tesseract (e.g., "eng", "fra+eng"). Default='eng'.password (string, optional): Password for encrypted PDFs.TextContentResponse JSON.pages for specific sections. If dealing with non-English scanned text, set ocr_language.extract_pdf_metadatapdf_path (string, required): Path to the local PDF file.password (string, optional): Password for encrypted PDFs.MetadataResponse JSON.search_pdf_textpdf_path (string, required): Path to the local PDF file.query (string, required): The text to search for (case-sensitive).pages (string, optional): Page spec. Default=all.password (string, optional): Password for encrypted PDFs.SearchResponse JSON containing a list of matches with page number and rectangle coordinates.extract_pdf_layoutpdf_path (string, required): Path to the local PDF file.pages (string, optional): Page spec. Default=all.include_images (boolean, optional): Include image info (xref, bbox, size). Default=False.include_drawings (boolean, optional): Include vector drawing info. Default=False.detail_level (string, optional): Text detail level ('blocks', 'lines', 'words'). Default='blocks'.password (string, optional): Password for encrypted PDFs.LayoutResponse JSON containing layout details per page.extract-imagespdf_path (string, required): Path to the local PDF file.pages (string, optional): Page spec. Default=all.include_data (boolean, optional): If true, include base64 image data. Default=false.min_width (integer, optional): Minimum image width to include in results.min_height (integer, optional): Minimum image height to include in results.filter_bbox (array, optional): Bounding box to filter images by [x0, y0, x1, y1].password (string, optional): Password for encrypted PDFs.output_directory (string, optional): Directory to save extracted images to. Requires ENABLE_SAVE_IMAGES_TO_FILES=true environment variable.save_without_returning_data (boolean, optional): If true, save images to files without returning base64 data in response. Default=false.ImageExtractionResponse JSON.xref). Bounding box (bbox) is optional and may be missing if detection fails (e.g., for Form XObjects). Use include_data=True cautiously as it can return very large responses. When output_directory is specified and ENABLE_SAVE_IMAGES_TO_FILES=true, images will be saved to disk and the response will include file paths. Use save_without_returning_data=True to save images to files without including the potentially large base64 data in the response.extract_tablespdf_path (string, required): Path to the local PDF file.pages (string, optional): 'all' or comma-separated page numbers (1-based). Default=all.password (string, optional): Password for encrypted PDFs.TableExtractionResponse JSON. (Note: Current implementation returns list of dicts, see docs/KNOWN_ISSUES.md).tabula-py. Results depend heavily on table formatting (lines, spacing). May be slow. Note: This tool requires a Java runtime. If Java is not detected at server startup and the --allow-no-java flag was used, this tool will be unavailable.detect-languagepdf_path (string, required): Path to the local PDF file.pages (string, optional): Page spec for sampling. Default='1'.sample_size (integer, optional): Max characters to sample. Default=2000.password (string, optional): Password for encrypted PDFs.LanguageDetectionResponse JSON.extract_pdf_outlinepdf_path (string, required): Path to the local PDF file.password (string, optional): Password for encrypted PDFs.OutlineExtractionResponse JSON containing the hierarchical outline structure.get_pdf_working_directorystatus, working_directory (string or null), and optional message.pdf_path. If the server was started with --allow-any-path, working_directory will be null.The test suite uses dynamically generated PDFs for all tests. No static PDF files are stored in the repository. The test fixtures in tests/conftest.py generate all necessary test PDFs at runtime, including:
This approach ensures that all tests can run without requiring external files and makes the test suite more portable and self-contained.
# Run all tests
python -m pytest
# Run specific test categories
python -m pytest tests/unit
python -m pytest tests/integration
# Run tests with coverage
python -m pytest --cov=src
The test suite includes several types of tests:
The end-to-end tests use the MCP command-line interface to interact with the server, simulating real-world usage. This approach ensures that the server works correctly in various scenarios and with different types of PDFs.
This server runs using the standard MCP stdio communication. There are multiple ways to run the server:
# Set required base path (if not using sandbox mode)
export DOCUMENT_UNDERSTANDING_BASE_PATH=/path/to/pdf/storage
# Run with default settings (sandbox mode)
bin/document-understanding-mcp-server
# Run with sandbox mode disabled (less restricted)
DOCUMENT_UNDERSTANDING_SANDBOX=false bin/document-understanding-mcp-server
# Run with additional arguments
bin/document-understanding-mcp-server --enable-experimental --port 8000
The document-understanding-mcp-server executable automatically sets up a secure environment with:
When the package is installed via pip, you can use the entry point directly:
# Run with default settings
document-understanding-mcp-server
# Run with custom arguments
document-understanding-mcp-server --allow-any-path --enable-experimental
standalone_server.py Directly# Activate environment
source .venv/bin/activate
# Set required base path
export DOCUMENT_UNDERSTANDING_BASE_PATH=/path/to/pdf/storage
# Run directly (will fail if Java/Tesseract missing and flags not used)
python standalone_server.py
# Run allowing missing Java/Tesseract but restricting path
python standalone_server.py --allow-no-java --allow-no-tesseract
# Run allowing ANY path access (UNSAFE)
# DOCUMENT_UNDERSTANDING_BASE_PATH is ignored here
python standalone_server.py --allow-any-path
# Enable experimental features
python standalone_server.py --enable-experimental
The server supports a secure sandbox mode (enabled by default) that:
--allow-any-path flag for better securityTo disable sandbox mode (not recommended for production):
export DOCUMENT_UNDERSTANDING_SANDBOX=false
mcp.json){
"mcpServers": {
"document-understanding": {
"command": "/path/to/document-understanding-mcp-server",
"args": [
"--enable-experimental"
]
}
}
}
{
"mcpServers": {
"document-understanding": {
"command": "/path/to/your/.venv/bin/python",
"args": [
"-m", "document_understanding.cli"
],
"env": {
"DOCUMENT_UNDERSTANDING_BASE_PATH": "/path/to/pdf/storage"
}
}
}
}
get_pdf_working_directory to find the allowed directory. Ensure any pdf_path arguments you provide refer to files within that directory (or subdirectories). Path traversal attempts (../) or absolute paths outside the working directory will be rejected unless the server was unsafely started with --allow-any-path.--allow-no-java was used, extract_tables will not be listed). Rely on the response from list_tools to know what is currently usable.search_pdf_text over extracting all content if you only need specific occurrences. Use extract_pdf_metadata if only metadata is needed.text field of the ToolResponseContent as JSON.status: Always check the status field in the JSON response. If it's "error", use the message and error_code fields for diagnostics (Note: errors are typically raised as exceptions by the server, the MCP client translates these).extract_pdf_layout tool provides rich structural information (text coordinates, drawings, image locations). This can be used for complex analysis (e.g., with find_nearby_content) but generates large responses.pages parameter effectively (e.g., "1-3, 5, -1") to limit processing when needed.ocr_language (e.g., "fra+eng" for French and English) for better accuracy.FileNotFoundError if the pdf_path is incorrect, or ValueError for invalid page specifications or processing issues. Encrypted files may cause various errors. The server raises exceptions which the MCP client should surface.Extracting French Text from Scanned Pages 2 & 3:
get_pdf_working_directory -> Check response for working_directory.mydoc.pdf is in the working directory)extract_pdf_contents with pdf_path="mydoc.pdf", pages="2-3", ocr_language="fra".pages list.Finding Text near an Image:
get_pdf_working_directory -> Get working_directory.report.pdf)extract_pdf_layout with pdf_path="report.pdf", pages="5" (assuming image is on page 5).xref, size, or rough bbox.find_nearby_content (if enabled) with pdf_path="report.pdf", pages="5", target_bbox set to the image's bbox, content_type="text_block", direction="below" (e.g., to find caption).Extracting Specific Tables after Metadata Check:
get_pdf_working_directory -> Get working_directory.data.pdf)extract_pdf_metadata with pdf_path="data.pdf".page_count, look at metadata fields.extract_tables with pdf_path="data.pdf", pages="2, 4" (e.g., only pages 2 and 4).extract_pdf_contents with pdf_path and pages="2-3".status, process the extracted content.For a list of current known issues and limitations, see docs/KNOWN_ISSUES.md.
For a list of previously resolved issues, see docs/SOLVED_ISSUES.md.
For information about planned enhancements and future development, see the plans directory.
For information on how to contribute to this project, please see the CONTRIBUTING.md file.
This project is licensed under the terms specified in the LICENSE file.
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for MCP server for extracting text, metadata, layout and tables from PDF documents from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/document-understanding-mcp-server)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。
尚无已审核的包 / 镜像标识,暂不展示下载统计。
Alternative and complementary servers in the same category

A Model Context Protocol server for global law with read-only tools to find and read provisions by date, trace the law behind each word, search text and changes, and check cases or briefs against law in force.

Hosted MCP server for tabletop RPG worlds that organizes messy notes and documents into a private store and lets MCP apps search lore, read documents, find characters, and optionally generate character or world pictures.

An MCP server that gives AI assistants scoped file system operations inside a project directory, with read-only reference projects plus git and GitHub tools.