mcp
v0.2.0MCP server for PDF123: lets Claude, Cursor and other AI agents merge, split, compress, convert and OCR local PDF files (97 tools)
MCP server (stdio) for PDF123: lets an AI agent merge, split, compress, convert, OCR and otherwise process PDF files on your machine (97 tools). It reads the input paths, calls the PDF123 API, and saves the result next to the input. Unlike the remote endpoint at https://pdf123.xyz/mcp, the agent hands it plain file paths instead of building upload requests and managing keys. There is no offline mode: the API base has to be reachable. Nothing to install: an MCP client starts it with npx -y @pdf123/mcp.
Summary extracted from the README.
@pdf123/mcp
MCP server (stdio) for PDF123: lets an AI agent merge, split, compress, convert, OCR and otherwise process PDF files on your machine (97 tools). It reads the input paths, calls the PDF123 API, and saves the result next to the input.
Unlike the remote endpoint at https://pdf123.xyz/mcp, the agent hands it plain file paths instead of building upload requests and managing keys. There is no offline mode: the API base has to be reachable.
Install
Nothing to install: an MCP client starts it with npx -y @pdf123/mcp. To run it yourself, npm install -g @pdf123/mcp (or bun add -g, pnpm add -g) puts a pdf123-mcp command on your path.
Quick start
Claude Code:
claude mcp add pdf123 -- npx -y @pdf123/mcp
Claude Desktop (claude_desktop_config.json), Cursor (.cursor/mcp.json) and other clients that read a JSON config:
{
"mcpServers": {
"pdf123": {
"command": "npx",
"args": ["-y", "@pdf123/mcp"]
}
}
}
Restart the client, then ask, for example:
Merge ~/Documents/a.pdf and ~/Documents/b.pdf, then compress the result.
The agent calls pdf123_run_pipeline (or pdf123_run_tool) and answers with the saved path.
Requirements
Node 20.3 or newer, and network access to the API base. ES module with a pdf123-mcp binary; createServer is exported for embedding.
Configuration
Environment variables of the server process (set them in the client's env block, or with claude mcp add -e NAME=value):
| Variable | Meaning | Default |
|---|---|---|
PDFX_API_BASE |
API origin; set it to use your own pdfx-server |
https://pdf123.xyz |
PDFX_API_KEY |
API key, sent as X-API-KEY (optional) |
none |
PDFX_MCP_ROOT |
Directories the server may read and write (below) | any path the process can reach |
Self-hosting: claude mcp add pdf123 -e PDFX_API_BASE=http://localhost:8080 -- npx -y @pdf123/mcp.
Restrict file access
Set PDFX_MCP_ROOT to a directory (several separated by : on macOS/Linux or ; on Windows) and the server reads inputs, and writes results, only under it: paths outside, .. escapes and symlinks that lead out (including dangling ones, whose target does not exist yet) are refused before anything is uploaded, with Code: path_not_allowed. An explicit output file is opened without following symbolic links, and an output that cannot be written (a parent that is a file, a file where a batch needs a directory) is refused up front with Code: output_unwritable. Without it any path the server process can reach is allowed.
"env": { "PDFX_API_BASE": "https://pdf123.xyz", "PDFX_MCP_ROOT": "/Users/me/Documents/pdfs" }
Tools
Six tools: pdf123_list_tools, pdf123_describe_tool, pdf123_run_tool, pdf123_run_pipeline, pdf123_call and pdf123_server_status. Tool ids are plain strings, so the 97 PDF123 tools (organize, convert, edit, security, advanced, plus the finer analysis, filter, forms and attachments groups) are found with pdf123_list_tools and described with pdf123_describe_tool; the CLI prints the same catalog with pdfx list. Details are in the reference below.
Errors
A failed call comes back as a tool error whose text ends with Reason:, Code: and Hint: lines when the server or the SDK supplied them. A batch with any failure is an error with the per-file report attached.
Links
- Documentation: pdf123.xyz/developers/mcp, overview at pdf123.xyz/developers
- CLI: pdf123.xyz/developers/cli; SDK: @pdf123/sdk
- HTTP API: Swagger UI and OpenAPI document
- Support: pdf123.xyz/contact
Reference
Tool reference
| Tool | What it does |
|---|---|
pdf123_list_tools |
List the tools, one line each with group, returns:file|json and files:0|1|1+|2+ tags. Filter with group (a category, or analysis, filter, forms, attachments) and query (words); format: "json" returns the same rows as pdfx list --json |
pdf123_describe_tool |
A tool's fields, defaults, allowed values, page-selection format, ranges, fixed fields and whether it runs as a batch |
pdf123_run_tool |
Run one tool on local files; returns the saved path (or the JSON report). Several files with a single-file tool run as a batch, with a per-file report; input_password opens encrypted inputs, passwords sets one per file |
pdf123_run_pipeline |
Chain up to 8 tools in one request; input_password opens its one input first |
pdf123_server_status |
The server's version, upload limits, OCR page limit and languages, and the operations that are switched off (a self-hosted server turns off a tool whose program is missing); read-only, no arguments |
pdf123_call |
Raw request to any endpoint (target is a tool id, an operation id such as general/merge-pdfs, or an /api/... path) with files (paths, or an object of multipart field to path(s)) and fields; nothing is validated, for operations newer than this server |
Tool ids are plain strings (an unknown one gets "did you mean" suggestions), so the tool list stays small. A single result is { path, contentType, bytes }, plus headers and notes when the service reported something about it (the size before and after, whether a Compress target size was met, parts of a split that are over the size limit); a batch is { processed, unmatched, failed, files: [{ input, ok, path, contentType, bytes | error, reason }] } with absolute input paths, the same shapes as pdfx --json. A batch of a JSON-report tool (get-info, analysis-*) returns the reports inline as each file's report and writes nothing unless output is given. Filter tools (filter-*) answer {"matched": false} (not an error, counted in unmatched in a batch) when their condition does not hold. An empty string in params means "not set" (the default applies); only the update-metadata text fields treat it as "clear". pdf123_run_pipeline takes input_password or per-file passwords and unlocks each protected input first.
Results are written next to the first input unless output says otherwise, and never overwrite an existing file. An output file whose extension contradicts the result (a ZIP to out.pdf) is refused with Code: output_mismatch; an existing directory is accepted for a batch even if its name has a dot. passwords also works for multi-file tools such as merge: each listed file is unlocked separately first. A batch saves each file as it finishes and, when the host passes a progress token, sends a notifications/progress per file; cancelling the call stops the batch and reports the files it never reached as cancelled.
Extra options on pdf123_run_tool: passwords (parallel to files, empty string for an unencrypted file, falling back to input_password), idempotencyKey (replay the first result for 24h; a batch sends <key>:<index> per file; the same key on a different request, or a repeat whose result was over 32 MiB, is an error: send a new key), timeoutMs and concurrency. A batch with any failure comes back as an error with the per-file report attached, so a caller can retry just the failed files. A tool that finds nothing to return (e.g. pdf-to-csv on a PDF with no tables) is an error carrying Code: no_content rather than a 0-byte file. Every failure text ends with Reason:/Code:/Hint: lines when the server or the SDK supplied them, so a caller can branch without matching prose.
License
MIT, see LICENSE.