Edit PDF text with VS Code

Describe the change in plain words. VS Code calls the pdf_edit tool, the text is rewritten in place with the document's own font, the page is rendered before and after, and the edit is refused if anything else on the page moved.

A real run on the hosted sample quotation: a name, a total and an IBAN, three edits, each verified. The prompt is the one shown.

Install

One click

Install in VS Code installs the server; local files work right away. No key needed to start: 20 pages a day per IP, output watermarked. A free key (200 pages a month, no watermark on ordinary documents) lifts both.

Or by file

.vscode/mcp.json in the workspace, or the user-level file from MCP: Open User Configuration:

{
  "servers": {
    "pdfedit": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@niubai/pdfedit-mcp"
      ]
    }
  }
}

With a key:

{
  "servers": {
    "pdfedit": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@niubai/pdfedit-mcp"
      ],
      "env": {
        "PDFEDIT_API_KEY": "sk_live_your_key"
      }
    }
  }
}

Hosted server instead (PDF URLs only): {"servers": {"pdfedit": {"type": "http", "url": "https://pdfedit-mcp-remote.niubai-pdfedit-remote-worker.workers.dev/mcp"}}}

The tools appear in Copilot Chat in Agent mode (the Tools picker lists pdfedit). MCP needs VS Code 1.99 or later.

What to say

Replace

In ./quote.pdf change "Acme Inc." to "Acme GmbH" and make the total 249.00 USD.

One call to pdf_edit; the result is written as quote.edited.pdf next to the original, which is never touched, and the changed page comes back as a before/after picture.

Redact

Redact every IBAN and every email address in ./statement.pdf before I share it.

The bytes are removed, not covered; metadata is swept; the reply lists anywhere the same string still appears.

Batch

Use ./offer-template.pdf and ./hires.csv: one PDF per row, filling {name} and {salary}.

pdf_batch returns a job id; pdf_job hands back one finished document per row.

What comes back

  • The edited PDF, written as a new file (x.edited.pdf, then x.edited.2.pdf); the original is never overwritten.
  • One record per edit: page, what was found, what it became, which font was used, and whether the verification passed.
  • A before/after image of every changed page, shown in the conversation.
  • A refusal instead of a file when a change cannot be verified: the page is rendered before and after, and anything that moved outside the edit rolls the edit back.

Limits

  • Without a key: 20 pages a day per IP, output watermarked.
  • With a key: 200 pages a month free, no watermark on ordinary documents. Get a key with one email, then set PDFEDIT_API_KEY.
  • Right-to-left scripts are refused; scanned pages go through OCR and a replacement is drawn as pixels; relative-positioned text (charts) may be rolled back. The error table lists each case.

Other clients: Claude · Cursor. The same tools from any MCP client: GitHub, npm. No Node? The same API as an agent skill: npx skills add zp130221/pdfedit-mcp.