PDF Tools MCP Server: Merge, Split, Encrypt, Optimize
Manage PDFs on an MCP server, merge, split, encrypt, optimize and automate workflows with a fast, comprehensive manipulation toolkit.
npx -y @Sohaib-2/pdf-mcp-serverOverview
This MCP (Model Context Protocol) server provides a focused PDF manipulation toolkit intended for developer workflows and agent integrations. It exposes HTTP endpoints that let you merge, split, encrypt, optimize, and otherwise process PDF files, enabling automated document pipelines, pre-processing for downstream models, or ad-hoc developer tools. Because it follows a simple service interface, it is easy to incorporate into CI jobs, serverless functions, or Model Context Protocol-enabled agents.
The server is designed to be fast and composable: endpoints accept uploaded PDFs (or remote file URLs), run common transformations, and return optimized files or metadata. Typical uses include preparing documents for storage, creating client-ready bundles, and protecting content with encryption. The repo and code are intended for developers who want an extensible PDF service they can host locally or in production.
Features
- Merge multiple PDFs into a single document
- Split PDFs by page ranges or extract individual pages
- Encrypt and decrypt PDFs (password-protect and remove protection)
- Optimize and compress PDFs for web or archival use
- Metadata reading and basic validation (page count, size, encryption status)
- File upload/download endpoints suitable for automation and agent use
- Docker-friendly and configurable via environment variables
Installation / Configuration
Clone the repository and run using Docker, or install and run locally with Node.js (if a JS implementation is provided). The examples below are generic; consult the repository README for implementation-specific details.
Clone repository:
Run with Docker:
# Build (if Dockerfile is present)
# Run
Run locally (Node.js example):
# Install and run (if package.json exists)
# or
Sample environment file (.env):
PORT=8080
UPLOAD_DIR=./uploads
MAX_FILE_SIZE=50mb
AUTH_TOKEN=your-secret-token
ENABLE_CORS=true
Available Tools / API Endpoints
Below is a representative set of endpoints commonly exposed by this kind of server. Exact endpoints and parameters may vary—check the project repository for full API documentation.
| Method | Path | Purpose | Key parameters |
|---|---|---|---|
| POST | /merge | Combine multiple PDFs into one | files[] (multipart), output_name |
| POST | /split | Split a PDF by page ranges | file (multipart), ranges (e.g. “1-3,5,7-9”) |
| POST | /encrypt | Add password protection | file, password, algorithm(optional) |
| POST | /decrypt | Remove password protection | file, password |
| POST | /optimize | Compress/linearize for web | file, quality (low/medium/high) |
| GET | /info | Return PDF metadata | file_id or URL |
| GET | /health | Health check | — |
Example merge request (cURL):
Example split request:
Use Cases
- Automating post-processing in document ingestion pipelines: receive uploaded PDFs, run /optimize, extract metadata with /info, then store optimized output in cloud storage.
- Generating client deliverables: merge multiple generated PDFs into a single package before sending to a customer or for archival.
- Securing documents before distribution: use /encrypt to password-protect sensitive output produced by other services.
- Preparing content for LLM agents: split large PDFs into smaller sections with /split, then feed page-level content to a model as part of an MCP context provider.
- Serverless handlers and webhooks: attach the MCP server to file upload events; when a PDF is uploaded, automatically run /optimize and /encrypt, then return the link to downstream systems.
Concrete workflow example: automated monthly report bundle
- Daily jobs generate several PDF reports into a storage folder.
- A small orchestrator calls the MCP server /merge endpoint with all daily PDFs.
- The merged PDF is passed to /optimize (quality=medium).
- The optimized file is encrypted and uploaded to an archive bucket, and a metadata record is written with /info data.
Tips for Developers
- Secure endpoints with an Authorization token or integrate with your existing auth layer.
- For large files, ensure your server and reverse proxy (Nginx, Cloud Run) are configured for the appropriate max body size and streaming.
- Use the /info endpoint to preflight operations (e.g., check page count) before expensive transforms.
- Consider running optimization as an async job for very large files and return a job ID or webhook callback on completion.
For implementation details, API reference, and advanced configuration options, see the project’s repository: https://github.com/Sohaib-2/pdf-mcp-server