
Document Operations
STDIOUniversal MCP server for document processing, conversion and automation across PDF, DOCX, HTML, Markdown formats
Universal MCP server for document processing, conversion and automation across PDF, DOCX, HTML, Markdown formats
Document Operations MCP Server - A universal MCP server for document processing, conversion, and automation. Handle PDF, DOCX, HTML, Markdown, and more through a unified API and toolset.
https://github.com/user-attachments/assets/43dfeeec-8097-413e-8519-a7de98e31136
In this demo, we showcase how to:
First, add the Document Operations MCP server to your MCP client.
Standard config works in most MCP clients:
{ "mcpServers": { "doc-ops-mcp": { "command": "npx", "args": ["-y", "doc-ops-mcp"], "env": { "OUTPUT_DIR": "/path/to/your/output/directory", "CACHE_DIR": "/path/to/your/cache/directory", } } } }
Follow the MCP install guide, use the standard config above.
Follow the MCP install guide, use the standard config above.
Go to Cursor Settings
-> MCP
-> Add new MCP Server
. Name to your liking, use command
type with the command npx -y doc-ops-mcp
.
For other MCP clients, use the standard config above and refer to your client's documentation for MCP server installation.
The Document Operations MCP server supports configuration through environment variables. These can be provided in the MCP client configuration as part of the "env"
object:
{ "mcpServers": { "doc-ops-mcp": { "command": "npx", "args": ["-y", "doc-ops-mcp"], "env": { "OUTPUT_DIR": "/path/to/your/output/directory", "CACHE_DIR": "/path/to/your/cache/directory", "WATERMARK_IMAGE": "/path/to/watermark.png", "QR_CODE_IMAGE": "/path/to/qrcode.png" } } } }
Format | Convert to PDF | Convert to DOCX | Convert to HTML | Convert to Markdown | Content Rewriting | Watermark/QR Code |
---|---|---|---|---|---|---|
✅ | ❌ | ❌ | ❌ | ❌ | ✅ | |
DOCX | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
HTML | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ |
Markdown | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
Rewriting Features:
Format Conversion:
Convert /Users/docs/report.docx to PDF
Convert /Users/docs/article.md to HTML
Convert /Users/docs/presentation.html to DOCX
Convert /Users/docs/readme.md to PDF (with theme styling)
Document Rewriting:
Rewrite company names in /Users/docs/contract.md
Batch replace terminology in /Users/docs/manual.docx
Adjust heading levels in /Users/docs/article.html
Update dates and version numbers in /Users/docs/policy.md
PDF Enhancement:
Add watermark to /Users/docs/document.pdf
Add QR code to /Users/docs/report.pdf
Add company logo watermark to /Users/docs/invoice.pdf
The server supports environment variables for controlling output paths and PDF enhancement features:
OUTPUT_DIR
: Controls where all generated files are saved (default: ~/Documents
)CACHE_DIR
: Directory for temporary and cache files (default: ~/.cache/doc-ops-mcp
)WATERMARK_IMAGE
: Default watermark image path for PDF files
QR_CODE_IMAGE
: Default QR code image path for PDF files
addQrCode=true
)Output Path Rules:
outputPath
is not provided → files saved to OUTPUT_DIR
with auto-generated namesoutputPath
is relative → resolved relative to OUTPUT_DIR
outputPath
is absolute → used as-is, ignoring OUTPUT_DIR
See OUTPUT_PATH_CONTROL.md for detailed documentation.
Document Operations MCP Server adopts a pure JavaScript architecture design, providing complete document processing capabilities:
┌─────────────────────────────────────────────────────────────┐
│ MCP Client Layer │
│ (Claude Desktop, Cursor, VS Code, etc.) │
└─────────────────────┬───────────────────────────────────────┘
│ JSON-RPC 2.0
┌─────────────────────┴───────────────────────────────────────┐
│ Doc-Ops-MCP Server │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
│ │ Tool Router │ │ Request │ │ Response │ │
│ │ & Handler │ │ Validator │ │ Formatter │ │
│ └────────┬────────┘ └────────┬────────┘ └──────┬──────┘ │
│ │ │ │ │
│ ┌────────┴────────────────────┴──────────────────┴─────┐ │
│ │ Document Processing Engine │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Document │ │ Format │ │ Style │ │ │
│ │ │ Reader │ │ Converter │ │ Processor │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ PDF │ │ Watermark/ │ │ Conversion │ │ │
│ │ │ Enhancement │ │ QR Code │ │ Planner │ │ │
│ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │
└────┴───────────────────────────────────────────────────────┴─┘
│
┌───────────────────────────┴─────────────────────────────────┐
│ Core Dependencies Layer │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ pdf-lib │ │word-extractor│ │ marked │ │
│ │ (PDF Tools) │ │(DOCX Reader)│ │ (Markdown) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ cheerio │ │ jszip │ │ docx │ │
│ │(HTML Parser)│ │(ZIP Handler)│ │(DOCX Gen.) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ │
│ │ xml2js │ │Custom OOXML │ │
│ │(XML Parser) │ │ Parser │ │
│ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
Core Features:
Conversion Flow:
This server can work with playwright-mcp
for enhanced PDF conversion capabilities. Please refer to the official playwright-mcp
documentation for detailed configuration.
This server supports complete PDF conversion functionality:
playwright-mcp
This server uses intelligent conversion architecture:
plan_conversion
analyzes conversion requirements and selects optimal pathsplaywright-mcp
for enhanced capabilitiesTool Name | Description | Input Parameters | External Dependencies |
---|---|---|---|
read_document | Read document content | filePath : Document pathextractMetadata : Extract metadatapreserveFormatting : Preserve formatting | None |
write_document | Write document content | content : Document contentoutputPath : Output file pathencoding : File encoding | None |
convert_document | Smart document conversion | inputPath : Input file pathoutputPath : Output file pathpreserveFormatting : Preserve formatting | None |
plan_conversion | Conversion planner | sourceFormat : Source formattargetFormat : Target formatpreserveStyles : Preserve stylesquality : Conversion quality | None |
Read various document formats including PDF, DOCX, DOC, HTML, MD, and more.
Parameters:
filePath
(string, required) - Document path to readextractMetadata
(boolean, optional) - Extract document metadata, defaults to false
preserveFormatting
(boolean, optional) - Preserve formatting (HTML output), defaults to false
Write content to document files in specified formats.
Parameters:
content
(string, required) - Content to writeoutputPath
(string, optional) - Output file path (auto-generated if not provided)encoding
(string, optional) - File encoding, defaults to utf-8
Convert documents between formats with enhanced style preservation.
Parameters:
inputPath
(string, required) - Input file pathoutputPath
(string, optional) - Output file path (auto-generated if not provided)preserveFormatting
(boolean, optional) - Preserve formatting, defaults to true
useInternalPlaywright
(boolean, optional) - Use built-in Playwright for PDF conversion, defaults to false
Convert DOCX to PDF with automatic watermark addition (if configured).
Parameters:
docxPath
(string, required) - DOCX file pathoutputPath
(string, optional) - Output PDF path (auto-generated if not provided)addQrCode
(boolean, optional) - Whether to add QR code, defaults to false
preserveFormatting
(boolean, optional) - Preserve original formatting, defaults to true
chineseFont
(string, optional) - Chinese font, defaults to Microsoft YaHei
Convert Markdown to PDF with automatic watermark addition (if configured).
Parameters:
markdownPath
(string, required) - Markdown file pathoutputPath
(string, optional) - Output PDF path (auto-generated if not provided)theme
(string, optional) - Theme style, defaults to "github"
includeTableOfContents
(boolean, optional) - Include table of contents, defaults to false
addQrCode
(boolean, optional) - Whether to add QR code, defaults to false
Convert Markdown to HTML.
Parameters:
markdownPath
(string, required) - Markdown file pathoutputPath
(string, optional) - Output HTML path (auto-generated if not provided)theme
(string, optional) - Theme style, defaults to "github"
includeTableOfContents
(boolean, optional) - Include table of contents, defaults to false
Convert Markdown to DOCX.
Parameters:
markdownPath
(string, required) - Markdown file pathoutputPath
(string, optional) - Output DOCX path (auto-generated if not provided)Convert HTML to Markdown.
Parameters:
htmlPath
(string, required) - HTML file pathoutputPath
(string, optional) - Output Markdown path (auto-generated if not provided)🎯 Smart Conversion Planner - Analyze conversion requirements and generate optimal conversion plans.
Parameters:
sourceFormat
(string, required) - Source file format (pdf, docx, html, markdown, md, txt, doc)targetFormat
(string, required) - Target file format (pdf, docx, html, markdown, md, txt, doc)sourceFile
(string, optional) - Source file path (for generating specific conversion parameters)preserveStyles
(boolean, optional) - Whether to preserve style formatting, defaults to true
includeImages
(boolean, optional) - Whether to include images, defaults to true
theme
(string, optional) - Conversion theme, defaults to github
quality
(string, optional) - Conversion quality requirement (fast, balanced, high), defaults to balanced
Parameters:
playwrightPdfPath
(string, required) - Generated PDF file pathtargetPath
(string, optional) - Target PDF file path (auto-generated if not provided)addWatermark
(boolean, optional) - Whether to add watermark, defaults to false
addQrCode
(boolean, optional) - Whether to add QR code, defaults to false
watermarkImage
(string, optional) - Watermark image pathqrCodePath
(string, optional) - QR code image path🎨 PDF Watermark Addition Tool - Add image or text watermarks to PDF documents.
Parameters:
pdfPath
(string, required) - PDF file pathwatermarkImage
(string, optional) - Watermark image path (PNG/JPG)watermarkText
(string, optional) - Watermark text contentwatermarkImageScale
(number, optional) - Image scale ratio, defaults to 0.25
watermarkImageOpacity
(number, optional) - Image opacity, defaults to 0.6
watermarkImagePosition
(string, optional) - Image position, defaults to fullscreen
📱 PDF QR Code Addition Tool - Add QR codes to PDF documents.
Parameters:
pdfPath
(string, required) - PDF file pathqrCodePath
(string, optional) - QR code image pathqrScale
(number, optional) - QR code scale ratio, defaults to 0.15
qrOpacity
(number, optional) - QR code opacity, defaults to 1.0
qrPosition
(string, optional) - QR code position, defaults to bottom-center
addText
(boolean, optional) - Whether to add explanatory text, defaults to true
# Global installation npm install -g doc-ops-mcp # Or using pnpm pnpm add -g doc-ops-mcp # Or using bun bun add -g doc-ops-mcp
Library | Version | License | Purpose |
---|---|---|---|
pdf-lib | ^1.17.1 | MIT | PDF document manipulation |
word-extractor | ^1.0.4 | MIT | DOCX document text extraction |
marked | ^15.0.12 | MIT | Markdown parsing and rendering |
cheerio | ^1.0.0-rc.12 | MIT | HTML parsing and manipulation |
docx | ^9.5.1 | Apache-2.0 | DOCX document generation |
jszip | ^3.10.1 | MIT | ZIP file processing |
xml2js | ^0.6.2 | MIT | XML parsing and conversion |
# Pull the latest image docker pull docops/doc-ops-mcp:latest # Run with default configuration docker run -d \ --name doc-ops-mcp \ -p 3000:3000 \ docops/doc-ops-mcp:latest
# Clone the repository git clone https://github.com/JefferyMunoz/doc-ops-mcp.git cd doc-ops-mcp # Build the Docker image docker build -t doc-ops-mcp . # Run the container docker run -d \ --name doc-ops-mcp \ -p 3000:3000 \ -v $(pwd)/documents:/app/documents \ doc-ops-mcp
Create a docker-compose.yml
file:
version: '3.8' services: doc-ops-mcp: image: docops/doc-ops-mcp:latest container_name: doc-ops-mcp ports: - "3000:3000" volumes: - ./documents:/app/documents - ./config:/app/config environment: - NODE_ENV=production - PORT=3000 restart: unless-stopped # Optional: Add Nginx for reverse proxy nginx: image: nginx:alpine container_name: doc-ops-nginx ports: - "80:80" volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro depends_on: - doc-ops-mcp restart: unless-stopped
Variable | Description | Default |
---|---|---|
PORT | Server port | 3000 |
NODE_ENV | Environment mode | production |
LOG_LEVEL | Logging level | info |
MAX_FILE_SIZE | Maximum file size (MB) | 50 |
Mount local directories for persistent storage:
# Documents directory for file processing docker run -d \ --name doc-ops-mcp \ -p 3000:3000 \ -v $(pwd)/documents:/app/documents \ -v $(pwd)/output:/app/output \ doc-ops-mcp
# Production setup with Docker Swarm docker swarm init docker stack deploy -c docker-compose.yml doc-ops # Scale the service docker service scale doc-ops_mcp=3
The container includes built-in health checks:
# Check container health docker ps # View health check logs docker inspect --format='{{.State.Health.Status}}' doc-ops-mcp # Manual health check docker exec doc-ops-mcp curl -f http://localhost:3000/health || exit 1
# Clone the repository git clone https://github.com/your-org/doc-ops-mcp.git cd doc-ops-mcp # Install dependencies npm install # Run in development mode npm run dev # Build the project npm run build # Run tests npm test
src/
├── index.ts # MCP server entry point
├── tools/ # Tool implementations
│ ├── documentConverter.ts
│ ├── pdfTools.ts
│ └── ...
├── types/ # Type definitions
└── utils/ # Utility functions
src/tools/
src/index.ts
# Run with debug logging docker run -d \ --name doc-ops-mcp \ -p 3000:3000 \ -e LOG_LEVEL=debug \ doc-ops-mcp # View logs docker logs -f doc-ops-mcp
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)By submitting a Pull Request, you agree that all contributions submitted through Pull Requests will be licensed under the MIT License. This means:
If you cannot agree to these terms, please do not submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.