How to edit documents with AI agents using MCP

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Editor MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-editor -- dnx GroupDocs.Editor.Mcp --yes
Folders, licensing and more →

Run the GroupDocs.Editor MCP server locally and your agent can change the wording of a Word, Excel, PowerPoint or PDF document without re-typing it — the formatting stays, the response counts the changes, and the original file is kept:

dnx GroupDocs.Editor.Mcp --yes

In contract.docx, replace ACME Corp with Globex Ltd and keep the formatting.

Note
The commands and config snippets on this page are for the .NET build of the server — the only platform available today. Installation and client setup: MCP server for .NET. Other platforms will expose the same tools with their own launch command; everything else on this page applies unchanged.

Prerequisites

  • The .NET 10 SDK (for dnx) or Docker, and the server registered in your AI client — quick start.
  • GROUPDOCS_MCP_STORAGE_PATH pointing at the folder that holds the document.

The pattern

user            agent                          Editor MCP server
 | "Replace ACME Corp with Globex Ltd in contract.docx"           |
 |-------------->|                                                |
 |               |-- get_document_info ------------------------->|
 |               |   {"file":{"filePath":"contract.docx"}}        |
 |               |<- {"family":"WordProcessing","pageCount":1} --|
 |               |-- replace_text ------------------------------>|
 |               |   {"find":"ACME Corp","replace":"Globex Ltd", |
 |               |    "wholeWord":true}                           |
 |               |<- "Replaced 6 occurrence(s) ...               |
 |               |    Saved to: .../contract_edited.docx" -------|
 |<- "6 places changed, formatting kept; the original is untouched"
    (a find that matches nothing: "No file was written")
  1. Inspect — get_document_info says what the file is: a Word document, a workbook with three worksheets, a three-page PDF.
  2. Edit — replace_text for wording; extract_html and save_from_html when the edit is bigger than a find and replace; fill_form_fields for forms.
  3. Check the count — the response says how many places changed, and “No file was written” when nothing matched.

What the agent sees

Captured from server 26.10.0 against a synthetic services agreement. The server prints the full path inside your storage folder; it is shortened to …/ here, and the evaluation line every response starts with is trimmed unless shown.

-> get_document_info {"file":{"filePath":"contract.docx"}}
<- { "fileName": "contract.docx", "family": "WordProcessing",
     "pageCount": 1, "isEncrypted": false, "canEdit": true,
     "canSaveTo": [ "docx", "doc", "rtf", "odt", "pdf", "md", ... ] }

-> replace_text {"file":{"filePath":"contract.docx"},
                 "find":"ACME Corp","replace":"Globex Ltd","wholeWord":true}
<- Replaced 6 occurrence(s) of 'ACME Corp' in 'contract.docx'
   Saved to: …/contract_edited.docx

-> replace_text {"file":{"filePath":"contract.docx"},
                 "find":"Initech","replace":"Globex Ltd"}
<- Text replacement found no matches for 'Initech' in 'contract.docx'. No
   file was written.

The contract mentions ACME Corp seven times. Six changed — in the parties paragraph (where the name is bold), the services clause, both rows of the fee table and the signature line, each keeping its formatting. The seventh, in the notices clause, is written with ACME in italics and Corp in plain text: two formatting runs, which replace_text does not match as one phrase. That is why the count matters.

Expected result

contract_edited.docx next to the original, with the six occurrences changed and every style, table and heading as it was. In evaluation mode its first line is the evaluation banner.

What the edited copy keeps

replace_text opens the document in the engine’s HTML editing model, replaces the text there and saves a new copy. We checked a Word file built with every common feature, on server 26.10.0:

KeptChanged or lost
headings, styles, bold and italics, tables, images, hyperlinks, bookmarksthe footer, page-number field included — dropped
the header, footnotes and comments (their text is replaced too)a content control — flattened to text, its text not replaced
existing tracked changesa tracked change loses its author

When the footer matters, use extract_html with "pagination": true and save_from_html — the paginated round-trip keeps it. fill_form_fields writes without the HTML step and keeps footers.

Which tool for which edit

The editTool
a word, a name, a number, a version stringreplace_text — wholeWord, matchCase, regex
a paragraph rewritten, a phrase across formatting, a table rowextract_html → edit → save_from_html
one worksheet or slidethe same pair, with worksheet / slide and sourceFile
a Word formget_form_fields → fill_form_fields

Troubleshooting

SymptomCauseFix
The count is lower than the occurrences you seethe missed ones are split across formatting runsask the agent to extract_html the edited copy — its preview joins the runs, so a leftover shows; edit those through the HTML round-trip
“Text replacement found no matches … No file was written.”the text differs — case (matchCase is true by default), spacing, a line breakmatchCase: false, or a regex
“File ‘contract-final.docx’ not found in storage.” with a file listthe name is wrong, or the file is outside the storage folderpass a name from the list

FAQ

Is the original changed? No. The edited copy is <name>_edited.<ext> (or the outputName you ask for) in the output folder.

Does it work on Excel and PowerPoint? Yes, one worksheet or slide per call — "worksheet": 2, "slide": 1. In evaluation mode, parts 1–2 only.

Does it keep tracked changes or comments? Existing ones stay — a tracked change loses its author name, and comment text is searched and replaced like the body. New edits are not tracked. Compare the two files to show a reviewer the changes.

Does it keep headers and footers? Headers, yes. On server 26.10.0 a Word footer is dropped from the edited copy — see What the edited copy keeps above for the workaround.

Add to your CLAUDE.md or AGENTS.md

Agents follow project instructions about when to use a tool. Paste this into the instruction file your agent reads (CLAUDE.md, AGENTS.md, .github/copilot-instructions.md, .cursorrules):

To change text in documents in ./documents, use the groupdocs-editor MCP server:
replace_text, never a re-typed copy. Report the occurrence count per file and
say when a file had no match. Do not overwrite originals.

Honest limits

  • Evaluation mode: every edited document starts with an evaluation banner, a saved workbook gains an Evaluation Warning worksheet, only worksheets and slides 1–2 can be edited, and a PDF is edited two pages per call (replace_text refuses a longer PDF). Licensing.
  • One formatting run: replace_text does not see a phrase whose words are formatted differently — not on a second run either; use the HTML round-trip for those.
  • Word footers: replace_text, and extract_html without pagination, drop a Word document’s footer on server 26.10.0; content controls are flattened. What is kept.
  • No tracked changes: the edited copy carries the new text, not a redline.
  • PDF editing is a conversion: text and structure come across; exact page layout does not.

Read more