graph-docs-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
graph-docs-mcp
An MCP server that works with documents in one SharePoint/OneDrive document library through Microsoft Graph.
It reads text from .docx/.pdf, fills .docx templates, converts to PDF (with a leftover check), replaces text,
writes .xlsx tables, stamps text onto PDF backgrounds, and copies/moves files and creates folders.
There is no delete operation.
Security model
Authentication is app-only through an Azure managed identity (
IDENTITY_ENDPOINT/IDENTITY_HEADER, resourcehttps://graph.microsoft.com; setAZURE_CLIENT_IDfor a user-assigned identity). No secrets, no user tokens.Grant the identity the Graph application role
Lists.SelectedOperations.Selected, then grant it access to the one library:POST /sites/{site-id}/lists/{list-id}/permissionswithrolesof["read"]or["write"]. Never grant tenant-wideFiles.*orSites.*roles.Fallback if the list-level grant is not available:
Sites.Selectedon a dedicated site that contains only this library.The server operates on a single drive (
DOCS_DRIVE_ID) below an optional root folder (DOCS_ROOT).
Related MCP server: AVOCarbon SharePoint MCP
Safety rules
Creates never overwrite: an existing target returns
already_exists(GraphconflictBehavior=fail).Overwrites and moves need
if_match(the etag you read); a changed file returnschanged_since_read.Nothing is ever deleted: no tool and no client method calls Graph DELETE.
Files whose name starts with a protected prefix (
DOCS_PROTECTED_PREFIXES) change only withconfirm_template_change=true. The prefixes are file-name prefixes, not paths: a value containing/or\is refused at startup. The check covers in-place edits, replacing an existing PDF (docs_convert_to_pdf), overwriting an existing.xlsx(docs_write_xlsx), and both the source and the target name ofdocs_move.docs_fill_templateanddocs_convert_to_pdfcheck the PDF before upload. Check codes:unfilled_token,broken_reference,no_text. Failure ispdf_check_failed.docs_stamp_pdfreportspdf_check_failedwith these codes (plus the affected field keys, never values):missing_field,unknown_field,invalid_value,missing_glyph,too_wide,outside_page,overlaps_forbidden_box,font_not_embedded,text_not_extractable,page_count_changed,unreadable_result.Moving a folder requires
confirm_template_change=true.A file open in Word returns
locked; there is no retry loop.
Configuration
Environment variables:
Variable | Default | Meaning |
| required | Graph drive id of the library |
| empty | Folder inside the drive that acts as the root; all paths are relative to it |
| empty | Comma-separated file-name prefixes (not paths; |
| empty | Client id of a user-assigned managed identity |
|
| Largest file downloaded or produced |
|
| Text returned by |
|
| Bind address |
|
| Bind port |
|
|
|
Tools
Tool | What it does |
| List files and folders (optionally recursive) with etags; at most 500 items, |
| Text of a |
| Fill |
| Convert a |
| Literal find/replace in a |
| Write a table as |
| Copy a file or folder to a new path (create-only; a name clash returns an error) |
| Move or rename a file or folder, with |
| Create a folder |
| Stamp text fields onto a PDF background according to a JSON layout; up to 30 fields of 200 characters each; rotated pages are not supported |
If docs_fill_template creates the .docx but the PDF step fails, it returns partial with the .docx etag.
Fix the cause and call docs_convert_to_pdf; calling fill again returns already_exists.
Errors are JSON: {"error": "<kind>", "message": "..."} with kinds invalid_path, not_found, already_exists,
changed_since_read, locked, fields_mismatch, template_unsupported, pdf_check_failed, count_mismatch,
protected, too_large, forbidden, graph_error, partial. Messages contain no paths or values.
Path rules
Paths are relative to the configured root: no leading /, no empty, . or .. segments, none of
" * : < > ? \ |, no control characters, no segment ending in . or starting/ending with whitespace.
Characters in the Unicode categories Cc, Cf (for example the zero-width joiner), Zl and Zp are rejected.
A segment is at most 255 characters and the whole path at most 400. Paths are normalized to NFC.
Non-ASCII names, spaces and characters such as #, %, &, + are supported and percent-encoded per segment.
Limits
Files up to
MAX_FILE_BYTES(default 20 MB);.docxarchives are limited to 2000 entries, 200 MB uncompressed in total and 50 MB per XML part.Behind an HTTP gateway with a 1 MB request cap,
docs_write_xlsxtables are limited to roughly a few thousand rows.docs_read_texttruncates atMAX_TEXT_CHARS.Logs contain only warnings and errors with tool name, outcome and error kind; never paths, names, values or contents.
Running
export DOCS_DRIVE_ID=<drive id>
graph-docs-mcpThe server speaks MCP over streamable HTTP (stateless) on MCP_HOST:MCP_PORT (default 127.0.0.1:8000);
stdio is not supported. The server itself performs no client authentication: run it behind an authenticating
gateway and never expose it directly. The managed identity is only available inside Azure (for example Container Apps).
Development
python -m venv .venv
.venv/bin/pip install -e '.[dev]'
.venv/bin/pytestPrivacy test: tests/test_repo_is_generic.py scans every tracked file for terms from a deny-list kept outside the repo.
Run it with PRIVATE_TERMS_FILE=/path/to/terms.txt .venv/bin/pytest tests/test_repo_is_generic.py
(one term per line, case-insensitive); it is skipped when the variable is unset.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Automate enterprise-grade documents from templates, merge and 100+ conversions: PDF, Office, HTML.
Convert, create and edit Word, PowerPoint, Excel and PDF documents from any AI agent.
Search, read and cite documents. Add, replace and delete files with write access. OAuth required.
Document AI and headless DMS: OCR, IDP, search, workflows, signatures. EU-hosted, OAuth 2.1.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Microsoft SharePoint sites, document libraries, and files through the Microsoft Graph API. Supports browsing, searching, uploading/downloading files, managing lists, and creating sharing links with secure OAuth authentication.3MIT
- FlicenseNot gradedqualityBmaintenanceEnables managing SharePoint and OneDrive files, folders, permissions, and versions through Microsoft Graph API with actions like upload, download, search, and sharing.-
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to create and process office documents locally, including generating branded PDF, Word, Excel, and editable PowerPoint files from templates and themes, plus reading, OCR, form-filling, manipulation, and conversion of PDFs.1MIT
- AlicenseAqualityBmaintenanceEnables local .docx files to be managed with verified writes, returning before/after evidence for every mutation, plus PDF export and lock/sync status checks.2MIT