DocMCP — Document Processing MCP Server
Servidor MCP para manipulación de documentos PDF. Lee, fusiona, divide, comprime, extrae páginas e imágenes, y genera PDFs desde texto, tablas o informes estructurados.
Features / Funcionalidades
| Tool / Herramienta | Description / Descripción |
|---|---|
read |
Lee un PDF y devuelve texto, metadatos y número de páginas |
info |
Obtiene metadatos, tamaño, páginas y conteo de imágenes |
extract_images |
Extrae todas las imágenes de un PDF a un directorio |
to_markdown |
Convierte el contenido del PDF a formato Markdown |
merge |
Fusiona múltiples PDFs en uno solo |
split |
Divide un PDF en páginas individuales |
extract_pages |
Extrae páginas específicas (ej: 1,3,5-10) a un nuevo PDF |
compress |
Comprime un PDF reduciendo su tamaño |
generate_report |
Genera un PDF estructurado desde contenido JSON |
generate_table |
Crea un PDF con una tabla estilizada |
generate_text |
Convierte texto plano/Markdown a PDF |
Tech Stack
- Python —
>=3.11 - Framework:
mcp(FastMCP) via stdio JSON-RPC - PDF reading:
PyMuPDF(fitz) - PDF manipulation:
pypdf - PDF generation:
reportlab
Quick Start
# Instalar dependencias
pip install mcp pymupdf reportlab pypdf
# Ejecutar servidor (stdio transport)
python server.py
# Configurar directorio de trabajo (opcional)
export DOCMCP_WORKDIR=/home/user/documents
Uso MCP Client
from mcp import ClientSession, StdioServerParameters
async with ClientSession(server) as session:
result = await session.call_tool("read", {"path": "documento.pdf"})
result = await session.call_tool("merge", {"paths": "a.pdf,b.pdf", "output": "merged.pdf"})
result = await session.call_tool("generate_report", {
"title": "Reporte",
"content": '{"sección": ["item1", "item2"]}',
"output": "reporte.pdf"
})
Security / Seguridad
Path traversal protection via DOCMCP_WORKDIR. All file operations are restricted to the work directory, with trailing-slash prefix check to prevent /home/user/evil matching /home/user/extra.
🔧 Recent Improvements
- Path Traversal Hardened —
_resolve()now normalizes relative paths against workdir and uses trailing-slash prefix check to_markdown()Error Handling — Output path validation errors are now caught and returned gracefullygenerate_table()JSON Parsing — MalformedrowsJSON returns a friendly error instead of crashingmerge()Newline Support — Accepts newline-separated paths in addition to comma-separatedMAX_PAGESConfigurable —DOCMCP_MAX_PAGESenv var (default 100) controls PDF page limitimport fitzMoved — Orphaned import at end ofgenerator.pymoved to top of file
Project Structure
docmcp/
├── server.py # MCP server entry point (tools)
├── docmcp/
│ ├── reader.py # PDF reading & extraction
│ ├── manipulator.py # Merge, split, compress, extract pages
│ ├── generator.py # PDF generation (reports, tables, text)
│ └── __init__.py
├── client.py # Test client
└── pyproject.toml
Metadata
Release files for docmcp 1.0.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 |
|---|---|---|---|---|
| docmcp-1.0.0.tar.gz | 9.6 kB | Without provenance | Details for docmcp-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docmcp-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for docmcp-1.0.0-py3-none-any.whl |
Total release size: 32.0 kB
Release files / docmcp-1.0.0.tar.gz
| Download URL | docmcp-1.0.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75d989dd2c543025dfca673b91bb8fbc153b48556856a756e12420e07771c5ae
|
|
BLAKE2b-256 checksum How to use checksums |
153ce418590259ce81c3681528caffcdc61960143adccf93bfb6748bc8d9d04a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / docmcp-1.0.0-py3-none-any.whl
| Download URL | docmcp-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f52cc91880b0ad987a8aec66c8457384ddbb8cce6ef8a1fefa5c5606efbee427
|
|
BLAKE2b-256 checksum How to use checksums |
42e64619e298edd8e6b3832730087d5ab95ff64cd5cdb81ccd18d9ab20609720
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for docmcp 1.0.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.