How to edit documents with AI agents using MCP
Leave feedback
On this page
Run the GroupDocs.Editor MCP server locally and your agent can change the wording of a Word, Excel, PowerPoint or PDF document without rewriting 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")
Inspect — get_document_info says what the file is: a Word document, a workbook with three worksheets, a three-page PDF.
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.
ask the agent to search the edited copy; edit the rest through extract_html
“Text replacement found no matches … No file was written.”
the text differs — case (matchCase is true by default), spacing, a line break
matchCase: false, or a regex
“File ‘contract-final.docx’ not found in storage.” with a file list
the name is wrong, or the file is outside the storage folder
pass 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 in the document; new edits are not tracked. Compare the two files to show a reviewer the changes.
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, and only worksheets and slides 1–2 can be edited (a PDF extraction holds two pages). Licensing.
One formatting run:replace_text does not see a phrase whose words are formatted differently; use the HTML round-trip for those.
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.