OnDevicePDF MCP Server
README.md
# OnDevicePDF MCP server
PDF tools for AI agents that run on your own computer. Ask Claude, Cursor or any
MCP client to merge, split, compress, password-protect, unlock, repair or clean up
a PDF, and the work happens locally. Your files are never uploaded.
Many PDF services offer MCP servers or chat-app plugins that send your file to
their servers to process it. This one has no server to send it to. It runs the
same PDF engines as [ondevicepdf.com](https://www.ondevicepdf.com), where every
tool works inside your browser.
## Tools
| Tool | What it does |
|---|---|
| `pdf_info` | Page count, password or restriction status, and stored metadata |
| `extract_text` | The text of each page (scanned pages come back empty and are flagged) |
| `merge_pdfs` | Combine PDFs in the order given |
| `split_pdf` | One file per page group (`"1-3; 4-6"`) or per page |
| `extract_pages` | Copy chosen pages into a new PDF |
| `delete_pages` | Remove pages |
| `rotate_pages` | Rotate all or some pages by 90, 180 or 270 degrees |
| `reorder_pages` | Put pages in a new order |
| `reverse_pages` | Reverse the page order |
| `interleave_pages` | Merge a fronts scan and a backs scan into reading order |
| `compress_pdf` | `lossless`, `balanced` or `strong`; text stays sharp and selectable |
| `protect_pdf` | AES-256 password, plus print, copy and edit permissions |
| `unlock_pdf` | Remove a password or restrictions from a file you can open |
| `remove_metadata` | Strip author, title, XMP, comment authors, attachments and scripts |
| `repair_pdf` | Fix files that fail to open (broken xref, header or end of file) |
| `grayscale_pdf` | Gray or pure black and white, without turning pages into pictures |
| `crop_pdf` | Trim margins in mm, cm, inches, points or percent |
| `resize_pages` | Fit pages onto A4, Letter, Legal and other sizes |
| `flatten_pdf` | Bake form fields and annotations into the page |
Every tool writes a new file next to the input (for example `report-merged.pdf`)
unless you give an `output` path. It never overwrites an existing file unless you
pass `overwrite: true`, so an agent cannot quietly replace your original.
## Set up
You need Node.js 22.13 or newer.
**Claude Code**, as a plugin (Claude Code 2.1.275 or later), inside a session:
```
/plugin install ondevicepdf --marketplace RaviChanduEdru/ondevicepdf-mcp
```
or as a plain MCP server, from your shell:
```bash
claude mcp add ondevicepdf -- npx -y ondevicepdf-mcp
```
**Claude Desktop, Cursor, Windsurf and other clients** (add to the client's MCP
config file):
```json
{
"mcpServers": {
"ondevicepdf": {
"command": "npx",
"args": ["-y", "ondevicepdf-mcp"]
}
}
}
```
**VS Code** (`.vscode/mcp.json`):
```json
{
"servers": {
"ondevicepdf": {
"command": "npx",
"args": ["-y", "ondevicepdf-mcp"]
}
}
}
```
Then ask in plain words, for example: "Merge every PDF in my Downloads/invoices
folder into one file, then compress it."
## How "never uploaded" is checked
`npm test` runs every tool in a process where all of Node's network APIs
(sockets, TLS, HTTP, DNS, UDP, `fetch`, WebSocket) throw, and fails if anything
even tries to use them. A negative control proves the block catches a real
`fetch`. The only network use is the one-time `npx` download of the package
itself.
The server speaks MCP over stdio, so it has no port and accepts no outside
connections. It reads and writes only the paths the agent passes to it, with your
user account's permissions.
## Use it as a library
```js
import { mergePdfs, compress } from 'ondevicepdf-mcp';
await mergePdfs({ inputs: ['a.pdf', 'b.pdf'], output: 'both.pdf' });
await compress({ input: 'both.pdf', level: 'balanced' });
```
## Limits
- Scanned pages have no text layer, so `extract_text` returns them empty. OCR is
on the website, not in this package yet.
- `merge_pdfs` does not carry over bookmarks or form fields.
- Cropping hides content outside the box; it does not delete it. Use a redaction
tool to remove content for good.
- Re-drawing pages as images (the website's last-resort compression) needs a
canvas, so it is not offered here.
## Licence
MIT. Third-party components and their licences are listed in
[NOTICE.md](NOTICE.md).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues